check_icmp succeed on down host

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
doneil326
Posts: 82
Joined: Fri Aug 14, 2015 3:26 pm

check_icmp succeed on down host

Post by doneil326 »

hello, is there a way to get the check_icmp module to return a success status when a host is down instead of up?
bheden
Product Development Manager
Posts: 179
Joined: Thu Feb 13, 2014 9:50 am
Location: Nagios Enterprises

Re: check_icmp succeed on down host

Post by bheden »

I think creating a script to wrap the check would be the way to go. Here is a VERY basic script, which could potentially aid you.

I created a file /usr/local/nagios/libexec/check_icmp_reverse.sh, and made it executable.

Here is the contents of check_icmp_reverse.sh

Code: Select all

#!/bin/sh

ICMP_RETURN=$(/usr/local/nagios/libexec/check_icmp "$@")

OLDIFS=$IFS
IFS=" - "
read -r ICMP_VAL ICMP_DATA <<< "$ICMP_RETURN"
IFS=$OLDIFS

if [ "$ICMP_VAL" == "CRITICAL" ]; then
        echo "OK - $ICMP_DATA"
else
        echo $ICMP_RETURN
fi

As of right now, that script only takes into account if the host is in Critical state, it will return Ok with all of the associated data returned from check_icmp. Otherwise, it just returns whatever check_icmp would have returned.

You can call this script using the exact same syntax as check_icmp (/usr/local/nagios/libexec/check_icmp_reverse -H localhost, etc.).

Hope this helps!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Nagios Enterprises
Senior Developer
Locked