prom-apcupsd-exporter

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 11 Imported by: 0

README

Prometheus apcupsd exporter

Docker Automated build

Docker Hub repository

iodeveloper/prom-apcupsd-exporter:latest

Use cases

  • Provides wide apcupsd metrics for prometheus.

    • apcupsd_input_*: input line metrics
    • apcupsd_output_*: output line metrics
    • apcupsd_battery_*: battery metrics
    • apcupsd_ups_*: UPS status and settings
    • apcupsd_shutdown_*: apcupsd shutdown settings
  • Can be integrated with apccontrol signals such as powerout, startselftest and etc.

  • Built-in websocket server allow to connect and notify web clients for events/signals. Example: lightweight status widget on pure js/css (responsive alternative to grafana for realtime monitoring).

  • This exporter calculates events between previous and latest states. Changed fields and new events are broadcasting to connected clients via websocket.

Grafana example

Grafana

Widget example

Websocket widget for pad (not included in this project): instant reaction for plug-out and plug-in. Status change: ONLINE -> ONBATTERY (powerout) -> ONLINE

Widget

Prerequisites:

Both services in docker because server shutdown is not required

SUA1500i connected via serial port /dev/ttyS0 in smart mode. After start on host appear two ports: 3559 - apcupsd, 3560 - exporter.

docker-compose.yml:
version: '3.4'

services:
  apcupsd:
    build: .
    restart: always
    user: root
    devices:
      - "/dev/ttyS0:/dev/ttyS0"
    volumes:
      - ./conf:/etc/apcupsd
      - ./log/apcupsd.events:/var/log/apcupsd.events
      - ./log/apcupsd.trace:/apcupsd.trace
    ports:
      - "0.0.0.0:3559:3551"

  exporter:
    image: iodeveloper/prom-apcupsd-exporter:latest
    restart: always
    ports:
      - "0.0.0.0:3560:8001"
    command: [
      "--logLevel", "warn",
      "--apcupsd", "apcupsd:3551",
      "--apcupsdStartSkip", "20",
      "--collectInterval", "10",
      "--defaultModelState", '{"OutputPowerNominal": 900, "OutputPowerApparentNominal": 1500}'
    ]
./conf/apcupsd.conf
UPSCABLE smart 
UPSTYPE apcsmart
DEVICE /dev/ttyS0
POLLTIME 3

ONBATTERYDELAY 0
BATTERYLEVEL 0
MINUTES 0
TIMEOUT 0
KILLDELAY 0

NETSERVER on
NISPORT 3551

# other by default
./conf/apccontrol:
# ...
export SYSADMIN=root
export APCUPSD_MAIL="mail"
if [ -f $SCRIPTDIR/config ]; then . $SCRIPTDIR/config ; fi

# signaling the exporter
curl -X POST "http://exporter:8001/signal/$1"

# ...
./conf/doshutdown:
#!/bin/sh

touch /etc/apcupsd/shuttingdown
exit 99
./conf/mainsback:
#!/bin/sh

# Kill and reload apcupsd to reset `shutdown` status flags after mains back
if [ -f /etc/apcupsd/shuttingdown ]; then
    rm -f /etc/apcupsd/shuttingdown
    pid=$(ps aux | grep '/sbin/apcupsd' | grep -v grep | awk '{print $2}')
    kill $pid
fi

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL