Coder Social home page Coder Social logo

jnovack / nut-to-mqtt Goto Github PK

View Code? Open in Web Editor NEW
7.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.

nut-to-mqtt's People

Contributors

jnovack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lukicsl

nut-to-mqtt's Issues

Security error on [email protected]

Hello,

jeo ~/d/nut-to-mqtt master* λ go mod download
go: github.com/jnovack/[email protected]: verifying go.mod: checksum mismatch
	downloaded: h1:s8DZ+9C9fQ7sK2KO8KDvuAIJgX+nzHGfXxgZyV/aGrY=
	sum.golang.org: h1:+wCtyeQ6/Ttm8Ih/g+48icj4NyFTvKqCC3v61ZV1CLs=

SECURITY ERROR
This download does NOT match the one reported by the checksum server.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.

For more information, see 'go help module-auth'.

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.