Joe Gervasio
2019-Jun-08 18:08 UTC
[Nut-upsuser] How to shutdown macOS / mac OSX from Network UPS Tools client - NUT
Hi, I’ve posted my question on Superuser.com but not had any replies in 2 weeks, so I guess no-one there knows anything about NUT. https://superuser.com/questions/1441153/how-to-shutdown-macos-mac-osx-from-network-ups-tools-client-nut <https://superuser.com/questions/1441153/how-to-shutdown-macos-mac-osx-from-network-ups-tools-client-nut> I’m looking for help in shutting down my iMac on detecting a power failure while running from a UPS. My setup is an APC SMT750i UPS, powering two Synology NASs, an iMac, plus the network kit (router, switch etc.). This is all fine. (Synology runs a variant of Linux plus NUT). I have installed NUT (v 2.6.5) on the iMac (High Sierra 10.13.6) using MacPorts. One NAS is connected directly to the UPS via USB and acts as the ‘master’ in the NUT network, the other NAS and the iMac are ‘slaves’. On power failure, the master detects the state of the UPS and broadcasts it to the slaves, which both receive it OK. The NASs both go into ‘safe mode’ correctly as they are configured to do. The iMac receives the state change OK and repeatedly alerts the logged in user, but does NOT in fact shut down, as I want and believe I have configured it to do. I have followed all the advice I can find online, especially at: https://networkupstools.org/ <https://networkupstools.org/> https://superuser.com/questions/1228972/how-to-automatically-launch-nut-client-at-boot-on-macos <https://superuser.com/questions/1228972/how-to-automatically-launch-nut-client-at-boot-on-macos> https://diktiosolutions.eu/en/synology/synology-ups-nut-en/ <https://diktiosolutions.eu/en/synology/synology-ups-nut-en/> What am I doing wrong? Mac NUT config files: etc/upsmon.conf RUN_AS_USER root MONITOR ups at xxx.xxx.xxx.xxx 1 monuser ****** slave MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -u -h +1" NOTIFYCMD /opt/local/sbin/upssched POLLFREQ 5 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 15 POWERDOWNFLAG /etc/killpower NOTIFYFLAG ONLINE EXEC+SYSLOG+WALL NOTIFYFLAG ONBATT EXEC+SYSLOG+WALL NOTIFYFLAG LOWBATT EXEC+SYSLOG+WALL NOTIFYFLAG FSD EXEC+SYSLOG+WALL NOTIFYFLAG COMMOK EXEC+SYSLOG NOTIFYFLAG COMMBAD EXEC+SYSLOG NOTIFYFLAG SHUTDOWN EXEC+SYSLOG+WALL NOTIFYFLAG REPLBATT EXEC+SYSLOG+WALL NOTIFYFLAG NOCOMM EXEC+SYSLOG+WALL NOTIFYFLAG NOPARENT EXEC+SYSLOG+WALL RBWARNTIME 43200 NOCOMMWARNTIME 300 FINALDELAY 5 etc/upssched.conf CMDSCRIPT /opt/local/bin/upssched-cmd PIPEFN /opt/local/var/db/ups/upssched/upssched.pipe LOCKFN /opt/local/var/db/ups/upssched/upssched.lock AT ONBATT ups at xxx.xxx.xxx.xxx EXECUTE on-battery AT ONLINE ups at xxx.xxx.xxx.xxx EXECUTE ups-back-on-line AT COMMBAD ups at xxx.xxx.xxx.xxx START-TIMER upsgone 75 AT COMMOK ups at xxx.xxx.xxx.xxx CANCEL-TIMER upsgone bin/upssched-cmd #! /bin/sh case $1 in upsgone) logger -t upssched-cmd "Lost communication with UPS" /usr/bin/osascript -e 'tell app (path to frontmost application as text) to display dialog "Lost contact with UPS server" buttons {"OK"} default button 1 with icon note' ;; on-battery) logger -t upssched-cmd "UPS is running on battery" /usr/bin/osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" buttons {"OK"} default button 1' ;; ups-back-on-line) logger -t upssched-cmd "UPS is running on utility power" /usr/bin/osascript -e 'tell app (path to frontmost application as text) to display dialog "Power restored to UPS" giving up after 600 buttons {"OK"} default button 1 with icon note' ;; *) logger -t upssched-cmd "Unrecognized command: $1" /usr/bin/osascript -e "tell app (path to frontmost application as text) to display dialog \"upssched-cmd: unsupported command $1\" buttons {\"OK\"} default button 1 with icon caution" ;; esac iMac$ sudo /opt/local/sbin/upsmon -DDD Network UPS Tools upsmon 2.6.5-Unversioned directory kill: No such process 0.000000 UPS: ups at xxx.xxx.xxx.xxx (slave) (power value 1) 0.000319 Using power down flag file /etc/killpower 0.000603 debug level is '3' 0.004081 Trying to connect to UPS [ups at 192.168.86.242] 0.006152 Logged into UPS ups at xxx.xxx.xxx.xxx 0.006166 pollups: ups at xxx.xxx.xxx.xxx 0.006189 get_var: ups at xxx.xxx.xxx.xxx / status 0.006566 parse_status: [OL] 0.006590 parsing: [OL] 0.006596 ups_on_line: ups at xxx.xxx.xxx.xxx (first time) 0.006603 Current power value: 1 0.006608 Minimum power value: 1 5.007706 pollups: ups at xxx.xxx.xxx.xxx 5.007759 get_var: ups at xxx.xxx.xxx.xxx / status 5.008277 parse_status: [OL] 5.008296 parsing: [OL] 5.008305 Current power value: 1 5.008310 Minimum power value: 1 : : There’s nothing NUT/UPS related in the /var/logs AFAICS Thanks for any help or advice ~Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20190608/c3164fb7/attachment.html>
Roger Price
2019-Jun-08 20:16 UTC
[Nut-upsuser] How to shutdown macOS / mac OSX from Network UPS Tools client - NUT
On Sat, 8 Jun 2019, Joe Gervasio wrote:> ETC/UPSMON.CONF > > NOTIFYFLAG LOWBATT EXEC+SYSLOG+WALL > > ETC/UPSSCHED.CONF > > CMDSCRIPT /opt/local/bin/upssched-cmd > PIPEFN /opt/local/var/db/ups/upssched/upssched.pipe > LOCKFN /opt/local/var/db/ups/upssched/upssched.lock > AT ONBATT ups at xxx.xxx.xxx.xxx EXECUTE on-battery > AT ONLINE ups at xxx.xxx.xxx.xxx EXECUTE ups-back-on-line > AT COMMBAD ups at xxx.xxx.xxx.xxx START-TIMER upsgone 75 > AT COMMOK ups at xxx.xxx.xxx.xxx CANCEL-TIMER upsgoneIs your System Shutdown Plan to shut down using upsmon or using the script upsched-cmd? In upssched.conf you do not have a line AT LOWBATT ups at ... EXECUTE lowbatt and in upssched-cmd there is nothing to shut down the system. Have you tried typing the command "/sbin/shutdown -u -h +1" directly? Does this perform a shutdown? Roger
Charles Lepple
2019-Jun-08 20:22 UTC
[Nut-upsuser] How to shutdown macOS / mac OSX from Network UPS Tools client - NUT
On Jun 8, 2019, at 4:16 PM, Roger Price wrote:> > Is your System Shutdown Plan to shut down using upsmon or using the script upsched-cmd? In upssched.conf you do not have a line > > AT LOWBATT ups at ... EXECUTE lowbatt > > and in upssched-cmd there is nothing to shut down the system.Joe, Roger has a good point - the SHUTDOWNCMD should work as long as the master system waits for the "OB LB" state, and doesn't shut down early (say, at 30% battery remaining, but the UPS waits for 20% before declaring LB). I have never used a Synology box, but I vaguely remember them not using the NUT LB state. (That might have been covered in one of your links, but I haven't had a chance to look through all of them.) -- - Charles Lepple https://ghz.cc/charles/
Possibly Parallel Threads
- How to shutdown macOS / mac OSX from Network UPS Tools client - NUT
- Fopen upsmon.pid - no such file or directory - Nut 2.8.0 built from source
- Shutdown when both (all) UPS on battery / low battery
- FW: Setup of upssched on opensuse 11 - examined pipefn ad lockfm
- Timer doesn't appear to start