====== Nagios check_visa.sh ====== ===== Background Info ===== This check was written as a spoof for a colleague who was working remotely in a slightly dodgy country. It bases the validity of the visa solely on the load of the system running the Nagios check, it does not of course, actually check a visa status. You will probably have to alter the load thresholds for your system. ===== Check code ===== #!/bin/bash # Written Andrew Stringer, 05/02/2014 # contact me on:- nagios atsymbol rainsbrook dot co dot uk # Purpose is to check XXXXX XXXXX's visa status. # This does not really check the visa status of course. # # Possible outputs:- # 0 Visa Valid # 1 Visa Valid but due to expire # 2 Visa no longer valid # 3 No visa information returned #Print out command line options usage() { echo "Usage:- check_visa.sh " 1>&2; exit 4; } #Check we have some arguments passed if [ -z "$1" ] ; then usage exit 4 fi HOSTNAME=$1 ONEMINLOAD=`uptime | cut -d: -f 5 | cut -d, -f1` VISASTATUS=$(echo "scale=1; $ONEMINLOAD * 100;" | bc | xargs printf "%1.0f") #echo "$VISASTATUS" if [[ $VISASTATUS -lt 150 ]]; then echo "OK - Visa Valid." exit 0 elif [[ $VISASTATUS -ge 150 ]] && [[ $VISASTATUS -lt 180 ]]; then echo "WARNING - Visa Valid but due to expire." exit 1 elif [[ $VISASTATUS -ge 180 ]] && [[ $VISASTATUS -lt 220 ]]; then echo "WARNING - Visa Valid but only just, more ca\$h payable." exit 1 elif [[ $VISASTATUS -ge 220 ]] && [[ $VISASTATUS -lt 260 ]]; then echo "CRITICAL - Visa no longer valid, pack your bags." exit 2 elif [[ $VISASTATUS -ge 260 ]]; then echo "CRITICAL - Visa no longer valid, deportation imminent." exit 2 else echo "UNKNOWN - No visa information returned." exit 3 fi exit 0 ===== Command Definition ===== define command { command_name check_visa command_line /usr/lib/nagios/plugins/check_visa.sh'$HOSTADDRESS$' } ===== Service Definition ===== define service { use generic-service host_name VisaHost-dummy service_description Check Visa check_command check_visa notifications_enabled 0 }