[Nut-upsuser] How to shutdown macOS / mac OSX from Network UPS Tools client - NUT

Roger Price roger at rogerprice.org
Sun Jun 9 21:19:32 BST 2019


On Sun, 9 Jun 2019, Joe Gervasio wrote:

> This question undermines my reading of the documentation.  I had thought that 
> these were separate things: 
> 
>     SHUTDOWNCMD "/sbin/shutdown -u -h +1" 
>     NOTIFYCMD /opt/local/sbin/upssched
> 
> I had assumed that the SHUTDOWNCMD would be used by the Nut client (upsmon) to 
> shutdown the slave system,  and that the NOTIFYCMD would be responsible for 
> notifying users of what is going on.  
> 
> But I am now inferring from your question, that use of the NOTIFYCMD 
> supersedes or overrides the functionality of the former.  Is that correct?  So 
> if I use a NOTIFYCMD, then I should implement the actual shutdown logic as 
> well as the notification logic in that script, forgetting about SHUTDOWNCMD?

Using upssched and a upssched-cmd script to shut down the system is an 
alternative to using the builtin upsmon SHUTDOWNCMD on status [OB LB]. A 
upssched-cmd script can provide a managed shutdown well before [OB LB] is 
reached, but should the UPS reach that status upsmon's SHUTDOWNCMD will take 
over and enforce an emergency shutdown.

I live in an area with a lot of lightning and frequent power failures, so I have 
to be able to perform several managed shutdowns before [LB] is reached.  I do 
this with upssched-cmd. Other sysadmins do not have this problem, and prefer 
something simpler, so they rely solely on builtin upsmon SHUTDOWNCMD.

Your current setup in which upsmon performs the "emergency shutdown" on status 
[OB LB], and upssched + upssched-cmd are used merely to provide useful warnings 
is ok, but you should be clear that this is what you want to do.

> Is there some way I can test my setup without having to deplete and recharge 
> my UPS every iteration?

How about temporarily setting the battery.charge.low to some very high value:

  upsrw -s battery.charge.low=90 -u <user> -p sekret my-UPS

I suggest adding something like the following lines to the top of upssched-cmd 
so that you can include the value of $CHMSG in all your messages.

  STATUS=$( upsc $UPS ups.status )
  CHARGE=$( upsc $UPS battery.charge )
  CHMSG="[$STATUS]:$CHARGE%"

This will give you a clearer idea of what is happening to the UPS unit.

Roger


More information about the Nut-upsuser mailing list