Issues with pinging multiple IPv4 Addresses

I’ve been having some issues with monitoring my internet connection. I followed the steps outlined in the official guide.

The “service” works correctly, as expected:

The issue is using it as a health check, I think. The error I’m getting is:

check_icmp: Failed to resolve $: Temporary failure in name resolution

The only place I can think of where the $ is coming from, is the check_icmp_arguments() function

The reason I think that is because the Service check command reads check_mk_active-icmp!-m 1 -w 200.00,80% -c 500.00,100% $HOST_ADDRESSES_4$

System Info

  • Debian 9.11
  • checkmk raw 1.6.0p7

I tried the same and got another problem.
My Service Check gets UNKN with Output of check plugin: check_icmp: Failed to resolve $: Name or service not known


And becuase my Service is UNKNWON my Host Status is OFFLINE.

Maybe this is the problem:
problem
Two IP addresses in the parameter which is used from the service check command ?
My host settings are like the totorial:

I got this error:

I have also set up the settings according to the current manual

@TiTux on cmd line can you ping internet , your hostname ?

Nope, “internet” is just there as a placeholder, as it is in the instructions.

When I activate probem
Alternative address to ping in the rule " [Check hosts with PING (ICMP Echo Request)] " I get the error.
Without this setting the service gets OK and only pings the normal IPv4 Hostaddress.

Update:

I tried it again and now I saw in WATO this:


That is looking good!
But the result is still the same:

:scream: :flushed:

It seems the custom “Internet connection” service is just broken. It fails to expand the variables.

So, the check-mk-active-icmp command is literally trying to ping $HOST_ADDRESS_4$, instead of a valid IP address.

Comparing it to the ping service, the “Service check commands” clearly show the issue, I think.

Ping Service check command: check-mk-ping!-w 200.00,80.00% -c 500.00,100.00% 1.1.1.1
Active ICMP Service check command: check_mk_active-icmp!-m 1 -w 200.00,80% -c 500.00,100% $HOST_ADDRESSES_4$

Just a quick update: this has not been fixed in 1.6.0p8

I believe I’ve found the cause of this issue.

Check_mk is building the service check command with variables like $HOST_ADDRESSES_4$, $HOST_ADDRESS_4$, etc.

It’s doing this by adding custom object variables to the Nagios host object.

If you run cmk --debug -vvN Internet, where "Internet is the hostname of your “internet host”, you might get output similar to the following:

# ----------------------------------------------------
# Internet
# ----------------------------------------------------
define host {
  _ADDRESSES_4                  8.8.8.8
  _ADDRESS_4                    1.1.1.1
  _ADDRESS_4_1                  8.8.8.8
...

And in the service configuration, you would have seen:

# Active checks
define service {
  active_checks_enabled         1
  check_command                 check_mk_active-icmp!-m 1 -w 200.00,80% -c 500.00,100% $HOST_ADDRESSES_4$ $HOST_ADDRESS_4$

The issue is that, Nagios is expecting the custom variables to look like $_HOSTADDRESS_4$. See Nagios custom object variable docs for more information.

Now, how can you solve this for yourself until check_mk devs get around to it? It’s pretty easy. Check_mk decides which variables to add to the service check command in checks/check_icmp.

I found this file on my system at /opt/omd/1.6.0p7.cre/share/check_mk/checks/check_icmp

All you have to do is replace all instances of HOST_ with _HOST. Turning $HOST_ADDRESS_4$ into $_HOSTADDRESS_4$, for example.

You might need to reconfigure the hosts so the Nagios configuration is rebuilt.


As an aside, this seems to break graphing this service. Everything else appears to work as expected.

3 Likes

Same issue here with an 1.6.0p8 cre. (Upgraded froom 1.6.0.p7)
Interesting is that this issue is not in my 1.6.0p8 CEE environment. (1.5… upgraded)

She problem is still there in Version 2.0.0p1.
I tried it on a completly other checkmk server.

Followed these steps:

My Service is UNKNOWN with summary:
check_icmp: Failed to resolve $HOST_ADDRESSES_4$: Name or service not known

But now also in WATO i get this error message
check_icmp: Failed to resolve 1.1.1.1 81.19.159.75: Name or service not known

When I modify the check_icmp file and replace all HOST_ with _HOST the only difference is that the service summary shoes the same message like WATO from the first try without the modified check_icmp file:

check_icmp: Failed to resolve 1.1.1.1 81.19.159.75: Name or service not known

(My host has 8.8.8.8 as primary IP and the other 2 as additionally addresses)

Same problems at 2.0.0p11!

Workaround modify usb example from develop check plugins

[root@monitoring ~]# cd /usr/lib/check_mk_agent/plugins
File ping_public_dns:
#!/bin/sh
echo ‘<<<ping_public_dns>>>’
ping -c 1 -W 1 8.8.8.8 | grep -e “1 received, 0% packet” || ping -c 1 -W 1 8.8.4.4 | grep -e “1 received, 0% packet” || ping -c 1 -W 1 1.1.1.1 | grep -e “1 received, 0% packet” || ping -c 1 -W 1 9.9.9.9 | grep -e “1 received, 0% packet”

OMD[mysite]:~$ cd local/lib/check_mk/base/plugins/agent_based
File ping_public_dns.py:
from .agent_based_api.v1 import *

def discover_ping_public_dns(section):
yield Service()

def check_ping_public_dns(section):
for line in section:
if line[5].startswith(“0%”):
yield Result(state=State.OK, summary=“Ping public dns ok”)
return
yield Result(state=State.CRIT, summary=“Ping public dns NOT ok”)

register.check_plugin(
name=“ping_public_dns”,
service_name=“Ping public dns (8.8.8.8, 8.8.4.4, 1.1.1.1, 9.9.9.9)”,
discovery_function=discover_ping_public_dns,
check_function=check_ping_public_dns,
)

WATO new service scan for checkmk host.