Coder Social home page Coder Social logo

jnovack / nut-to-mqtt Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 27 KB

Network UPS Tools to MQTT exporter.

License: MIT License

Dockerfile 8.84% Makefile 4.17% Go 53.38% Shell 33.62%
nut network-ups-tools mqtt-client upsmon golang-application docker-container

nut-to-mqtt's Introduction

nut-to-mqtt

nut-to-mqtt is a transmogrifier for exporting data from Network UPS Tools (nut), and streaming to an MQTT broker.

Quick Start

$ nut-to-mqtt \
    -nut_hostname=192.168.9.10 -nut_username=monitor -nut_password=hunter2 \
    -mqtt_hostname=172.23.4.5 -mqtt_username=user24601 -mqtt_password=hunter2

Features

Currently tracks the following metrics from NUT:

  • battery.charge - Battery charge (percent of full)
  • battery.runtime - Battery runtime (seconds)
  • battery.voltage - Battery voltage (V)
  • input.voltage - Input voltage (V)
  • ups.load - Load on UPS (percent of full)
  • ups.status - UPS status

And publishes them to the MQTT broker under the following topic:

  • v1/ups/UPSNAME/METRIC

Currently, there are some conversions to published data.

  • battery.runtime - Read as seconds, published as minutes (with 1 decimal place)
  • ups.status - Read as two-char code, published as full word

Example:

  • battery.runtime is read as 2725 (seconds) and published to MQTT as 45.4 (minutes)
  • ups.status is read as OL (code) and published to MQTT as Online (text).

Docker Secret Support

nut_password and mqtt_password permit a _FILE suffix (for nut_password_file and mqtt_password_file) to not expose password via environment variables.

You must point to a file called nut_password or mqtt_password which should contain the password only.

Example:

$ nut-to-mqtt \
    -nut_hostname=192.168.9.10 -nut_username=monitor \
    -nut_password_file=/run/secrets/nut_password \
    -mqtt_hostname=172.23.4.5 -mqtt_username=user24601 \
    -mqtt_password_file=/run/secrets/mqtt_password

Caveats

If connecting multiple nut-to-mqtt transmogrifiers to a single broker, each UPS should have a different name within their ups.conf. UPSes are identified by their name only, and not by their host.

Having a UPS called myups on two different hosts will result in metrics being overwritten.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.