#!/bin/sh - # # Proof Of Concept Implementation # # Yield UNKNOWN value if the parent (related) plugin failed to run succesfully. # Mainly used to disable NRPE2 checks if the NRPE2 daemon is not running or # reachable. # # Rick van der Zwet # EXIT_OK=0 EXIT_WARNING=1 EXIT_CRITICAL=2 EXIT_UNKNOWN=3 NRPE2_ARGS=$* NRPE2_RUNNING_CHECK="NRPE2" CHECK_NRPE2=/usr/local/libexec/nagios/check_nrpe2 while [ -n "$1" ]; do if [ "$1" = "-H" ]; then HOSTADDRESS=$2 break; fi shift done if [ -z "$HOSTADDRESS" ]; then echo "CRITICAL: No valid host argument (-H) was found in: $NRPE2_ARGS" exit $EXIT_CRITICAL fi STATE=`printf "GET services\nColumns: state\nFilter: description = $NRPE2_RUNNING_CHECK\nFilter: host_address = $HOSTADDRESS\n" | /usr/local/lib/mk-livestatus/unixcat /var/spool/nagios/rw/live` if [ -z "$STATE" ]; then echo "CRITICAL: NRPE2 Deamon Alive check ($NRPE2_RUNNING_CHECK) cannot be found" elif [ "$STATE" != "0" ]; then echo "UNKNOWN: NRPE2 Deamon not running." exit $EXIT_UNKNOWN else $CHECK_NRPE2 ${NRPE2_ARGS} fi