############################################### # check_apc_emu # nagios plugin for APC's env. monitoring unit # checks the following conditions # - temperature probe 1 # - temperature probe 2 # - contact status external contact 1 # - contact status external contact 2 # - contact status external contact 3 # - contact status external contact 4 # # The code is free software # # cjohn@mpi-bremen.de 8/2006 # ############################################### if [ ! "$#" == "9" ]; then echo -e "Warning: not enough arguments. \nUsage: ./check_apc_emu warn_t1 crit_t1 warn_t2 crit_t2 crit_c1 crit_c2 crit_c3 crit_c4\n crit_cX=1: normal open, crit_cX=2: normal closed\n" && exit "3"; fi HOSTNAME=$1 WARN_T1=$2 CRIT_T1=$3 WARN_T2=$4 CRIT_T2=$5 CRIT_CON1=$6 CRIT_CON2=$7 CRIT_CON3=$8 CRIT_CON4=$9 STATUS_T1=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.1 | awk '{print $4}') STATUS_T2=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.2 | awk '{print $4}') STATUS_H1=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.13.1.1.6.1 | awk '{print $4}') STATUS_H2=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.13.1.1.6.2 | awk '{print $4}') STATUS_C1=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.1 | awk '{print $4}') STATUS_C2=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.2 | awk '{print $4}') STATUS_C3=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.3 | awk '{print $4}') STATUS_C4=$(snmpget -v1 -cpublic $HOSTNAME .1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.4 | awk '{print $4}') OVERALL_STATUS=0 CONTACT1="normal" CONTACT2="normal" CONTACT3="normal" CONTACT4="normal" # check for critical condition if [ $STATUS_T1 -gt $CRIT_T1 ]; then OVERALL_STATUS=2 fi if [ $STATUS_T2 -gt $CRIT_T2 ]; then OVERALL_STATUS=2 fi if [ $STATUS_C1 -eq $CRIT_CON1 ]; then OVERALL_STATUS=2; CONTACT1="critical"; fi if [ $STATUS_C2 -eq $CRIT_CON2 ]; then OVERALL_STATUS=2; CONTACT2="critical"; fi if [ $STATUS_C3 -eq $CRIT_CON3 ]; then OVERALL_STATUS=2; CONTACT3="critical"; fi if [ $STATUS_C4 -eq $CRIT_CON4 ]; then OVERALL_STATUS=2; CONTACT4="critical"; fi if [ $OVERALL_STATUS -eq 2 ]; then echo "CRITICAL: Temp #1:$STATUS_T1 - #2:$STATUS_T2, Contact #1:$CONTACT1 - #2:$CONTACT2 - #3:$CONTACT3 - #4:$CONTACT4"; exit $OVERALL_STATUS; else if [ $STATUS_T1 -gt $WARN_T1 ]; then OVERALL_STATUS=1; fi if [ $STATUS_T2 -gt $WARN_T2 ]; then OVERALL_STATUS=1; fi if [ $OVERALL_STATUS -eq 1 ]; then echo "WARNING Temp #1:$STATUS_T1 - #2:$STATUS_T2, Contact #1:$CONTACT1 - #2:$CONTACT2 - #3:$CONTACT3 - #4:$CONTACT4"; exit $OVERALL_STATUS; else echo "OK: Temp #1:$STATUS_T1 - #2:$STATUS_T2, Contact #1:$CONTACT1 - #2:$CONTACT2 - #3:$CONTACT3 - #4:$CONTACT4"; exit $OVERALL_STATUS; fi fi