Posted by joli in Linux, Slackware
- Install sbopkg https://sbopkg.org/
- Create user nut and group nut
- Use sbopkg to download/build/install system/nut
- Check device info for your connected UPS:
root@pn41:/etc/nut# lsusb
.
.
Bus 001 Device 006: ID 0463:ffff MGE UPS Systems UPS
.
- Edit /etc/nut/ups.conf and add your device:
[myups]
driver = usbhid-ups
port = auto
vendorid = 0463
pollfreq = 30
- Add an user to /etc/nut/upsd.users:
[user]
password = password
upsmon master
actions = SET
instcmds = ALL
# To be used by monitoring client
[client]
password = password2
upsmon slave
- Edit and configure /etc/nut/upsmon.conf.sample and save as upsmon.conf:
MONITOR myups@localhost 1 user password master
NOTIFYCMD /etc/nut/sendupsmsg
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
- Edit /etc/nut/nut.conf (to allow other clients to connect):
MODE=netserver
- Edit /etc/upsd.conf and specify which NIC that should be used for outside connections:
LISTEN 192.168.1.9 3493
LISTEN 127.0.0.1 3493
- Edit script (/etc/nut/sendupsmsg) that will be called if NOTIFYFLAG with flag EXEC kicks in:
#!/bin/bash
echo $(date): "$*" >> /var/log/ups.log
# Replace with your own script for alert.
sendupsemail "$*"
- Set correct file permissions:
chown root:nut /etc/nut/* /var/log/ups.log
chmod 650 /etc/nut/* /var/log/ups.log
chmod +x /etc/rc.d/rc.ups
chmod 750 /etc/nut/sendupsmsg
- Add rc.ups to /etc/rc.d/rc.local:
if [ -x /etc/rc.d/rc.ups ]; then
/etc/rc.d/rc.ups start
fi
- Add shutdown cmd to /etc/rc.d/rc.local_shutdown:
if [ -f /etc/killpower ]; then
# Stop ups service:
echo "Stopping ups stuff: upsdrvctl shutdown"
upsdrvctl shutdown
fi
- Start the services:
/etc/rc.d/rc.usp start
- Check if it works:
upsc myups
- Pull the plug and check syslog and that the notify script is called