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 [email protected] 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  [email protected] EXECUTE      on-battery
AT ONLINE  [email protected] EXECUTE      ups-back-on-line
AT COMMBAD [email protected] START-TIMER  upsgone 75
AT COMMOK  [email protected] 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: [email protected] (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 [[email protected]]
   0.006152     Logged into UPS [email protected] 
   0.006166     pollups: [email protected] 
   0.006189     get_var: [email protected]  / status
   0.006566     parse_status: [OL]
   0.006590     parsing: [OL]
   0.006596     ups_on_line: [email protected]  (first time)
   0.006603     Current power value: 1
   0.006608     Minimum power value: 1
   5.007706     pollups: [email protected] 
   5.007759     get_var: [email protected]  / 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



_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to