Nagios: Check powersupply HP DL380G8 with snmp through ILO4

I want to monitor the power supplies from an HP DL380G8, but only have access to the ILO4.

So i look for the snmp adress for the powersupply via ILO4 and HP DL380. (and a „little try and error“).

I wrote a little plugin:  check_my_ps

(copy it to:  /usr/lib64/nagios/plugins/)

———————————————-

#!/bin/bash
#
# check_my_ps
# check powersupply with snmp through ILO4
#
# v 1.0 21.06.2013 J.H.
#
# $1 = HostIP

PSUHealth=`snmpget -v 2c -c public $1 .1.3.6.1.4.1.232.6.2.9.1.0 | grep „INTEGER: 2″`

if [[ $? -ne 0 ]] ; then
echo „ERROR:Power Supply Problem – visit https://$1 for more information.“
exit 2
else
echo „OK: Powersupplies ok“
exit 0
fi
———————————————-
in /etc/nagios/objects add entry to commands.cfg:

define command{
command_name         check_my_ps
command_line            $USER1$/check_my_ps $HOSTADDRESS$
}

———————————————-

in /etc/nagios/objects add entry to <servername.cfg>

define service{
use                                   generic-service
host_name                    myServer.sample.org
service_description    Power Supply
check_command         check_my_ps
}

———————————————-

It works in my enviroment, maybe it doesn’t work in yours. Take it as a sample for own plugins.

Nagios Core 3.4.3, CentOS release 6.4 (Final)

Output in Nagios: (click on image for details)
nagios_check_my_ps_output_cr