Giter VIP home page Giter VIP logo

nut-upsd's Introduction

Network UPS Tools server

Docker Cloud Build Status GitHub issues Docker Image Size (amd64) Docker Pulls Docker Stars

This image provides a complete UPS monitoring service (USB driver only).
This is a fork of sudo-bot/nut-upsd.
I added a lot of additional configuration options and implemented email notifications.
I use Debian instead of Alpine as base image to allow shutdown of the host machine using systemctl.

Usage

You can mount your own /etc/nut/ups.conf, /etc/nut/upsd.conf, /etc/nut/upsd.users and /etc/nut/upsmon.conf.
If not provided externally by bind mount, the configuration files are generated automatically using the following environment variables.

General configuration

  • UPS_NAME - Name of the UPS (default: ups)

  • UPS_DESCRIPTION - Short description of the UPS (default: UPS)

  • UPS_DRIVER - The driver to use for the UPS (default: usbhid-ups)

  • UPS_PORT - The serial port where the UPS is connected (default: auto)

  • LOWBATT_PERCENT - Override the percentage which is reported as low battery (and triggers SHUTDOWNCMD)

  • LOWBATT_RUNTIME - Override the remaining runtime (in seconds) which is considered low (and triggers SHUTDOWNCMD)

  • API_ADDRESS - The address used by upsd (default: 0.0.0.0)

  • API_PORT - The port used by upsd (default: 3493)

  • API_USER - The username for upsd (default: upsmon)

  • API_PASSWORD - The username for upsd (default: random)

  • ADMIN_PASSWORD - The username for the upsd admin user (default: random)

upsmon.conf

You can set any directive from uspmon.conf as an environment variable (Documentation) e.g. POLLFREQ or SHUTDOWNCMD.

Host shutdown on low battery

If your host machine uses systemd (most distributions), you can shutdown the host from within the container using systemctl.
In this case, you have to mount /run/systemd from the host to the container and set e.g. SHUTDOWNCMD="systemctl poweroff".
In some cases, you need to mount /run/dbus, too.

Email notifications

You have to configure at least these options to enable email notifications:

  • NOTIFICATION_EMAIL - Notification emails are sent to this email adress.

  • NOTIFICATION_FROM - Email address from which the emails are sent

  • NOTIFICATION_FROM_NAME - The display name of the email sender (default: $UPS_DESCRIPTION)

By default, you get notifications for all upsmon events.
You can disable emails for a certain event type by setting the environment variable NOTIFY_<type> to 0, e.g. NOTIFY_LOWBATT=0 (types under 'NOTIFYMSG' in Documentation).

The file /etc/nut/email_messages.json contains the subjects and messages of the notification emails.
You can provide your own messages by mounting your own file.

You have to set your smtp server by either providing /etc/msmtprc or using the following environment variables:

  • SMTP_HOST - Hostname of the SMTP server

  • SMTP_PORT - Port of the SMTP server (default: 587)

  • SMTP_AUTH - Enable/disable user authentication (on/off, default: on)

  • SMTP_USER - Username/email for authentication (default: $NOTIFICATION_FROM)

  • SMTP_PASSWORD - Password for authentication

  • SMTP_TLS - Enable/disable TLS (on/off, default: on)

  • SMTP_STARTTLS - Enable/disable STARTTLS (on/off, default: on)

  • SMTP_CERTCHECK - Enable/disable certificate verification (on/off, default: on)

Docker Run

A sample docker run command could look like this:

docker run -d \
    --name nut-upsd \
    --device /dev/bus/usb/xxx/yyy
    -p 3493:3493 \
    -e UPS_DESCRIPTION="My UPS" \
    -e POLLFREQ=10 \
    -e NOTIFY_NOCOMM=0 \
    -e NOTIFICATION_EMAIL="[email protected]" \
    -e NOTIFICATION_FROM="[email protected]" \
    -e SMTP_HOST="smtp.example.com" \
    -e SMTP_PASSWORD="xxxx" \
    schmailzl/nut-upsd

Docker Compose

A sample docker-compose.yml could look like this:

version: '3'
services:
  nut:
    image: schmailzl/nut-upsd
    devices:
      - "/dev/bus/usb/xxx/yyy"
    ports:
      - "3493:3493"
    environment:
      UPS_DESCRIPTION: "My UPS"
      POLLFREQ: 10
      NOTIFY_NOCOMM: 0
      NOTIFICATION_EMAIL: [email protected]
      NOTIFICATION_FROM: [email protected]
      SMTP_HOST: smtp.example.com
      SMTP_PASSWORD: xxxx

nut-upsd's People

Contributors

m-schmailzl avatar williamdes avatar

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.