Created
June 7, 2013 10:25
-
-
Save doublemarket/5728392 to your computer and use it in GitHub Desktop.
Force check specific service for the host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# force check specific service for the host | |
# using Nagios external commands | |
NOW=`date +%s` | |
CMDFILE='/var/spool/nagios/cmd/nagios.cmd' | |
# check service for the host | |
f_check() { | |
/usr/bin/printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%s\n" $NOW $HOST $SERVICE $NOW > $CMDFILE | |
if [ $? -eq 0 ] ;then | |
echo | |
echo "Success" | |
echo "Issued command : [$NOW] SCHEDULE_FORCED_SVC_CHECK;$HOST;$SERVICE;$NOW" | |
else | |
echo "Error" | |
exit 1 | |
fi | |
} | |
f_usage() { | |
echo | |
echo " Force check specific service for the host" | |
echo " using Nagios external commands" | |
echo | |
echo " usage: sh $0 hostname servicename" | |
echo | |
} | |
# MAIN | |
if [ $# -eq 2 ] ;then | |
HOST=$1 | |
SERVICE=$2 | |
f_check | |
else | |
f_usage | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/usr/bin/printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%s\n" $NOW $HOST "$SERVICE" $NOW > $CMDFILE
is better, cause it is support servicename with spaces.