viral32111 / apc-ups-exporter

Prometheus exporter for APC UPS status data.
http://www.apcupsd.org/manual
GNU Affero General Public License v3.0
7 stars 1 forks source link
exporter metrics prometheus ups

APC UPS Exporter

CI CodeQL GitHub tag (with filter) GitHub repository size GitHub release downloads GitHub commit activity

This is a Prometheus exporter for the status data reported by APC's Uninterruptible Power Supplies.

The status data is fetched from apcupsd's Network Information Server (NIS), so ensure it is enabled in your apcupsd.conf configuration file.

I test this against my APC Back-UPS 850VA (BE850G2-UK).

📥 Usage

Download the latest release for your platform. There are builds available for Linux and Windows, on 32-bit and 64-bit architectures of x86 and ARM. There are extra Linux builds to accommodate glibc and musl libraries.

The utility does not expect any command-line arguments. There are sensible defaults in place, so it should run without any configuration. However, functionality can be changed using the optional command-line flags below.

These flags can be prefixed with either a single (-) or double (--) hyphen.

Use the --help (-h) flag for more information.

🐳 Docker

Alternatively, there is a Docker image available for Linux.

The image is based on Ubuntu (ghcr.io/viral32111/apc-ups-exporter:latest-ubuntu) weighing in at roughly 130 MiB. However, there is a variant based on Alpine Linux (ghcr.io/viral32111/apc-ups-exporter:latest-alpine) which is much lighter at roughly 20 MiB.

Run the command below to download the image and create a container. Replace the :latest tag with your desired variant (e.g., :1.2.0-ubuntu, :main-alpine, etc.).

docker container run \
    --name apc-ups-exporter \
    --network host \
    --detach \
    ghcr.io/viral32111/apc-ups-exporter:1

The host's networking stack is often required to connect to the daemon's Network Information Server.

🖼️ Examples

Serve metrics at /metrics the default loopback port 5000 using data fetched every 15 seconds from the Network Information Server at 192.168.0.5 on the default port 3551:

$ apc-ups-exporter --nis-address 192.168.0.5
The configured Network Information Server is: 192.168.0.5:3551.

Resetting all metrics...
Starting background metrics collection...
Serving metrics page at http://127.0.0.1:5000/metrics...

Connected to the Network Information Server.
 Fetched status from the Network Information Server.
    Updated the status metric.
    Updated the temperature metric.
    Updated the power metrics.
    Updated the battery metrics.
    Updated the daemon metrics.
 Disconnected from the Network Information Server.
 Waiting 15 seconds for next collection..

📰 Metrics

The following Prometheus metrics are exported:

Status

Temperature

Power

Battery

Daemon

⚖️ License

Copyright (C) 2022 viral32111.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses.