User Tools

Site Tools


operating_systems:linux:debian:check_apcupsd

apcupsd plugin for nagios

By installing the apcupsd (aptitude install apcupsd) daemon to monitor UPS (in my case an IBM UPS7500XHV), we can find the nagios_plugin_check_apcupsd (in directory /usr/share/doc/apcupsd/examples/). The goal now is to compile it (this is an example with the 3.14.6 version of apcupsd) so we need:

  1. g++
  2. the nagios_plugin_check_apcupsd.c source file either from the /usr/share/doc/apcupsd/examples/ directory or directly from apcupsd.sourceforge.net

So, in summary, just follow the lines belows:

root@watchdog00:/tmp# aptitude install g++
root@watchdog00:/tmp# wget http://downloads.sourceforge.net/sourceforge/apcupsd/apcupsd-3.14.6.tar.gz?use_mirror=surfnet
root@watchdog00:/tmp# tar -xzvf apcupsd-3.14.6.tar.gz
root@watchdog00:/tmp# cd apcupsd-3.14.6
root@watchdog00:/tmp/apcupsd-3.14.6# ./configure
root@watchdog00:/tmp/apcupsd-3.14.6# ./make

Then we need to modify slightly the nagios_plugin_check_apcupsd.c to change the path to the apc.h file.
Originally the header file is: #include “apc.h”
So we modify this line to: #include “include/apc.h” In summary:

root@watchdog00:/tmp/apcupsd-3.14.6# cp examples/nagios_plugin_check_apcupsd.c ./
root@watchdog00:/tmp/apcupsd-3.14.6# vi nagios_plugin_check_apcupsd.c #And do the modification

finally we can compile it:

root@watchdog00:/tmp/apcupsd-3.14.6# g++ nagios_plugin_check_apcupsd.c src/lib/libapc.a -o check_apcupsd

which provides the check_apcupsd plugin for nagios.

Finally just add this plugin in /usr/local/lib/nagios/plugins/

root@watchdog00:/tmp/apcupsd-3.14.6# cp check_apcupsd /usr/local/lib/nagios/plugins/

and edit your commands.cfg (usually in /etc/nagios3) to add:

define command {
command_name                    check_apcupsd
command_line                    /usr/local/lib/nagios/plugins/check_apcupsd
}
operating_systems/linux/debian/check_apcupsd.txt · Last modified: 2011/08/14 17:48 by sbolay