User Tools

Site Tools


Sidebar

ups

Setup NUT (Network UPS Tools)

http://www.bernaerts-nicolas.fr/linux/75-debian/335-debian-wheezy-install-monitor-eaton-ups

sudo apt-get install nut nut-monitor

To get vendorid and productid if you have more than one UPS:

lsusb  

Lookup UPS from dmesg to find driver to use https://networkupstools.org/stable-hcl.html

sudo vim /etc/nut/ups.conf 

[eaton]
driver = usbhid-ups
port = auto
desc = "Eaton E5 1100"
vendorid = 0463
productid = ffff

sudo upsdrvctl start
sudo vim /etc/nut/nut.conf

MODE=standalone

sudo vim /etc/nut/upsd.conf

# LISTEN <address> [<port>]
LISTEN 127.0.0.1 3493
LISTEN ::1 3493

sudo systemctl restart nut-server.service 
sudo systemctl status nut-server.service 
sudo systemctl enable nut-server.service 
upsc eaton

upsmon configuration

The last step is to configure upsmon to listen to upsd and take action on events.

vim /etc/nut/upsmon.conf

MONITOR upsname@localhost 1 upsduser password master

Create a notify send script file of sorts

vim ./send_simple.py 

#!/usr/bin/python3.7
import telegram
import sys
TOKEN = 'mytokenhere1234567890987654321'
user_id = '01234567890'
msg = sys.argv[1]
bot = telegram.Bot(token=TOKEN_vissie_bot)
bot.send_message(chat_id=user_id, text=msg)

sudo vim /etc/nut/upsmon.conf 

 
RUN_AS_USER root
MONITOR apc-1500@localhost 1 admin xxxx master
MINSUPPLIES 1
NOTIFYCMD /usr/sbin/send.py
POLLFREQ 2
POLLFREQALERT 1
NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL+EXEC

sudo systemctl status nut-monitor.service 
sudo systemctl start nut-monitor.service 
sudo systemctl enable nut-monitor.service 
ups.txt · Last modified: 2022/05/16 23:26 by vissie