2

I'm new to check_mk and got it installed using OMD (last daily version). I'm trying to create a check so my hosts ping google to see if their network connection to the internet is working. I thought something so basic could be available using wato but I can't find it and as I have defined all using WATO now I'm not sure how to configure this manually.

I tried to add in the /omd/sites/mysite/etc/check_mk/main.mk the following


define command {
         command_name    check_tcp_http
         command_line    $USER1$/check_tcp -H $HOSTADDRESS$ -p 80
}

legacy_checks = [
   ( ( "check_tcp_http!www.google.com", "HTTP Service", True), [ "httpd" ], ALL_HOSTS ),
]

but get an error when check_mk tries to read the main.mk

Any idea how to accomplish what I want?

mwfearnley
  • 816
  • 1
  • 11
  • 22
Santi
  • 149
  • 4
  • 13
  • It's not possible to define a check like this from the server side since the agent is not designed to ever accept external input. – Florian Heigl Jun 04 '14 at 15:00

2 Answers2

2

You can use MRPE with nagios-plugins-icmp:

For example in centos agent:

# yum -y install epel-release
# yum -y install nagios-plugins-icmp

# cat /etc/check_mk/mrpe.cfg
  PingDNS8888 /usr/lib/nagios/plugins/check_icmp 8.8.8.8

Path in x86_64 maybe

/usr/lib64/nagios/plugins/check_icmp

That's all.

weijh
  • 121
  • 4
1

I manage to get it working by using local checks. I created a script on my hosts in the /usr/lib/check_mk_agent/local that the check_mk reads and pass the output to the Check_mk server

#!/bin/bash

host=8.8.8.8
if ping -c 1 $host &> /dev/nul
then
  status=0
  statustxt=OK
else
    status=2
    statustxt=CRITICAL
fi
echo "$status ping_$host varname=2;crit $statustxt"
Santi
  • 149
  • 4
  • 13
  • You should just make one addition and suppress error messages from the script as they could break the local checks section, badly. – Florian Heigl Jun 04 '14 at 14:58
  • I don't understand what do you mean. – Santi Jun 05 '14 at 16:00
  • Errors from ping wil be printed prior to the echo. When that happens, your local check section of the agent output will go to hell – Florian Heigl Jun 06 '14 at 18:00
  • Doesn't `&>` redirect all output, including errors? But the problem I see is that `/dev/nul` probably won't exist and should be `/dev/null` instead. – mwfearnley Sep 14 '22 at 10:01