Class of service monitoring

Poll APC and Eaton UPS Cards: SNMPv3, NUT and Prometheus

Poll APC PowerNet and Eaton Network-M2 UPS cards over SNMPv3 with NUT. Verify both with upsc and scrape each UPS separately in Prometheus.

From UPS Card Guide Editorial Filed Reading 3 min
Illustrated title card for the guide: Poll APC and Eaton UPS Cards: SNMPv3, NUT and Prometheus

Use the NUT snmp-ups driver to poll an APC PowerNet UPS card and an Eaton Network-M2 card with SNMPv3 authPriv. Then give Prometheus one /ups_metrics scrape job per UPS through nut_exporter. Start by checking each card’s status in NUT. NUT driver manual · Exporter setup

Check SNMPv3 access on each card

This setup uses one host for NUT, the exporter and Prometheus. Have NUT with snmp-ups and Prometheus installed. NUT driver manual · Exporter setup

Start with SNMPv3 enabled and a polling user configured on each card. Have each card’s address, SNMPv3 username, authentication protocol and passphrase, and privacy protocol and passphrase. NUT driver manual

Add both UPSes to NUT

In ups.conf, use mibs = apcc for the APC PowerNet mapping and mibs = eaton_pw_nm2 for Network-M2. Replace the example addresses, usernames and passphrase placeholders. The protocol values are examples. Match them to each card and run snmp-ups -h to check which algorithms your Net-SNMP build supports. NUT driver manual

Keep ups.conf readable by the NUT processes that need it and restrict access to the file before adding passphrases. NUT configuration security

[apc-ups]
    driver = snmp-ups
    port = apc-ups.example.com
    mibs = apcc
    snmp_version = v3
    secLevel = authPriv
    secName = REPLACE_APC_USER
    authProtocol = SHA
    authPassword = "REPLACE_APC_AUTH_PASSPHRASE"
    privProtocol = AES
    privPassword = "REPLACE_APC_PRIVACY_PASSPHRASE"

[eaton-ups]
    driver = snmp-ups
    port = eaton-ups.example.com
    mibs = eaton_pw_nm2
    snmp_version = v3
    secLevel = authPriv
    secName = REPLACE_EATON_USER
    authProtocol = SHA256
    authPassword = "REPLACE_EATON_AUTH_PASSPHRASE"
    privProtocol = AES
    privPassword = "REPLACE_EATON_PRIVACY_PASSPHRASE"

The driver uses SNMP port 161 by default. If the card uses another port, append it to the address in port using hostname:port syntax. NUT driver manual

For a fresh same-host setup, set the local listener in upsd.conf as shown. If you are creating upsd.users for this setup, it can start empty. NUT data server configuration

LISTEN 127.0.0.1 3493

If your package manages NUT services, start the drivers and nut-server through its service manager. For a manually managed instance, start the drivers first, then the data server. NUT startup instructions

upsdrvctl start
upsd

Verify both UPSes in NUT

List the UPS names registered with upsd, then read ups.status separately for each one. Match the returned status to the UPS’s actual state. For example, OL indicates line power and OB indicates battery power. NUT status checks · upsc manual

upsc -l 127.0.0.1
upsc apc-ups@127.0.0.1 ups.status
upsc eaton-ups@127.0.0.1 ups.status

If NUT reports stale data or cannot connect to a UPS driver, check that the driver started for that entry. Recheck the corresponding card address, SNMPv3 settings and ups.conf mapping before proceeding. NUT configuration notes · NUT driver manual

Expose both UPSes to Prometheus

Download the nut_exporter binary for your host and save it as nut_exporter. Make it executable, then start it on the same host with its HTTP listener bound to loopback. Exporter binaries · chmod manual · Exporter flags

chmod u+x ./nut_exporter
./nut_exporter --nut.server=127.0.0.1 --nut.serverport=3493 --web.listen-address=127.0.0.1:9199

The exporter reads one UPS per request to /ups_metrics. Give each scrape job the ups parameter matching its section name in ups.conf. Exporter scrape examples

Add these jobs under scrape_configs in prometheus.yml. If that key already exists, append just the two jobs to its list. Restart Prometheus to apply the changes. Prometheus setup guide · Exporter scrape examples

scrape_configs:
  - job_name: nut-apc
    metrics_path: /ups_metrics
    params:
      ups: [apc-ups]
    static_configs:
      - targets: ["127.0.0.1:9199"]
  - job_name: nut-eaton
    metrics_path: /ups_metrics
    params:
      ups: [eaton-ups]
    static_configs:
      - targets: ["127.0.0.1:9199"]

Confirm that Prometheus has both status series

Open /targets in the Prometheus UI and check that both jobs show UP. Then run the query below in the expression browser and compare each job’s value with its upsc result. With the exporter’s default status settings, the OL series is 1 when NUT reports that flag and 0 when the flag is absent. Prometheus verification steps · PromQL label matchers · Exporter status handling

network_ups_tools_ups_status{flag="OL",job=~"nut-apc|nut-eaton"}

If both upsc checks work but a target is DOWN, check that the exporter is listening at the configured address and that the job passes the correct ups parameter. If a target is UP and you only see exporter process metrics, check that metrics_path is /ups_metrics. The exporter’s /metrics path serves its process metrics. Prometheus target checks · Exporter endpoints

Evidence and limits. The setup is based on the NUT 2.8.4 man pages and project guide, the nut_exporter v3.3.0 README, and the Prometheus documentation. The setup steps were not run.

Sources

  1. Network UPS Tools 2.8.4 snmp-ups manual networkupstools.org
  2. Network UPS Tools configuration notes networkupstools.org
  3. Network UPS Tools security notes networkupstools.org
  4. Network UPS Tools 2.8.4 upsc manual networkupstools.org
  5. nut_exporter v3.3.0 README github.com
  6. nut_exporter v3.3.0 release binaries github.com
  7. FreeBSD chmod manual man.freebsd.org
  8. Prometheus getting started prometheus.io
  9. Prometheus querying basics prometheus.io