Need a sanity check with pdu plug-in
Posted: Thu Jul 30, 2015 1:14 pm
Hoping to get another pair of eyes on this as I am a struggling to figure this one out. I recently added an APC PDU load script from https://exchange.nagios.org/directory/P ... s#rev-1648 to my Nagios Xi installation and am having trouble getting it to work. After several failed command and service configuration tests, I decided to look at the script's code to see where the potential hang up could be. Here is the script's code.
Having read through this, I am under the impression that this plugin only supports SNMPv2c calls to the target devices. Am I correct in this assessment? It certainly would explain why I am unable to pull a response from my PDUs as they only support SNMPv1 and v3. Thanks in advance for your help.
- Rob
Code: Select all
#!/bin/bash
#
# Program : check_apc_pdu_load
# :
# Author : Deraoui Saïd <[email protected]>
# Purpose : Nagios plugin to return Information from APC PDU Load status
# :
# Parameters : --help
# : --version
# :
# Returns : Standard Nagios status_* codes as defined in utils.sh
# :
# Licence : GPL
#
# Notes : See --help for details
#============:==============================================================
PROGNAME=`basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.0.0.1 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME [-H hostname] [-c communauty] [-w warning] [-c critical]"
echo " -H Hostname"
echo " -C Communauty"
echo " -w (optional) warning threshold"
echo " -c (optional) critical threshold"
echo ""
echo ""
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
echo "Nagios Plugin to check PDU APC Load"
echo ""
print_usage
echo ""
echo "PDU APC Load Status Check. © Deraoui Said 2012"
echo ""
exit 0
# support
}
# If we have arguments, process them.
#
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
-H)
REMOTEHOST=$2;
shift;
;;
-C) COMMUNAUTY=$2;
shift;
;;
-c)
CRITICALNUMBER=$2
shift;
;;
-w)
WARNINGNUMBER=$2;
shift;
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
if [ "${REMOTEHOST}" = "" ]; then
echo "UNKNOWN: Please check hostname"
exit $STATUS_UNKNOW
fi
if [ "${COMMUNAUTY}" = "" ]; then
COMMUNAUTY=public
fi
if [ "$WARNINGNUMBER" = "" ]; then
WARNINGNUMBER=10
fi
if [ "$CRITICALNUMBER" = "" ]; then
CRITICALNUMBER=8
fi
LOAD=`snmpwalk -v2c -c ${COMMUNAUTY} ${REMOTEHOST} SNMPv2-SMI::enterprises.318.1.1.12.2.3.1.1.2.1 | awk '/Gauge32:/ {print $4}'`
if [ "$LOAD" = "" ]; then
echo "UNKNOWN: Unable to get load from PDU"
exit $STATUS_UNKNOWN
fi
if [ $LOAD -lt $WARNINGNUMBER ]; then
exitstatus=$STATU_OK
ULOAD=`echo "scale=2; ${LOAD}/10" | bc`
MSG="OK: ${ULOAD} Amps of load"
elif [ $LOAD -lt $CRITICALNUMBER ]; then
exitstatus=$STATU_WARNING
ULOAD=`echo "scale=2; ${LOAD}/10" | bc`
MSG="WARNING: ${ULOAD} Amps of load PDU, please check."
elif [ $LOAD -ge $CRITICALNUMBER ]; then
exitstatus=$STATU_CRITICAL
ULOAD=`echo "scale=2; ${LOAD}/10" | bc`
MSG="CRITICAL: ${ULOAD} Amps of load PDU."
else
echo="CRITICAL: Unknown command"
print_help
exitstatus=$STATE_CRITICAL
fi
echo $MSG
exit $exitstatus
- Rob