Skip to content

NekoShinobi/pyapcupsdexporter

 
 

Repository files navigation

pyapcupsdexporter

Dockerized Python script that will send data from apcupsd to influxdb.

This is a fork of https://github.com/atribe/apcupsd-influxdb-exporter to add InfluxDB 2.x support.

NOTE

  • This still works as-is, but due to influxDB's terrible way of managing v1->v2->v3, I've decided to stop maintaining this altogether.
  • Trying to move away from InfluxDB, using greptimeDB as replacement, and prometheus exports / gRPC whenever possible.
  • You can check out my Rust Prometheus Export here - https://github.com/xNinjaKittyx/rsapcupsdexporter
    • Ram consumption 30 MB -> 8 MB
    • Docker image size is very small. ~2 MB

How to Use

Run docker container directly

docker run --rm  -d --name="pyapcupsdexporter" \
    -e "WATTS=600" \
    -e "INFLUX_URL=http://10.0.1.11:8086" \
    -e "INFLUX_TOKEN=asdflkajwse;orfiajsdklfjaskl==" \
    -e "INFLUX_ORG=my-org" \
    -e "APCUPSD_HOST=10.0.1.11" \
    -t ghcr.io/xNinjaKittyx/pyapcupsdexporter

Note: if your UPS does not include the NOMPOWER metric, you will need to include the WATTS environment variable in order to compute the live-power consumption metric.

Run from docker-compose

version: '3'
services:
  pyapcupsdexporter:
    image: ghcr.io/xninjakittyx/pyapcupsdexporter
    container_name: apcupsd-influxdb-exporter
    restart: always
    environment:
      WATTS: 1500 # if your ups doesn't have NOMPOWER, set this to be the rated max power, if you do have NOMPOWER, don't set this variable
      APCUPSD_HOST: 10.0.1.11  # Host running APCUPSD
      INFLUX_URL: http://10.0.1.11:8086  # URL of the InfluxDB instance
      INFLUX_ORG: my-org  # ORG Associated with your influx bucket.
      INFLUX_TOKEN:  # Token associated with your influx instance/org
      INFLUX_BUCKET: apcupsd
      INTERVAL: 5
      VERBOSE: true

If you want to debug the apcaccess output or the send to influxdb, set the environment variable "VERBOSE" to "true"

How to build

Building the image is straight forward:

  • Git clone this repo
  • docker compose -f docker-compose.yml build
  • docker compose -f docker-compose.yml up

Environment Variables

These are all the available environment variables, along with some example values, and a description.

With the changes to InfluxDB 2.0, this currently requires you to have an ORG + Token setup instead of the base username/password.

Environment Variable Example Value Description
WATTS 1000 if your ups doesn't have NOMPOWER, set this to be the rated max power, if you do have NOMPOWER, don't set this variable
APCUPSD_HOST 192.168.1.100 host running apcupsd, defaults to the value of influxdb_host
INFLUX_URL http://192.168.1.100:8086 required. URL to your InfluxDB Instance.
INFLUX_ORG my-org required, the name of the organization.
INFLUX_TOKEN somebase64string required, needed to log in to InfluxDB instance
INFLUXDB_PORT 8086 optional, defaults to 8086
INFLUXDB_PORT 8086 optional, defaults to 8086
INTERVAL 10 optional, defaults to 10 seconds
VERBOSE true if anything but true docker logging will show no output

Contributing

Contributions are welcome. I will try my best to review it as soon as possible.

About

Docker-based APCUPSd daemon that sends UPS-device information to InfluxDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 79.3%
  • Dockerfile 20.7%