Atom Feed
Comments Atom Feed

Similar Articles

2009-10-31 16:02
LM Sensors stats on Cacti (via SNMP)
2015-05-14 22:35
PHP APC on Cacti via SNMP
2009-11-14 13:46
Apache stats on Cacti (via SNMP)
2009-10-31 14:46
SMART stats on Cacti (via SNMP)
2015-01-08 22:58
Nginx on Cacti via SNMP

Recent Articles

2019-07-28 16:35
git http with Nginx via Flask wsgi application (git4nginx)
2018-05-15 16:48
Raspberry Pi Camera, IR Lights and more
2017-04-23 14:21
Raspberry Pi SD Card Test
2017-04-07 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
2017-03-28 13:07
Kubernetes to learn Part 4

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 and Cacti Templates for apcupsd are on GitHub

I place script apcupsd-stats (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.

Simply import the template cacti_host_template_apcupsd.xml, 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"