Can we monitor a host without an active connection

In the configuration, I read check_mk host are monitored from the master by queries are host. Is there any option to monitor a host without queries instead only by configuring host to send status or events to the master using a script or agent with check_mk. If it is possible please help me to achieve it.

Yes. The basic idea and steps would be as follows:

  • Install the checkmk-agent on the host to be monitored
  • Create ssh keys on the host and put the public key into the authorized_keys file on the checkmk-server
  • Create a cronjob (or systemd timer) on the host to call the checkmk-agent every minute
  • Pipe (or copy) the agent’s output to a file on the checkmk-server via ssh
  • Configure the checkmk-server with a “datasource rule” to “cat the_file”

Of course you will need to add some logic so that the server won’t do a cat on the file when it’s not fully written yet or when the file doesn’t exist or is too old.

1 Like

Thanks for your reply. If possible can you please share some reference article or configuration to do the same.

From your reply i can understand without check_mk server querying the metrics host will push the metrics to server with ssh through the metrics collected with cronjob.

Now this metrics data are available in the check_mk server. It could be more helpful if you have explain me how to configure check_mk server to read metrics inputs from the copied data because as per understanding there are only below options when we configure host to be monitored with agent or snmp right.

I am newly trying to use check_mk for monitoring. Please help to achieve the monitoring without passive connection because my host does not have public ip. So it cannot be accessed from check_mk server for querying the required scripts but it can send the data locally collected with any script via my nat instance.

Thanks in advance for your help.

As Dirk said:

  1. run the agent on the host (monitoring client) - e.g. scheduled from cron, probably as root (or with sudo) to get all the information
  2. capture the agent output and transfer it to the monitoring server - use whichever method best fits your environment. Like, copy the file via scp to ~/tmp/check_mk/agent-output-from-your-hostname on the monitoring server.
  3. configure a WATO rule “Individual program call instead of agent access” for this host:
    “Command line to execute” cat ~/tmp/check_mk/agent-output-from-your-hostname. So instead of trying to connect to the agent on the host, the monitoring server just reads the information from the local file you copied there.
  4. If you cannot ping the host, then add another WATO rule, “Host Check Command” for this host:
    “Use a custom check plugin …” check_file_age -w 120 -c 120 -f ~/tmp/check_mk/agent-output-from-your-hostname. So if the file is older than 120 seconds, the host will be considered down.
6 Likes

Thanq so much my dear friend will try to configure the monitoring as you mentioned.

Do i need to run the command “check_mk_agent > /tmp/check_mk/ip-172-30-0-43.ap-south-1.compute.internal” and save the output to a file in tmp dir or is there any command to get all the information. Thanks in advance

Running the agent is the “command to get all the information”. So yes, you probably want to output this to a tmp file. Depending on your environment, you could also pipe the output directly to another command, e.g. to send it via e-mail.

2 Likes

Hi Martin,
Thanks for sharing your knowledge. I have done all the configurations. Now the output is getting copied to checkmk server from client. After that i created a rule. Now will it automatically get applied to the hosts in that folder because i dont any monitoring metrics for that client host in check_mk

?
Just put the rule in the top folder and restrict it to this explicit host.

1 Like

I use that too, and you can put 127.0.0.1 for IP Address ( Host is of course allways up )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.