Last active
August 29, 2015 14:11
-
-
Save Aricg/9ff5cd70fab23a27b1a3 to your computer and use it in GitHub Desktop.
Nagios Check for Raritan 1000X PDU
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/bash | |
help () { | |
echo "====================================" | |
echo "$0" | |
echo "Option:-" | |
echo " -w : PDU Usage warning " | |
echo " -c : PDU Usage critical " | |
echo " -H : Hostname / IP address" | |
echo " -C : SNMP Community string" | |
exit 0 | |
} | |
#Defaults | |
WARNING="150" | |
CRITICAL="180" | |
COMMUNITY="" | |
DESTINATION="" | |
while getopts ":H:C:c:w:h" Option | |
do | |
case $Option in | |
w ) | |
WARNING=$OPTARG | |
;; | |
c ) | |
CRITICAL=$OPTARG | |
;; | |
H ) | |
DESTINATION=$OPTARG | |
;; | |
C ) | |
COMMUNITY=$OPTARG | |
;; | |
h ) | |
help | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
# Check parameter | |
[ -z $COMMUNITY ] && help | |
[ -z $DESTINATION ] && help | |
status="$(snmpwalk -v2c -c $COMMUNITY $DESTINATION 1.3.6.1.4.1.13742.6.5.2.3.1.6.1.1.1 | awk -F"INTEGER:" '{print $2}'| tr -d '[:blank:]')" | |
# Unknow status | |
[ -z $status ] && echo "CRITICAL: Cannot retrive information" && exit 2 | |
#check is integer | |
case $status in | |
''|*[!0-9]*) echo "CRITICAL $status is not an integer" && exit 2 ;; | |
esac | |
# Normal status | |
[ $status -lt $WARNING ] && echo "OK: RMS Current is $status out of 240" && exit 0 | |
# Warning status | |
[ $status -lt $CRITICAL ] && echo "WARNING: RMS Current is $status out of 240" && exit 1 | |
# Critical status | |
[ $status -gt $CRITICAL ] && echo "CRITICAL: RMS Current is $status out of 240" && exit 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment