#! /bin/sh # # HP hpasm hplog utility plugin for Nagios # Written by Brien Dieterle (brien.dieterle@cgcmail.maricopa.edu) # Last Modified: 11-29-2005 - Revision: 1.0 # # Usage: ./check_hplog -type temp|fan|ps -id [-w ] [-c ] # # Examples: # # ./check_hplog -type temp -id 1 -w 40 -c 50 # TEMP OK - 1 28 # # ./check_hplog -type temp -id 1 -w 40 -c 50 # TEMP WARNING - 1 44 # # Description: # # This plugin checks hardware status of HP Proliant Servers via the hplog utility included with hpasm, # # HPASM needs administrator rights. # add this line to /etc/sudoers # # nagios ALL=NOPASSWD: /sbin/hplog # PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin PROGNAME=`basename $0` PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` REVISION=`echo '$Revision: 1.0 $' | sed -e 's/[^0-9.]//g'` . $PROGPATH/utils.sh print_usage() { echo "" echo "Usage: $PROGNAME -type temp|fan|ps -id [-w ] [-c ]" echo "Usage: $PROGNAME [-h | --help]" echo "Usage: $PROGNAME [-V | --version]" echo "" echo " NOTE:" echo "" echo " HPASM needs administrator rights." echo " add this line to /etc/sudoers" echo " nagios ALL=NOPASSWD: /sbin/hplog" echo "" } print_help() { print_revision $PROGNAME $REVISION echo "" print_usage echo "" echo "This plugin checks hardware status for HP Proliant servers using HPASM's hplog utility." echo "" support exit 0 } if [ $# -lt 1 ]; then print_usage exit $STATE_UNKNOWN fi case "$1" in --help) print_help exit 0 ;; -h) print_help exit 0 ;; --version) print_revision $PROGNAME $REVISION exit 0 ;; -V) print_revision $PROGNAME $REVISION exit 0 ;; -type) if test "$2" = "temp"; then check=`sudo -u root hplog -t |grep -E "^ $4" |sed 's/^.*\b\([0-9][0-9]\)C.*[0-9].*/\1/'` if test "$check" -ge "$8"; then echo "TEMP CRITICAL - id=$4 temp=$check" exit $STATE_CRITICAL elif test "$check" -ge "$6"; then echo "TEMP WARNING - id=$4 temp=$check" exit $STATE_WARNING elif test "$check" -lt "$6"; then echo "TEMP OK - id=$4 temp=$check" exit $STATE_OK else echo "TEMP UNKNOWN - id=$4 temp=$check" exit $STATE_UNKNOWN fi fi if test "$2" = "fan"; then check=`sudo -u root hplog -f |grep -E "^ $4" |grep -q Nominal` status=$? if test "$status" -eq 0 ; then echo "FAN OK - id=$4" exit $STATE_OK else echo "FAN CRITICAL - id=$4" exit $STATE_CRITICAL fi fi if test "$2" = "ps"; then check=`sudo -u root hplog -p |grep -E "^ $4" |grep -q Nominal` status=$? if test "$status" -eq 0 ; then echo "POWERSUPPLY OK - id=$4" exit $STATE_OK else echo "POWERSUPPLY CRITICAL - id=$4" exit $STATE_CRITICAL fi fi ;; *) print_usage ;; esac