Friday, December 3, 2010

Nagios NRPE APC UPS monitor



Scenario / Question:

How do I monitor APC UPS Battery via apcaccess on linux

Solution / Answer:

Use the check_apcupsd plugin and NRPE

Download check_apcupsd Plugin on Remote Host Server

The original check_apcupsd plugin can be found here.
check_apcupsd
I modified the check_apcupsd plugin to include  the STATUS (Online or Offline) and renamed it to check_apcups
Which can be downloaded from here.
check_apcups
1. Download the plugin to folder /usr/local/nagios/libexec/
2. Change permissions on plugin to nagios
# cd /usr/local/nagios/libexec/
# chown nagios.nagios check_raid
# chmod 775 check_raid
3. Test the plugin works
# /usr/local/nagios/libexec/check_apcups -w 80 -c 60 bcharge

Edit nrpe.cfg File on Remote Host Server

Add a new command definition to the nrpe.cfg file on the remote host
# vi /usr/local/nagios/etc/nrpe.cfg
Add new check_apcups command definitions.
command[check_apcups_bcharge]=/usr/local/nagios/libexec/check_apcups -w 95 -c 50 bcharge
command[check_apcups_itemp]=/usr/local/nagios/libexec/check_apcups -w 35 -c 40 itemp
command[check_apcups_loadpct]=/usr/local/nagios/libexec/check_apcups -w 75 -c 85 loadpct
command[check_apcups_status]=/usr/local/nagios/libexec/check_apcups status
Because we are running xinetd we do not need to restart the NRPE daemon. Otherwise you would have to restart the NRPE daemon for the changes to take effect.

Add Service Definition to Nagios Monitoring Server

On the monitoring host, you need to define a new service for check_something on the remote host. Add
the following entry to one of your object configuration files (linux-server-remote.cfg)

define service {
        use                     generic-service
        host_name               remotehost
        service_description     APC STATUS
        check_command           check_nrpe!check_apcups_status
        }

define service {
        use                     generic-service
        host_name               remotehost
        service_description     APC CHARGE
        check_command           check_nrpe!check_apcups_bcharge
        }

define service {
        use                     generic-service
        host_name               remotehost
        service_description     APC TEMP
        check_command           check_nrpe!check_apcups_itemp
        }

define service {
        use                     generic-service
        host_name               remotehost
        service_description     APC LOAD
        check_command           check_nrpe!check_apcups_loadpct
        }
Next, verify your Nagios configuration files and restart Nagios.
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# service nagios restart

1 comment: