[Nut-upsuser] Apple Mac slave

Robbie van der Walle rvanderwalle at gmail.com
Sun Jun 11 11:27:55 UTC 2017


> If notify-send is available on the Mac, then perhaps this will work:

It is not installed. 

> In upsmon.conf on the Mac you need
> 
> NOTIFYCMD /usr/sbin/upssched        (or wherever this goes on a Mac)
> NOTIFYFLAG ONBATT SYSLOG+EXEC

Mac  /sw/etc/nut/upsmon.conf, I have FINK installed on Mac. http://www.finkproject.org

NOTIFYCMD /sw/sbin/upssched
NOTIFYFLAG ONBATT SYSLOG+EXEC

Mac /sw/etc/nut/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 ups@<ip address> EXECUTE on-battery

Mac /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


This is working and showing a box with an ok button which disappears after a while. With the same command osascript it should be possible to send an message to a mobile phone. 

Thanks ! 


Kind Regards,

Rob



> On 10 Jun 2017, at 10:02, Roger Price <roger at rogerprice.org> wrote:
> 
> On Fri, 9 Jun 2017, Robbie van der Walle wrote:
> 
>> ... and also still open is the notification on the Mac.
> 
> If notify-send is available on the Mac, then perhaps this will work:
> 
> In upsmon.conf on the Mac you need
> 
> NOTIFYCMD /usr/sbin/upssched        (or wherever this goes on a Mac)
> NOTIFYFLAG ONBATT SYSLOG+EXEC
> 
> In upssched.conf you need
> 
> CMDSCRIPT /usr/sbin/upssched-cmd    (or wherever this goes on a Mac)
> AT ONBATT UPS at NAS EXECUTE on-battery
> 
> In upssched-cmd you need
> 
> case $1 in
>   (on-battery) MSG="Power failure. Save your work!"
>                notify-send -a nut -u critical -t 600000 $MSG ;;
>   (*) logger -i -t upssched-cmd "Unrecognized command: \"$1\"." ;;
> esac
> 
> Roger
> 
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3583 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20170611/82c8f638/attachment-0001.bin>


More information about the Nut-upsuser mailing list