From 68e44f853eb0e720c73b31ec6e1a0adc38f677a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3mas=20Edwardsson?= Date: Thu, 25 Nov 2010 23:17:13 +0000 Subject: [PATCH] check_uptime updated to support remote hosts via nrpe --- check_uptime/trunk/check_uptime | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/check_uptime/trunk/check_uptime b/check_uptime/trunk/check_uptime index f16cf8d..a9a7fee 100644 --- a/check_uptime/trunk/check_uptime +++ b/check_uptime/trunk/check_uptime @@ -22,7 +22,14 @@ HOSTN="localhost" # By default check localhost CHECK_COMMAND="uptime" # Default command to check uptime +# We we are not checking localhost, lets get remote uptime via NRPE +if [ "$HOSTN" -ne "localhost" ]; then + export PATH=$PATH:/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins + CHECK_COMMAND="check_nrpe -H $HOSTN -c get_uptime" +fi + +# Get the uptime, raise error if we are unsuccessful OUTPUT=`$CHECK_COMMAND` RESULT=$? @@ -32,6 +39,7 @@ if [ $RESULT -gt 0 ]; then exit 3 fi +# Parse the output from uptime command set -- $OUTPUT if [ $4 == 'min(s),' ]; then echo "Warning, $HOSTN uptime is $OUTPUT"