Synology UPS NUT
Synology UPS NUT
Synology UPS NUT (network UPS Tools), door aan een Synology NAS een UPS te koppelen wordt voorkomen dat er dataverlies optreedt of hardware stuk gaat bij een stroomstoring. Daarnaast kunnen ook andere apparaten een seintje krijgen om uitgezet te worden bij een stroomstoring. Synology has implemented NUT: http://networkupstools.org
De gebruikte configuratie voor Synology UPS NUT:
Synology NAS connected via Dataport to APC Back-UPS ES 700.
The configuration files on the Synology NAS are found here:
/usr/syno/etc/ups, which you can access via a terminal
upsd.conf
upsd.users
ups.conf
After changing the file you can reload the configuration:
upsd -c reload
Settings via the Synology GUI
GUI, control panel, Hardware & Power, General
restart automatically after a power failure
GUI, control panel, Hardware & Power,UPS
Select Enable Network UPS Server, Permitted Disk Station Devices.
Select the devices who are allowed to connect.
To get UPS status information from another device and user:
you have to be in the upsd.users file and be in the list of permitted disk station devices, (control panel, Hardware & Power, UPS)
run the following command to check UPS information and status from another device:
upsc <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>
for example upsc ups@192.168.1.10
To change a value for example for testing:
upsrw -s battery.charge.low=<new value> -u <user, defined in upsd.conf NAS> -p <password user in upsd.conf> <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>
To install a nut client on a Mac:
I used Fink Project; http://www.finkproject.org to install Fink Project.
To install nut on your Mac:
fink install nut
The configuration files:
/sw/etc/nut
upsmon.conf:
RUN_AS_USER root
MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -u -h +0"
NOTIFYCMD /sw/sbin/upssched
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
upssched.conf
CMDSCRIPT /sw/bin/upssched-cmd
PIPEFN /sw/var/run/ups/upssched/upssched.pipe
LOCKFN /sw/var/run/ups/upssched/upssched.lock
AT ONBATT <name ups, see synology ups.conf>@<ip address> EXECUTE on-battery
/sw/bin/upssched-cmd:
case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;
on-battery)
osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" giving up after 20 buttons {"OK"} default button 1 with icon caution'
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
To start upsmon manually:
sudo upsmon -D (/sw/sbin/upsmon)
-D Raise the debugging level. upsmon will run in the foreground and
prints information on stdout about the monitoring process. Use this
multiple times for more details.
upsmon -c stop ( stop monitoring and exit)
upsmon -c reload ( reread upsmon.conf)
To start upsmon automatically on a macOS Sierra :
/Library/LaunchDaemons
-rw-r--r-- 1 root wheel org.networkupstools.upsmon.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.networkupstools.upsmon</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sw/sbin/upsmon</string>
<string>-D</string> <!-- "-D" keeps upsmon from going into the background -->
</array>
<key>KeepAlive</key>
<true/>
<key>SuccessfulExit</key>
<false/> <!-- Do not respawn at shutdown time -->
</dict>
</plist>
To load manually:
sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist
system.log:
com.apple.xpc.launchd[1] (org.networkupstools.upsmon): Unknown key for Boolean: SuccessfulExit
com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This service is defined to be constantly running and is inherently inefficient.
To see if it is running:
sudo launchctl list|fgrep -v com.app
PID Status Label
…
<PID> 0 org.networkupstools.upsmon
ps -ef |grep upsmon
0 88 1 0 9:52AM 0:00.01 /sw/sbin/upsmon -D
0 167 88 0 9:52AM 0:00.50 /sw/sbin/upsmon -D
To install a nut client on Linux CentOS 6.9 :
Download the binary package of Feodora EPEL6, nut-client
Install on Linux machine with rpm command:
for example: rpm -ivh nut-client-2.6.5-2.el6.x86_64.rpm
make a user nutmon and at to group nut:
adduser nutmon
passwd nutmon
usermod -a -G nut nutmon
groups nut
Config files:
/etc/ups/
check nut group read rights upsmon.conf
upsmon.conf:
RUN_AS_USER nutmon
MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
To run upsmon at startup:
chkconfig --list ups
chkconfig ups on
to check upsmon running:
service ups status
ps -ef |grep upsmon:
root 2271 1 0 Jul08 ? 00:00:00 /usr/sbin/upsmon
nutmon 2273 2271 0 Jul08 ? 00:00:09 /usr/sbin/upsmon
To start en stop upsmon:
service ups start
service ups stop
The nut client on Ubuntu 20.04 :
Check permission on Synology NAS to connect to network UPS server
Synology GUI, control panel, Hardware & Power,UPS
Select Enable Network UPS Server, Permitted Disk Station Devices.
Select the devices which are allowed to connect.
On Linux computer via the terminal.
- Sudo apt install nut-client
- Check permission on Synology NAS to connect to network UPS server
sudo upsc <user>@<synology server>
for example upsc ups@192.168.1.10
- sudo adduser nutmon
- sudo usermod -a -G nut nutmon
- cd /etc/nut
- sudo vi upsmon.conf:
RUN_AS_USER nutmon
MONITOR <name UPS>@<synology nas server> 1 <user> <password> slave
"slave" means this system shuts down immediately when power goes critical.
<powervalue> is an integer - the number of power supplies that this UPS
# feeds on this system. Most computers only have one power supply, so this
# is normally set to 1. You need a pretty big or special box to have any
# other value here.
For example:
MONITOR ups@192.168.1.10 1 monuser password slave
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
- sudo vi nut.conf
MODE=netclient
- sudo systemctl enable nut-client
- sudo systemctl start nut-client
- sudo systemctl status nut-client
Heeft u hulp nodig. Klik hier voor contact met Diktio Solutions.