Glen Pitt-Pladdy :: Blog

apcupsd stats on Cacti (via SNMP)

Following on from the basics of SNMP I did previously, this article now adds another set of SNMP extension scripts, config, and Cacti templates to monitor APC UPS' via apcupsd.

apcupsd Config

apcupsd is one of the standard ways of monitoring APC UPS' and has a huge variety of devices and connectivity options. It can also serve the status information to other hosts which avoids needing a network management card.

To get the status for Cacti, I use the network service (NIS as it is known in the config), so you need to ensure that this is enabled and available on the local interface. Since I have already got SNMP v3 configured with encryption on the server, I chose to use this to transmit the data rather than allow apcupsd to serve the data to the cacti monitoring server. The script I provide could easily be modified to allow remote monitoring without SNMP by passing the hostname argument through to apcaccess and adding labels to the parameters.

 

If your config is correct then you should be able to get a list of parameters from apcupsd by running:

$ /sbin/apcaccess status localhost

Getting apcupsd satus over SNMP

I have created a simple Perl wrapper script for apcaccess to get it into SNMP.

Download:  Perl script to send apcupsd status for SNMP

I place this script (make it executable first: chmod +x apcupsd-stats) in /etc/snmp

In /etc/snmp/snmpd.conf add the following line:

extend apcupsd /etc/snmp/apcupsd-stats

Once you have added all this in you can test apcupsd-stats by running it from the command line, and via SNMP by appending the appropriate SNMP OID to the "snmpwalk" commands shown previously.

Cacti Templates

I have generated some basic Cacti Templates for apcupsd. Since different model UPS' give different information, not all the graphs may be appropriate on your UPS. On my one the Output Voltage always gives 230V. the Internal Temperature always 29.2°C, and although the Line Frequency does vary, it does this in steps of 1Hz which is way to course of be of interest.

Download: Cacti Templates for apcupsd status over SNMP

Simply import this template, and add the graphs you want to the appropriate device graphs in Cacti. It should just work if your SNMP is working correctly for that device (ensure other SNMP parameters are working for that device).

Graph Screen Shots

apcupsd over SNMP on Cacti : Battery Charge

apcupsd over SNMP on Cacti : Battery Voltage

apcupsd over SNMP on Cacti : Internal Temperature

apcupsd over SNMP on Cacti : Line Frequency

apcupsd over SNMP on Cacti : Line Voltage

apcupsd over SNMP on Cacti : Line Voltage, no Output

apcupsd over SNMP on Cacti : Load Percent

apcupsd over SNMP on Cacti : Load Power

apcupsd over SNMP on Cacti : Status

apcupsd over SNMP on Cacti : Time Left

 

Different versions of Cacti:

One person had pointed out that there has been some problems on some versions of Cacti with importing the templates. The template was generated with version 0.8.7b (from Debain Lenny).

The problem manifests it's self as "Cacti version does not exist" error, and appears to be cured by adding in this version, although in my version the file is actually global_arrays.php

The relevant array from my global_arrays.php / config_array.php:

$hash_version_codes = array(
    "0.8.4"  => "0000",
    "0.8.5"  => "0001",
    "0.8.5a" => "0002",
    "0.8.6"  => "0003",
    "0.8.6a" => "0004",
    "0.8.6b" => "0005",
    "0.8.6c" => "0006",
    "0.8.6d" => "0007",
    "0.8.6e" => "0008",
    "0.8.6f" => "0009",
    "0.8.6g" => "0010",
    "0.8.6h" => "0011",
    "0.8.6i" => "0012",
    "0.8.6j" => "0013",
    "0.8.7"  => "0014",
    "0.8.7a" => "0015",
    "0.8.7b" => "0016",
    "0.8.7c" => "0017",
    "0.8.7d" => "0018",
    "0.8.7e" => "0019",
    "0.8.7f" => "0020",
    "0.8.7g" => "0021"
    );

 

Comments:

Chandrakanta Sahoo Image  17/01/2011 11:51 :: Chandrakanta Sahoo

Hi,

I have installed Cacti Version 0.8.7e on my CENTOS-5.5 Server & getting the graphs of some network devices. I want to add my APC Switched Rack PDU in cacti to view the performance graph. My APC Switched Rack PDU is connected to my network switch not directly connected to my cacti server. I have installed apcupsd on my cacti server. Then I have created a file apcupsd-stats.pl in /etc/snmp/ & given the execute permission. Then I issue the below command & get the below error:

[andola-sys1@nagios ~]$ /sbin/apcaccess status 192.168.40.15

Error contacting apcupsd @ 192.168.40.15:3551: Connection refused

[andola-sys1@nagios ~]$ /sbin/apcaccess status 192.168.40.15:3551

Error contacting apcupsd @ 192.168.40.15:3551: Connection refused

SO please help me to do the same




Are you human? (reduces spam)
Note: Identity details will be stored in a cookie. Posts may not appear immediately