Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Charles Lepple
On Jun 15, 2017, at 4:09 PM, Robbie van der Walle  
wrote:
> What is the purpose of Boolean:  SuccessfulExit?
> 
All I remember is the comment on the next line: 

 I did have to fiddle with permissions of config files - Fink currently 
 builds NUT to run as user "nobody", so I have the following non-default 
 permissions:
 
 $ ls -l /sw/etc/nut
 ...
 -rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
 -rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf
> 
> /sw/etc/nut
> 
> -rw-r--r--   1 root  admin  12199 Jun 10 16:22 upsmon.conf
> 
> This are default permissions. 

Well, technically the Fink package doesn't install the *.conf files, just the 
*.conf.sample versions.
> 
> I# For best results, you should create a new normal user like "nutmon",
> # and make it a member of a "nut" group or similar.  Then specify it
> # here and grant read access to the upsmon.conf for that group.
> #
> # This user should not have write access to upsmon.conf.
> #
> # RUN_AS_USER nutmon
> 
> RUN_AS_USER root
> 
> For security reasons you should change root to another user? 
> 
> which other rights are needed for this user to make it work? 

Not a lot - upsmon keeps a copy around that runs as root (in order to execute 
the shutdown command), but it parses the files and network traffic under the 
lesser RUN_AS_USER privileges. So the Fink default of "nobody" could work, if 
you change the group of the configuration file as well. I don't know if many 
other processes in OS X use "nobody".

See http://networkupstools.org/docs/man/upsmon.html#_reloading_nuances and 
http://networkupstools.org/docs/man/upsmon.conf.html
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Robbie van der Walle
Ok rebooted 

All running ok now. Great thanks a lot!  

In system.log 

Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): 
Unknown key for Boolean: SuccessfulExit
Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This 
service is defined to be constantly running and is inherently inefficient.

What is the purpose of Boolean:  SuccessfulExit?


>>> I did have to fiddle with permissions of config files - Fink currently 
>>> builds NUT to run as user "nobody", so I have the following non-default 
>>> permissions:
>>> 
>>> $ ls -l /sw/etc/nut
>>> ...
>>> -rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
>>> -rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf

/sw/etc/nut

-rw-r--r--   1 root  admin  12199 Jun 10 16:22 upsmon.conf

This are default permissions. 

I# For best results, you should create a new normal user like "nutmon",
# and make it a member of a "nut" group or similar.  Then specify it
# here and grant read access to the upsmon.conf for that group.
#
# This user should not have write access to upsmon.conf.
#
# RUN_AS_USER nutmon

RUN_AS_USER root

For security reasons you should change root to another user? 

which other rights are needed for this user to make it work? 

Kind Regards,

Rob



> On 15 Jun 2017, at 21:48, Robbie van der Walle  wrote:
> 
> Ok did it again from scratch. 
> 
> I used the same plist file. 
> 
> sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist
> 
> Doesn’t return an error: 
> 
> 
> system.log:
> 
> Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): 
> Unknown key for Boolean: SuccessfulExit
> Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): 
> This service is defined to be constantly running and is inherently 
> inefficient.
> 
> sudo launchctl list|fgrep -v com.app
> 
> PID Status  Label
> …
> 1266  0   org.networkupstools.upsmon
> 
> ps -ef |grep upsmon
>0  1266 1   0  9:38PM ?? 0:00.01 /sw/sbin/upsmon -D
>0  1267  1266   0  9:38PM ?? 0:00.02 /sw/sbin/upsmon -D
> 
> Let try to reboot my Mac and check. 
> 
> Kind Regards,
> 
> Rob
> 
> 
> 
>> On 15 Jun 2017, at 16:51, Robbie van der Walle  
>> wrote:
>> 
>> I deleted the plist file and rebooted:
>> 
>> sudo /sw/sbin/upsmon -D
>> Network UPS Tools upsmon 2.7.4
>>   0.00   fopen /sw/var/run/upsmon.pid: No such file or directory
>>   0.044649   UPS: ups@ip address (slave) (power value 1)
>>   0.081597   Using power down flag file /etc/killpower
>>   0.162720   debug level is '1'
>>   0.538410   Trying to connect to UPS [ups@ip address]
>>   0.540345   Logged into UPS ups@ip address
>> 
>> fopen /sw/var/run/upsmon.pid: No such file or directory
>> 
>> This is strange because the file exits. 
>> 
>> Let me check why this is happening. It would explain why the pid is not 
>> running. 
>> 
>> Kind Regards,
>> 
>> Rob
>> 
>> 
>> 
>>> On 15 Jun 2017, at 16:38, Charles Lepple  wrote:
>>> 
>>> On Jun 15, 2017, at 10:31 AM, Robbie van der Walle  
>>> wrote:
 
 Did you change anything in the plist or used mine ?
 
>>> 
>>> Copied and pasted from yours.
>>> 
>>> If you run "sudo /sw/sbin/upsmon -D" from the command line, does it exit 
>>> immediately?
>>> 
>>> I did have to fiddle with permissions of config files - Fink currently 
>>> builds NUT to run as user "nobody", so I have the following non-default 
>>> permissions:
>>> 
>>> $ ls -l /sw/etc/nut
>>> ...
>>> -rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
>>> -rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf
>>> 
>>> ___
>>> Nut-upsuser mailing list
>>> Nut-upsuser@lists.alioth.debian.org
>>> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser
>> 
> 



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Robbie van der Walle
Ok did it again from scratch. 

I used the same plist file. 

sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist

Doesn’t return an error: 


system.log:

Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): 
Unknown key for Boolean: SuccessfulExit
Jun 15 21:38:54 c01 com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This 
service is defined to be constantly running and is inherently inefficient.
 
sudo launchctl list|fgrep -v com.app

PID Status  Label
…
12660   org.networkupstools.upsmon

ps -ef |grep upsmon
0  1266 1   0  9:38PM ?? 0:00.01 /sw/sbin/upsmon -D
0  1267  1266   0  9:38PM ?? 0:00.02 /sw/sbin/upsmon -D

Let try to reboot my Mac and check. 

Kind Regards,

Rob



> On 15 Jun 2017, at 16:51, Robbie van der Walle  wrote:
> 
> I deleted the plist file and rebooted:
> 
> sudo /sw/sbin/upsmon -D
> Network UPS Tools upsmon 2.7.4
>0.00   fopen /sw/var/run/upsmon.pid: No such file or directory
>0.044649   UPS: ups@ip address (slave) (power value 1)
>0.081597   Using power down flag file /etc/killpower
>0.162720   debug level is '1'
>0.538410   Trying to connect to UPS [ups@ip address]
>0.540345   Logged into UPS ups@ip address
> 
> fopen /sw/var/run/upsmon.pid: No such file or directory
> 
> This is strange because the file exits. 
> 
> Let me check why this is happening. It would explain why the pid is not 
> running. 
> 
> Kind Regards,
> 
> Rob
> 
> 
> 
>> On 15 Jun 2017, at 16:38, Charles Lepple  wrote:
>> 
>> On Jun 15, 2017, at 10:31 AM, Robbie van der Walle  
>> wrote:
>>> 
>>> Did you change anything in the plist or used mine ?
>>> 
>> 
>> Copied and pasted from yours.
>> 
>> If you run "sudo /sw/sbin/upsmon -D" from the command line, does it exit 
>> immediately?
>> 
>> I did have to fiddle with permissions of config files - Fink currently 
>> builds NUT to run as user "nobody", so I have the following non-default 
>> permissions:
>> 
>> $ ls -l /sw/etc/nut
>> ...
>> -rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
>> -rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf
>> 
>> ___
>> Nut-upsuser mailing list
>> Nut-upsuser@lists.alioth.debian.org
>> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser
> 



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Robbie van der Walle
I deleted the plist file and rebooted:

sudo /sw/sbin/upsmon -D
Network UPS Tools upsmon 2.7.4
   0.00 fopen /sw/var/run/upsmon.pid: No such file or directory
   0.044649 UPS: ups@ip address (slave) (power value 1)
   0.081597 Using power down flag file /etc/killpower
   0.162720 debug level is '1'
   0.538410 Trying to connect to UPS [ups@ip address]
   0.540345 Logged into UPS ups@ip address

fopen /sw/var/run/upsmon.pid: No such file or directory

This is strange because the file exits. 

Let me check why this is happening. It would explain why the pid is not 
running. 

Kind Regards,

Rob



> On 15 Jun 2017, at 16:38, Charles Lepple  wrote:
> 
> On Jun 15, 2017, at 10:31 AM, Robbie van der Walle  > wrote:
>> 
>> Did you change anything in the plist or used mine ?
>> 
> 
> Copied and pasted from yours.
> 
> If you run "sudo /sw/sbin/upsmon -D" from the command line, does it exit 
> immediately?
> 
> I did have to fiddle with permissions of config files - Fink currently builds 
> NUT to run as user "nobody", so I have the following non-default permissions:
> 
> $ ls -l /sw/etc/nut
> ...
> -rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
> -rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf
> 
> ___
> Nut-upsuser mailing list
> Nut-upsuser@lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Charles Lepple
On Jun 15, 2017, at 10:31 AM, Robbie van der Walle  
wrote:
> 
> Did you change anything in the plist or used mine ?
> 

Copied and pasted from yours.

If you run "sudo /sw/sbin/upsmon -D" from the command line, does it exit 
immediately?

I did have to fiddle with permissions of config files - Fink currently builds 
NUT to run as user "nobody", so I have the following non-default permissions:

$ ls -l /sw/etc/nut
...
-rw-r-+ 1 root  nobody   2177 Jun 15 08:42 upsd.users
-rw-r-+ 1 root  nobody  15455 Jun 15 08:50 upsmon.conf

___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-15 Thread Charles Lepple
On Jun 14, 2017, at 1:54 PM, Robbie van der Walle  
wrote:
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd 
> ">
> 
> 
> Label
> org.networkupstools.upsmon
> RunAtLoad
> 
> ProgramArguments
> 
> /sw/sbin/upsmon
> -D 
> 
> KeepAlive
> 
> SuccessfulExit
>  
> 
> 
> 
> 
> sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist
> 
> Doesn’t return an error. But when I check of upsmon is running I don’t see it 
> running. 

This works for me on 10.12.5. (There is a warning that SuccessfulExit is an 
"unknown key" from launchd.)

$ sudo launchctl list|fgrep -v com.app
PID Status  Label
...
89810   org.networkupstools.upsmon
...

Does anything for upsmon show up in system.log in Console.app?___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-14 Thread Charles Lepple
On Jun 14, 2017, at 9:12 AM, Robbie van der Walle  
wrote:
> 
> But I cannot load it with the command: 
> 
> $ sudo launchctl load /Library/LaunchAgents/com.networkupstools.upsmon.plist
> 
> /Library/LaunchAgents/com.networkupstools.upsmon.plist: Invalid property list
> 

I will try to look into this later, but three quick things:

1) does the base filename need to match the Label key? com.network... vs 
org.network...

2) maybe it doesn't like the comments (between "")?

3) should only need to go in /Library/LaunchDaemons  (LaunchAgents is to make 
it run at login, rather than system startup.)___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-14 Thread Robbie van der Walle
> To be honest, I haven't experimented much with this, but I saw a normal 
> shutdown/reboot when I just tried this from the command line (10.12):
> 
> reboot~ Mon Jun 12 08:36 
> shutdown  ~ Mon Jun 12 08:35 
> clepple   ttys007   Sun Jun  4 21:52 - shutdown (7+10:43)

> However, the "-u" flag did not seem to keep the Mac running for long after 
> the shutdown (certainly seemed shorter than five minutes).

I have the same result showing a shutdown and reboot running manually. 
Also the shutdown was shorter than five minutes. 


> I also have to find a solution for starting up upsmon when the Mac starts

I never finished the integration for this branch, but...

https://github.com/networkupstools/nut/compare/osx_launchd 


You can save off the Raw file, and replace @SBINDIR@ with /sw/sbin or whatever:

https://github.com/networkupstools/nut/blob/161efce6c6fc32f205817ca71f8963af253cec59/scripts/launchd/org.networkupstools.upsmon.plist.in
 



I have made a file com.networkupstools.upsmon.plist. in /Library/LaunchDaemons 
and /Library/LauchAgents 

-rw-r--r--   1 root  wheel   708 Jun 14 14:59 com.networkupstools.upsmon.plist

But I cannot load it with the command: 

$ sudo launchctl load /Library/LaunchAgents/com.networkupstools.upsmon.plist

/Library/LaunchAgents/com.networkupstools.upsmon.plist: Invalid property list


com.networkupstools.upsmon.plist:


http://www.apple.com/DTDs/PropertyList-1.0.dtd;>



Label
org.networkupstools.upsmon
ProgramArguments

/sw/sbin/upsmon
-D 

RunAtLoad

KeepAlive

SuccessfulExit
 





Kind Regards,

Rob



> On 12 Jun 2017, at 14:42, Charles Lepple  wrote:
> 
> On Jun 11, 2017, at 7:15 AM, Robbie van der Walle  
> wrote:
>> 
>> I see only a reboot. Not a shutdown.  But is this normal because shutdown -u 
>> -h +0 is used? 
>> 
> To be honest, I haven't experimented much with this, but I saw a normal 
> shutdown/reboot when I just tried this from the command line (10.12):
> 
> reboot~ Mon Jun 12 08:36 
> shutdown  ~ Mon Jun 12 08:35 
> clepple   ttys007   Sun Jun  4 21:52 - shutdown (7+10:43)
> 
> However, the "-u" flag did not seem to keep the Mac running for long after 
> the shutdown (certainly seemed shorter than five minutes).
> 
> Maybe I can test this on another machine with the full NUT stack later.
> 
> Thanks for posting the osascript example - that looks useful!
> ___
> Nut-upsuser mailing list
> Nut-upsuser@lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-12 Thread Charles Lepple
On Jun 11, 2017, at 7:15 AM, Robbie van der Walle  
wrote:
> 
> I see only a reboot. Not a shutdown.  But is this normal because shutdown -u 
> -h +0 is used? 
> 
To be honest, I haven't experimented much with this, but I saw a normal 
shutdown/reboot when I just tried this from the command line (10.12):

reboot~ Mon Jun 12 08:36 
shutdown  ~ Mon Jun 12 08:35 
clepple   ttys007   Sun Jun  4 21:52 - shutdown (7+10:43)

However, the "-u" flag did not seem to keep the Mac running for long after the 
shutdown (certainly seemed shorter than five minutes).

Maybe I can test this on another machine with the full NUT stack later.

Thanks for posting the osascript example - that looks useful!
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-11 Thread Robbie van der Walle
> 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@ 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  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@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 60 $MSG ;;
>   (*) logger -i -t upssched-cmd "Unrecognized command: \"$1\"." ;;
> esac
> 
> Roger
> 
> ___
> Nut-upsuser mailing list
> Nut-upsuser@lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-11 Thread Robbie van der Walle
>> What I wonder if the shutdown is done proper. Does the shutdown command use 
>> umount to prevent disk corruption?
> 
> Yes, it prevents filesystem corruption, but I am not sure if it bothers to 
> save the desktop state.
> 
> You can check the "last" logs to see if it was cleanly shut down:
> 
> $ last shutdown reboot
> reboot~ Sun May 21 19:04 
> shutdown  ~ Sun May 21 19:03 
> ...
> 
> If you see a "reboot" without a corresponding "shutdown" before it, the 
> system did not shut down properly.


reboot~ Sun Jun 11 12:40 
   ttys002   Sun Jun 11 12:21 - crash  (00:18)
ttys001   Sun Jun 11 12:21 - crash  (00:18)
ttys000   Sun Jun 11 12:21 - crash  (00:18)



I see only a reboot. Not a shutdown.  But is this normal because shutdown -u -h 
+0 is used? 


>> I also have to find a solution for starting up upsmon when the Mac starts
> 
> I never finished the integration for this branch, but...
> 
> https://github.com/networkupstools/nut/compare/osx_launchd
> 
> You can save off the Raw file, and replace @SBINDIR@ with /sw/sbin or 
> whatever:
> 
> https://github.com/networkupstools/nut/blob/161efce6c6fc32f205817ca71f8963af253cec59/scripts/launchd/org.networkupstools.upsmon.plist.in
>  
> 


I will look in to it. 

> 
>> and also still open is the notification on the Mac. 
> 
> I used to have a script that would send UDP notifications to Growl, but that 
> was before OS X notifications made Growl mostly obsolete. I can dig that up 
> if it is of interest.


No thanks, I can use osascript to notify. 



Kind Regards,

Rob




smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-10 Thread Roger Price

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@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 60 $MSG ;;
   (*) logger -i -t upssched-cmd "Unrecognized command: \"$1\"." ;;
esac

Roger

___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Robbie van der Walle
> Alternatively, on 10.12 and 10.11, there is a "-u" option to shutdown:
> 
> -u  The system is halted up until the point of removing system power, 
> but waits before removing power for 5 minutes so that an external UPS 
> (uninterruptible power supply) can forcibly remove power.  This simulates a 
> dirty shutdown to permit a later automatic power on. OS X uses this mode 
> automatically with supported UPSs in emergency shutdowns.
> 
> Let us know what works. (I have NUT set up on a Mac Mini, but we do not get 
> frequent power outages, and the machine is set to wake up on a schedule 
> anyway.)


SHUTDOWNCMD "/sbin/shutdown -u -h +0” in upsmon.conf on the Mac did the trick. 
Thanks! 

After power is restored, the Mac starts. 

What I wonder if the shutdown is done proper. Does the shutdown command use 
umount to prevent disk corruption?

I also have to find a solution for starting up upsmon when the Mac starts and 
also still open is the notification on the Mac. 

But thanks so much all for the steps so far. 


Kind Regards,

Rob



> On 9 Jun 2017, at 14:42, Charles Lepple  wrote:
> 
> On Jun 9, 2017, at 4:47 AM, Robbie van der Walle  
> wrote:
>> 
>>> Under System Preferences, Energy Saver, there is a setting Start up 
>>> automatically after a power failure. 
>>> Running sudo pmset  -a autorestart 1 does the same trick. 
>> 
>> But unfortunately Mac stays . Step 7 
>> 
> 
> You might want to save off the output of "pmset -g" before experimenting 
> further - that way, after you find a solution, you can run it again to see 
> what changed.
> 
> This page implies that the "sudo" and "-a" are not needed:
> 
>   
> http://www.virtuallyghetto.com/2013/02/enable-auto-startup-after-power-failure.html
> 
> Also potentially useful, though I can't imagine it is changing different 
> settings under the hood:
> 
>   
> https://macminicolo.net/blog/files/Be-sure-your-Mac-mini-will-restart-automatically-when-needed.html
> 
> Alternatively, on 10.12 and 10.11, there is a "-u" option to shutdown:
> 
> -u  The system is halted up until the point of removing system power, 
> but waits before removing power for 5 minutes so that an external UPS 
> (uninterruptible power supply) can forcibly remove power.  This simulates a 
> dirty shutdown to permit a later automatic power on. OS X uses this mode 
> automatically with supported UPSs in emergency shutdowns.
> 
> Let us know what works. (I have NUT set up on a Mac Mini, but we do not get 
> frequent power outages, and the machine is set to wake up on a schedule 
> anyway.)



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Charles Lepple
On Jun 9, 2017, at 4:47 AM, Robbie van der Walle  wrote:
> 
>> Under System Preferences, Energy Saver, there is a setting Start up 
>> automatically after a power failure. 
>> Running sudo pmset  -a autorestart 1 does the same trick. 
> 
> But unfortunately Mac stays . Step 7 
> 

You might want to save off the output of "pmset -g" before experimenting 
further - that way, after you find a solution, you can run it again to see what 
changed.

This page implies that the "sudo" and "-a" are not needed:

   
http://www.virtuallyghetto.com/2013/02/enable-auto-startup-after-power-failure.html

Also potentially useful, though I can't imagine it is changing different 
settings under the hood:

   
https://macminicolo.net/blog/files/Be-sure-your-Mac-mini-will-restart-automatically-when-needed.html

Alternatively, on 10.12 and 10.11, there is a "-u" option to shutdown:

 -u  The system is halted up until the point of removing system power, 
but waits before removing power for 5 minutes so that an external UPS 
(uninterruptible power supply) can forcibly remove power.  This simulates a 
dirty shutdown to permit a later automatic power on. OS X uses this mode 
automatically with supported UPSs in emergency shutdowns.

Let us know what works. (I have NUT set up on a Mac Mini, but we do not get 
frequent power outages, and the machine is set to wake up on a schedule anyway.)
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Robbie van der Walle
>> After the first test and the NAS is restarted I had to change the setting 
>> battery.charge.low again to 80 
> 
> Does the NAS DSM reset battery.charge.low to 10 or is it internal to the UPS? 
>  You will have to experiment by disconnecting the UPS control lead from the 
> NAS and connecting it (if possible) to the Mac.  After setting to 80 and a 
> power off-on cycle is the value 80 or 10?

Ok I will have try this.  I am also searching on the NAS if it set somehow. 

>> 3. Users from the NAS are warned, not yet the Mac user.  Only when executing 
>> automatic power-fail shutdown. 
> 
> In upsmon.conf on the Mac, what are the values of NOTIFYMSG ONBATT and 
> NOTIFYFLAG ONBATT?  Does program wall work on the Mac? It fails on a lot of 
> Linux boxes with graphical interfaces - to get a message to the user, you 
> have to use notify-send, which means setting up upssched.

# NOTIFYMSG - change messages sent by upsmon when certain events occur
#
# You can change the default messages to something else if you like.
#
# NOTIFYMSG  "message"
#
# NOTIFYMSG ONLINE  "UPS %s on line power"
# NOTIFYMSG ONBATT  "UPS %s on battery"
# NOTIFYMSG LOWBATT "UPS %s battery is low"
# NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
# NOTIFYMSG COMMOK  "Communications with UPS %s established"
# NOTIFYMSG COMMBAD "Communications with UPS %s lost"
# NOTIFYMSG SHUTDOWN"Auto logout and shutdown proceeding"
# NOTIFYMSG REPLBATT"UPS %s battery needs to be replaced"
# NOTIFYMSG NOCOMM  "UPS %s is unavailable"
# NOTIFYMSG NOPARENT"upsmon parent process died - shutdown impossible"
#
# Note that %s is replaced with the identifier of the UPS in question.
#
# Possible values for :
#
# ONLINE   : UPS is back online
# ONBATT   : UPS is on battery
# LOWBATT  : UPS has a low battery (if also on battery, it's "critical")
# FSD  : UPS is being shutdown by the master (FSD = "Forced Shutdown")
# COMMOK   : Communications established with the UPS
# COMMBAD  : Communications lost to the UPS
# SHUTDOWN : The system is being shutdown
# REPLBATT : The UPS battery is bad and needs to be replaced
# NOCOMM   : A UPS is unavailable (can't be contacted for monitoring)
# NOPARENT : The process that shuts down the system has died (shutdown 
impossible)

# --
# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur
#
# By default, upsmon sends walls (global messages to all logged in users)
# and writes to the syslog when things happen.  You can change this.
#
# NOTIFYFLAG  [+][+] ...
#
# NOTIFYFLAG ONLINE SYSLOG+WALL
# NOTIFYFLAG ONBATT SYSLOG+WALL
# NOTIFYFLAG LOWBATTSYSLOG+WALL
# NOTIFYFLAG FSDSYSLOG+WALL
# NOTIFYFLAG COMMOK SYSLOG+WALL
# NOTIFYFLAG COMMBADSYSLOG+WALL
# NOTIFYFLAG SHUTDOWN   SYSLOG+WALL
# NOTIFYFLAG REPLBATT   SYSLOG+WALL
# NOTIFYFLAG NOCOMM SYSLOG+WALL
# NOTIFYFLAG NOPARENT   SYSLOG+WALL
#
# Possible values for the flags:
#
# SYSLOG - Write the message in the syslog 
# WALL   - Write the message to all users on the system
# EXEC   - Execute NOTIFYCMD (see above) with the message
# IGNORE - Don't do anything
#
# If you use IGNORE, don't use any other flags on the same line.

NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE 
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG


> Does program wall work on the Mac?

file testwall:

hallo 

tried: wall testwall and result:

Broadcast Message from
(/dev/ttys002) at 11:28 CEST...
   
hallo 


So wall work in a terminal only. 

> It fails on a lot of Linux boxes with graphical interfaces - to get a message 
> to the user, you have to use notify-send, which means setting up upssched.

# NOTIFYCMD 
#
# upsmon calls this to send messages when things happen
#
# This command is called with the full text of the message as one argument.
# The environment string NOTIFYTYPE will contain the type string of
# whatever caused this event to happen.
#
# Note that this is only called for NOTIFY events that have EXEC set with
# NOTIFYFLAG.  See NOTIFYFLAG below for more details.
#
# Making this some sort of shell script might not be a bad idea.  For more
# information and ideas, see pager.txt in the docs directory.
#
# Example:
# NOTIFYCMD /usr/local/ups/bin/notifyme

NOTIFYCMD /sw/sbin/upssched



Results second test 1 after changing on NAS, Control Panel Hardware & Power, 
Power recovery, Restart automatically after a power failure. And changing on 
the Mac, system preferences, energy saver, start up automatically after a power 
failure. 


1 Pull power cord

2 Ups beeps NAS and Mac work

3 NAS users warned. Mac not

4 low bat, first slave Mac 

Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Robbie van der Walle
>> After the first test and the NAS is restarted I had to change the setting 
>> battery.charge.low again to 80 
> 
> Does the NAS DSM reset battery.charge.low to 10 or is it internal to the UPS? 
>  You will have to experiment by disconnecting the UPS control lead from the 
> NAS and connecting it (if possible) to the Mac.  After setting to 80 and a 
> power off-on cycle is the value 80 or 10?

Ok I will have try this.  I am also searching on the NAS if it set somehow. 

>> 3. Users from the NAS are warned, not yet the Mac user.  Only when executing 
>> automatic power-fail shutdown. 
> 
> In upsmon.conf on the Mac, what are the values of NOTIFYMSG ONBATT and 
> NOTIFYFLAG ONBATT?  Does program wall work on the Mac? It fails on a lot of 
> Linux boxes with graphical interfaces - to get a message to the user, you 
> have to use notify-send, which means setting up upssched.



#NOTIFYMSG ONBAT 

NOTIFYFLAG ONBATT EXEC



> Does program wall work on the Mac?

file testwall:

hallo 

tried: wall testwall and result:

Broadcast Message from
(/dev/ttys002) at 11:28 CEST...
   
hallo 


So wall work in a terminal only. 

> It fails on a lot of Linux boxes with graphical interfaces - to get a message 
> to the user, you have to use notify-send, which means setting up upssched.

# NOTIFYCMD 

NOTIFYCMD /sw/sbin/upssched



Results second test 1 after changing on NAS, Control Panel Hardware & Power, 
Power recovery, Restart automatically after a power failure. And changing on 
the Mac, system preferences, energy saver, start up automatically after a power 
failure. 


1 Pull power cord

2 Ups beeps NAS and Mac work

3 NAS users warned. Mac not

4 low bat, first slave Mac shutdown.  Than Master NAS shutdown. ( report in log 
NAS, server is on battery, server going to safe shutdown) 

5 UPS shutdown after 29 seconds. 

6 reconnect power 

7 NAS now starts up but Mac doesn’t 





Kind Regards,

Rob




smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Roger Price

On Fri, 9 Jun 2017, Robbie van der Walle wrote:


# NOTIFYMSG - change messages sent by upsmon when certain events occur
#
# You can change the default messages to something else if you like.
#
# NOTIFYMSG  "message"
#
# NOTIFYMSG ONLINE "UPS %s on line power"
# NOTIFYMSG ONBATT "UPS %s on battery"
# NOTIFYMSG LOWBATT "UPS %s battery is low"
# NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
# NOTIFYMSG COMMOK "Communications with UPS %s established"
# NOTIFYMSG COMMBAD "Communications with UPS %s lost"
# NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
# NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
# NOTIFYMSG NOCOMM "UPS %s is unavailable"
# NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
#


Lots more lines of comments.
Please remove comments and blank lines before posting in mailing lists. 
I gave up reading.

Roger

___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Robbie van der Walle
>> After the first test and the NAS is restarted I had to change the setting 
>> battery.charge.low again to 80 
> 
> Does the NAS DSM reset battery.charge.low to 10 or is it internal to the UPS? 
>  You will have to experiment by disconnecting the UPS control lead from the 
> NAS and connecting it (if possible) to the Mac.  After setting to 80 and a 
> power off-on cycle is the value 80 or 10?

Ok I will have try this.  I am also searching on the NAS if it set somehow. 

>> 3. Users from the NAS are warned, not yet the Mac user.  Only when executing 
>> automatic power-fail shutdown. 
> 
> In upsmon.conf on the Mac, what are the values of NOTIFYMSG ONBATT and 
> NOTIFYFLAG ONBATT?  Does program wall work on the Mac? It fails on a lot of 
> Linux boxes with graphical interfaces - to get a message to the user, you 
> have to use notify-send, which means setting up upssched.


# NOTIFYMSG ONLINE  "UPS %s on line power"
# NOTIFYMSG ONBATT  "UPS %s on battery"
# NOTIFYMSG LOWBATT "UPS %s battery is low"
# NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
# NOTIFYMSG COMMOK  "Communications with UPS %s established"
# NOTIFYMSG COMMBAD "Communications with UPS %s lost"
# NOTIFYMSG SHUTDOWN"Auto logout and shutdown proceeding"
# NOTIFYMSG REPLBATT"UPS %s battery needs to be replaced"
# NOTIFYMSG NOCOMM  "UPS %s is unavailable"
# NOTIFYMSG NOPARENT"upsmon parent process died - shutdown impossible"



NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE 
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG


> Does program wall work on the Mac?

file testwall:

hallo 

tried: wall testwall and result:

Broadcast Message from
(/dev/ttys002) at 11:28 CEST...
   
hallo 


So wall work in a terminal only. 

> It fails on a lot of Linux boxes with graphical interfaces - to get a message 
> to the user, you have to use notify-send, which means setting up upssched.

# NOTIFYCMD 
#
# upsmon calls this to send messages when things happen
#
# This command is called with the full text of the message as one argument.
# The environment string NOTIFYTYPE will contain the type string of
# whatever caused this event to happen.
#
# Note that this is only called for NOTIFY events that have EXEC set with
# NOTIFYFLAG.  See NOTIFYFLAG below for more details.
#
# Making this some sort of shell script might not be a bad idea.  For more
# information and ideas, see pager.txt in the docs directory.
#
# Example:
# NOTIFYCMD /usr/local/ups/bin/notifyme

NOTIFYCMD /sw/sbin/upssched



Results second test 1 after changing on NAS, Control Panel Hardware & Power, 
Power recovery, Restart automatically after a power failure. And changing on 
the Mac, system preferences, energy saver, start up automatically after a power 
failure. 


1 Pull power cord

2 Ups beeps NAS and Mac work

3 NAS users warned. Mac not

4 low bat, first slave Mac shutdown.  Than Master NAS shutdown. ( report in log 
NAS, server is on battery, server going to safe shutdown) 

5 UPS shutdown after 29 seconds. 

6 reconnect power 

7 NAS now starts up but Mac doesn’t 





Kind Regards,

Rob


smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Robbie van der Walle
>> 7. No they didn’t restart. I know there is a setting on the NAS to activate 
>> this. I will check and try again. 
> 
> Not sure for the NAS, but for the Mac, it is probably something like this:
> 
>   sudo pmset -a autorestart 1
> 
> There is also usually a checkbox in the Energy Saver panel in the System 
> Preferences GUI.


Under System Preferences, Energy Saver, there is a setting Start up 
automatically after a power failure. 
Running sudo pmset  -a autorestart 1 does the same trick. 

But unfortunately Mac stays . Step 7 

I will try again. 

Kind Regards,

Rob





smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-09 Thread Roger Price

On Thu, 8 Jun 2017, Robbie van der Walle wrote:

After the first test and the NAS is restarted I had to change the 
setting battery.charge.low again to 80 


Does the NAS DSM reset battery.charge.low to 10 or is it internal to the 
UPS?  You will have to experiment by disconnecting the UPS control lead 
from the NAS and connecting it (if possible) to the Mac.  After setting to 
80 and a power off-on cycle is the value 80 or 10?


3. Users from the NAS are warned, not yet the Mac user.  Only when 
executing automatic power-fail shutdown. 


In upsmon.conf on the Mac, what are the values of NOTIFYMSG ONBATT and 
NOTIFYFLAG ONBATT?  Does program wall work on the Mac? It fails on a lot 
of Linux boxes with graphical interfaces - to get a message to the user, 
you have to use notify-send, which means setting up upssched.


7. No they didn’t restart. I know there is a setting on the NAS to 
activate this. I will check and try again. 


Does the NAS have a BIOS option "Power on when AC resumes"?

Roger
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Charles Lepple
On Jun 8, 2017, at 4:06 PM, Robbie van der Walle  wrote:
> 
> 7. No they didn’t restart. I know there is a setting on the NAS to activate 
> this. I will check and try again. 

Not sure for the NAS, but for the Mac, it is probably something like this:

   sudo pmset -a autorestart 1

There is also usually a checkbox in the Energy Saver panel in the System 
Preferences GUI.
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Robbie van der Walle
> When you carry out tests to ensure that the setup is working well, you will 
> pull the power cord from the wall and wait until the UPS reaches LB. This 
> means waiting and wasting time.  You can speed up the testing by setting LB 
> very high so that the UPS reaches it quickly.  Later you can set a more 
> reasonable value.

After the first test and the NAS is restarted I had to change the setting 
battery.charge.low again to 80 

> On most UPS units, there is a light which goes out.  Some produce an audible 
> clunk as the relays disconnect the UPS power outlets. You could also connect 
> a light bulb to a protected outlet.  It should go out when the UPS shuts down.

The APC produced an audible clunk. So the UPS was shutdown. I am not sure it 
was after 20 seconds. I have to clock that. 

> Example test:
> 
> 1. Pull power cord from wall
> 
> 2. UPS beeps, NAS and Mac continue operation
> 
> 3. Users are warned that power has failed
> 
> 4. When the battery drops to battery.charge.low the slave (Mac) and then the 
> master (NAS) shutdown.
> 
> 5. After 20 seconds the UPS shuts down.
> 
> 6. Reconnect the wall power
> 
> 7. NAS and Mac should restart


Result test 1 

1. Pull power cord from wall. — OK

2. UPS beeps, NAS and Mac continue operation

3. Users from the NAS are warned, not yet the Mac user.  Only when executing 
automatic power-fail shutdown. 

4. Yes, Both the Mac and NAS shutdown. Only the Mac shutdown so fast that it 
looks like pressing the off button. The NAS I have to check if it was in 
safe-mode some how. 

5. The UPS shuts down. I heard an audible clunk. 

6. Reconnect the wall power — OK

7. No they didn’t restart. I know there is a setting on the NAS to activate 
this. I will check and try again. 


This is what is reported from the terminal on the Mac:

-
Broadcast Message from @   
   
(/dev/ttys001) at 21:30 CEST...
   
Executing automatic power-fail shutdown  
———

and 

———

sudo upsmon -D

Network UPS Tools upsmon 2.7.4
kill: No such process
   0.00 UPS: ups@  (slave) (power value 1)
   0.000718 Using power down flag file /etc/killpower
   0.001192 debug level is '1'
   0.008274 Trying to connect to UPS [ups@]
   0.009866 Logged into UPS ups@
 290.089253 Critical UPS: ups@
 290.089313 Shutting down any UPSes in MASTER mode...
 290.089322 Executing automatic power-fail shutdown
   
Broadcast Message from @   
   
(/dev/ttys001) at 21:30 CEST...
   
Executing automatic power-fail shutdown  


Kind regards,

Rob 




smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Roger Price

On Thu, 8 Jun 2017, Robbie van der Walle wrote:


  The "upsrw" command contacts upsd, so it sounds like you should be able 
to add a user to upsd.users on the NAS, and then run something like
  this on the Mac:

    upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS@synology

  Per http://networkupstools.org/docs/man/upsd.users.html , the "upsmaster" user 
would need at least "actions = SET". You will need to reload
  upsd after changing upsd.users.

I managed to do this, upsc reports: 

battery.charge.low: 80 instead of 10 
What is the purpose of changing this value?


When you carry out tests to ensure that the setup is working well, you 
will pull the power cord from the wall and wait until the UPS reaches LB. 
This means waiting and wasting time.  You can speed up the testing by 
setting LB very high so that the UPS reaches it quickly.  Later you can 
set a more reasonable value.



  If the UPS is not turning itself off after the NAS goes into safe mode, 
it might be possible to do this from the Mac. You probably have
  something like this in the Mac's upsmon.conf:

    SHUTDOWNCMD "/sbin/shutdown -h +0"

  You could add an UPS shutdown command before the Mac shutdown command:

    upscmd -u upsmaster -s sekret UPS@synology shutdown.stayoff

  but you would need to be sure that the UPS shutdown delay is long enough 
to allow the NAS to go into safe mode. (This is why it is
  recommended that the master (the NAS in your case) initiate the UPS 
shutdown.) Also, you would need to configure that NUT user to allow
  instant commands in upsd.users as well as upsrw access.

I have SHUTDOWNCMD "/sbin/shutdown -h +0” now on the Mac is was SHUTDOWNCMD “” 
before.



How do I check if the UPS is turning itself off after the NAS goes into safe 
mode? 


On most UPS units, there is a light which goes out.  Some produce an 
audible clunk as the relays disconnect the UPS power outlets. You could 
also connect a light bulb to a protected outlet.  It should go out when 
the UPS shuts down.


Example test:

1. Pull power cord from wall

2. UPS beeps, NAS and Mac continue operation

3. Users are warned that power has failed

4. When the battery drops to battery.charge.low the slave (Mac) and then 
the master (NAS) shutdown.


5. After 20 seconds the UPS shuts down.

6. Reconnect the wall power

7. NAS and Mac should restart

You will also need a test in which you wait a long time before step 6, 
and a test in which you reconnect power between steps 4 and 5.


Roger___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Mark Hansen

On 6/8/2017 7:44 AM, Robbie van der Walle wrote:

The "upsrw" command contacts upsd, so it sounds like you should be able to add 
a user to upsd.users on the NAS, and then run something like this on the Mac:

  upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS@synology

Per http://networkupstools.org/docs/man/upsd.users.html 
 , the "upsmaster" user would need 
at least "actions = SET". You will need to reload upsd after changing upsd.users.




I managed to do this, upsc reports:

battery.charge.low: 80 instead of 10

What is the purpose of changing this value?


Once the UPS loses line power (and goes on the battery) it will wait for a 
configurable amount of
time before it will attempt to shut down the hosts computers. Normally, this is 
when the battery
charge gets down to a low level, identified by the battery.charge.low setting. 
When it is set to
10, that means NUT won't attempt to shut down the hosts until the battery gets 
down to 10% charge.

This can take a while, and can make testing difficult.

If you change this value to 80, then it will happen a lot sooner (when the 
battery gets down to
an 80% charge).

After you're all done with your testing and your configuration is working the 
way you want, you'll
want to come back to this and set it back to a reasonable value, like 10.

  




If the UPS is not turning itself off after the NAS goes into safe mode, it 
might be possible to do this from the Mac. You probably have something like 
this in the Mac's upsmon.conf:

  SHUTDOWNCMD "/sbin/shutdown -h +0"

You could add an UPS shutdown command before the Mac shutdown command:

  upscmd -u upsmaster -s sekret UPS@synology shutdown.stayoff

but you would need to be sure that the UPS shutdown delay is long enough to 
allow the NAS to go into safe mode. (This is why it is recommended that the 
master (the NAS in your case) initiate the UPS shutdown.) Also, you would need 
to configure that NUT user to allow instant commands in upsd.users as well as 
upsrw access.




I have SHUTDOWNCMD "/sbin/shutdown -h +0” now on the Mac is was SHUTDOWNCMD “” 
before.


How do I check if the UPS is turning itself off after the NAS goes into safe 
mode?


By this, they mean when the UPS cuts the power to its "switched" outlets - 
these are the outlets
into which your host computers should be connected for power.

One easy way to tell when this happens is to just plug a lamp into one of the 
switched outlets
(most UPS models have 3 or 4 switched outlets - make sure you're using these). 
Then when the
lamp goes off, you know the UPS has cut power to the switched outlets.







Kind regards,

Rob





___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser




___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Robbie van der Walle
> The "upsrw" command contacts upsd, so it sounds like you should be able to 
> add a user to upsd.users on the NAS, and then run something like this on the 
> Mac:
> 
>   upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS@synology
> 
> Per http://networkupstools.org/docs/man/upsd.users.html 
>  , the "upsmaster" user 
> would need at least "actions = SET". You will need to reload upsd after 
> changing upsd.users.



I managed to do this, upsc reports: 

battery.charge.low: 80 instead of 10 

What is the purpose of changing this value?
 


> If the UPS is not turning itself off after the NAS goes into safe mode, it 
> might be possible to do this from the Mac. You probably have something like 
> this in the Mac's upsmon.conf:
> 
>   SHUTDOWNCMD "/sbin/shutdown -h +0"
> 
> You could add an UPS shutdown command before the Mac shutdown command:
> 
>   upscmd -u upsmaster -s sekret UPS@synology shutdown.stayoff
> 
> but you would need to be sure that the UPS shutdown delay is long enough to 
> allow the NAS to go into safe mode. (This is why it is recommended that the 
> master (the NAS in your case) initiate the UPS shutdown.) Also, you would 
> need to configure that NUT user to allow instant commands in upsd.users as 
> well as upsrw access.



I have SHUTDOWNCMD "/sbin/shutdown -h +0” now on the Mac is was SHUTDOWNCMD “” 
before.


How do I check if the UPS is turning itself off after the NAS goes into safe 
mode? 




Kind regards,

Rob 




smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Roger Price

On Thu, 8 Jun 2017, Robbie van der Walle wrote:


I suppose I have to use -u for user? Which user? and -p  for password? 


Sorry, my typo, it should be

   upsrw -s battery.charge.low=80 -u upsmaster -p sekret UPS@NAS

upsmaster is the "user" declared in the NAS file upsd.users in square 
brackets.  It has nothing to do with /etc/passwd.  sekret is the password 
also declared in NAS file upsd.users.  See man upsd.users and man upsrw.


Roger___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Robbie van der Walle
> Yes, See the User Manual http://networkupstools.org/docs/user-manual.pdf 
> chapter 6.3 "Configuring automatic shutdowns for low battery events”.



> The NUT documentation is not always clear, and it looks as if the Synology is 
> even less clear.  You must distinguish carefully between "system shutdown" 
> and "(delayed) UPS shutdown".  The UPS is turned off _after_ the system.  
> There is a delay between the moment the upsdrvctl shutdown command is given 
> and the moment the UPS shuts down.  The default is 20 seconds, but you may 
> have to increase this.

I have read 6.3. I don’t see the delayed shutdown here, more about low battery 
events 

What I notice in the upsmon.conf on the Mac which is the slave:

POWERDOWNFLAG /etc/killpower 

I don’t think this is necessary? 

When I start on the Mac : sudo upsmon -D 

I can see: 

sudo upsmon -D
Network UPS Tools upsmon 2.7.4
kill: No such process
   0.00 UPS: ups@ (slave) (power value 1)
   0.000791 Using power down flag file /etc/killpower
   0.001240 debug level is '1'
   0.013266 Trying to connect to UPS [ups@]
   0.014898 Logged into UPS ups@

There is also a message:

kill: no such process. what does it mean? 

Also I changed on the Mac, upsmon.conf :

SHUTDOWNCMD "/sbin/shutdown -h +0” which was before SHUTDOWNCMD ""

SHUTDOWNCMD “” Didn’t make sense to me. 

> You will need the utility programs upsrw and upscom which are part of NUT, 
> but they should be available in the Mac.

upsrw is available on the Mac:


upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS

I suppose I have to use -u for user? Which user? and -p  for password? 
What does -s sekret UPS means? -s means variable to be changed but I don’t know 
which variable this is, sekret. 


Kind regards,

Rob 









> On 8 Jun 2017, at 11:30, Roger Price  wrote:
> 
> On Wed, 7 Jun 2017, Robbie van der Walle wrote:
> 
>>  Out of curiosity, when you shut down the NAS, do you run the
>>  command "upsdrvctl shutdown" ?  Do you see or hear anything to
>>  suggest that the delayed UPS shutdown has happened?
>> I don’t know where to search to answer this. The delayed UPS shutdown means 
>> that Synology NAS will turn off the UPS after the delay? 
> 
> Yes, See the User Manual http://networkupstools.org/docs/user-manual.pdf 
> chapter 6.3 "Configuring automatic shutdowns for low battery events".
> 
>> ups.delay.shutdown Interval to wait after shutdown with delay command 
>> (seconds). 
>> Shutdown of what?  I don’t know what is means. 
> 
> The NUT documentation is not always clear, and it looks as if the Synology is 
> even less clear.  You must distinguish carefully between "system shutdown" 
> and "(delayed) UPS shutdown".  The UPS is turned off _after_ the system.  
> There is a delay between the moment the upsdrvctl shutdown command is given 
> and the moment the UPS shuts down.  The default is 20 seconds, but you may 
> have to increase this.
> 
>> The commando upsrw cannot be found on the Synology NAS? 
> 
> I understand from 
> https://tellini.info/2014/09/connecting-a-synology-diskstation-to-a-nut-server/
>  that the NUT configuration is hard coded into the NAS, and I suspect that 
> the configuration is more or less broken.
> 
> You will need the utility programs upsrw and upscom which are part of NUT, 
> but they should be available in the Mac.
> 
> Roger
> ___
> Nut-upsuser mailing list
> Nut-upsuser@lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Charles Lepple
On Jun 7, 2017, at 1:14 PM, Roger Price wrote:
> 
> 2. On the NAS, use command
> 
>   upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS

Robbie,

The "upsrw" command contacts upsd, so it sounds like you should be able to add 
a user to upsd.users on the NAS, and then run something like this on the Mac:

   upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS@synology

Per http://networkupstools.org/docs/man/upsd.users.html , the "upsmaster" user 
would need at least "actions = SET". You will need to reload upsd after 
changing upsd.users.

If the UPS is not turning itself off after the NAS goes into safe mode, it 
might be possible to do this from the Mac. You probably have something like 
this in the Mac's upsmon.conf:

   SHUTDOWNCMD "/sbin/shutdown -h +0"

You could add an UPS shutdown command before the Mac shutdown command:

   upscmd -u upsmaster -s sekret UPS@synology shutdown.stayoff

but you would need to be sure that the UPS shutdown delay is long enough to 
allow the NAS to go into safe mode. (This is why it is recommended that the 
master (the NAS in your case) initiate the UPS shutdown.) Also, you would need 
to configure that NUT user to allow instant commands in upsd.users as well as 
upsrw access.
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser


Re: [Nut-upsuser] Apple Mac slave

2017-06-08 Thread Roger Price

On Wed, 7 Jun 2017, Robbie van der Walle wrote:


  Out of curiosity, when you shut down the NAS, do you run the
  command "upsdrvctl shutdown" ?  Do you see or hear anything to
  suggest that the delayed UPS shutdown has happened?

I don’t know where to search to answer this. The delayed UPS shutdown 
means that Synology NAS will turn off the UPS after the delay? 


Yes, See the User Manual http://networkupstools.org/docs/user-manual.pdf 
chapter 6.3 "Configuring automatic shutdowns for low battery events".


ups.delay.shutdown Interval to wait after shutdown with delay command 
(seconds). 

Shutdown of what?  I don’t know what is means. 


The NUT documentation is not always clear, and it looks as if the Synology 
is even less clear.  You must distinguish carefully between "system 
shutdown" and "(delayed) UPS shutdown".  The UPS is turned off _after_ the 
system.  There is a delay between the moment the upsdrvctl shutdown 
command is given and the moment the UPS shuts down.  The default is 20 
seconds, but you may have to increase this.



The commando upsrw cannot be found on the Synology NAS? 


I understand from 
https://tellini.info/2014/09/connecting-a-synology-diskstation-to-a-nut-server/ 
that the NUT configuration is hard coded into the NAS, and I suspect that 
the configuration is more or less broken.


You will need the utility programs upsrw and upscom which are part of NUT, 
but they should be available in the Mac.


Roger
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-07 Thread Robbie van der Walle
> I see upsd and the first upsmon are running as "root".  They are often run as 
> user "nut" or "upsd”.

Apparently Synology has implemented it standard like this. 

Upsmon.conf on the Synology NAS:

RUN_AS_USER root

I suppose this needs to be changed from a security point of view. 


> I don't know the Synology NAS, but I guess that unless it is shutdown 
> completely, it will still draw power.  Will the safe-mode drain the UPS 
> completely, leading to a crash?

Good question and I don’t know the answer yet. 

This is what I can find about safe-mode means that all services are stopped and 
volumes (unmounted). So I quess it is not completely shut down and wil draw 
still power. 

I have to examine this.  


> Out of curiosity, when you shut down the NAS, do you run the command
> "upsdrvctl shutdown" ?  Do you see or hear anything to suggest that the 
> delayed UPS shutdown has happened?

I don’t know where to search to answer this. The delayed UPS shutdown means 
that Synology NAS will turn off the UPS after the delay? 


ups.delay.shutdown Interval to wait after shutdown with delay command 
(seconds). Shutdown of what?  I don’t know what is means. 


> Now for the Mac: You will need to have upsmon running on the Mac
> with a MONITOR declaration of the form
> 
>   MONITOR UPS@NAS 1   slave
> 
> Setting "slave" says that upsmon on the Mac is to shutdown the Mac as soon as 
> LB is detected in the NAS.

On the Mac I have in upsmon.conf 

MONITOR ups@ 1   slave

2. On the NAS, use command

  upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS

to set the low limit very high during testing.  This will speed up your 
testing.  You can reset it to something else later.

When I run this command:

upsc ups@localhost:



battery.charge.low: 10


The commando upsrw cannot be found on the Synology NAS? 





smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-07 Thread Roger Price

On Wed, 7 Jun 2017, Robbie van der Walle wrote:


I am running NUT on a Synology NAS with attached a USB APC UPS.
  Do you have upsd and upsmon running as daemons on the Synology DSM?
Yes I have them both running on the Synology DSM: 
root      7236     1  0 Jun01 ?        00:00:16 /usr/sbin/upsd
root      7741     1  0 Jun01 ?        00:00:00 /usr/sbin/upsmon
root      7744  7741  0 Jun01 ?        00:00:12 /usr/sbin/upsmon


I see upsd and the first upsmon are running as "root".  They are often run 
as user "nut" or "upsd".



  Does the NAS shut down (and restart) correctly when wall power fails?
Yes it does and also the other Synology Nas which is attached via the 
network. It brings the Synology NAS in a safe-mode. 


I don't know the Synology NAS, but I guess that unless it is shutdown 
completely, it will still draw power.  Will the safe-mode drain the UPS 
completely, leading to a crash?


Out of curiosity, when you shut down the NAS, do you run the command
"upsdrvctl shutdown" ?  Do you see or hear anything to suggest that the 
delayed UPS shutdown has happened?


  Is the Mac protected by the same APC UPS as the Synology NAS? Yes 
it is. The power cable of the Mac is connected to the APC UPS. The 
dataport of the APC UPS is connected via USB with the Synology NAS. 


Apart from these points, it looks as if NUT is running correctly on the 
Synology NAS.


Now for the Mac: You will need to have upsmon running on the Mac
with a MONITOR declaration of the form

   MONITOR UPS@NAS 1   slave

Setting "slave" says that upsmon on the Mac is to shutdown the Mac as soon 
as LB is detected in the NAS.


I suggest

 1. Shutting down on LB rather than on a timer since it's easier to set 
up.


 2. On the NAS, use command

   upsrw -s battery.charge.low=80 -u upsmaster -s sekret UPS

to set the low limit very high during testing.  This will speed up your 
testing.  You can reset it to something else later.


Roger___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-07 Thread Robbie van der Walle

>> I am running NUT on a Synology NAS with attached a USB APC UPS.
> 
> Do you have upsd and upsmon running as daemons on the Synology DSM?
> 

Yes I have them both running on the Synology DSM: 

root  7236 1  0 Jun01 ?00:00:16 /usr/sbin/upsd

root  7741 1  0 Jun01 ?00:00:00 /usr/sbin/upsmon
root  7744  7741  0 Jun01 ?00:00:12 /usr/sbin/upsmon

> Does the NAS shut down (and restart) correctly when wall power fails?

Yes it does and also the other Synology Nas which is attached via the network. 
It brings the Synology NAS in a safe-mode. 


> Is the Mac protected by the same APC UPS as the Synology NAS?

Yes it is. The power cable of the Mac is connected to the APC UPS. The dataport 
of the APC UPS is connected via USB with the Synology NAS. 

> Do you have upsd and possibly upsmon running on the Mac?  

Standard not when I start,  sudo upsmon -D, only upsmon and not upsd.  

> What does command   ps -elf | grep -E "ups[dms]|nut” report on the Mac? 


With copy and paste the commando didn’t work.  So I changed it.

ps -elf | grep -E "ups[dms]|nut”

0  2919  2788 4106   0  31  0  2447248  10756 -  S+  0 
ttys0000:00.04 sudo upsmon -D2:06PM
0  2920  2919 4006   0  31  0  2444528   2376 -  S+ 
 0 ttys0000:00.01 upsmon -D 2:06PM
0  2921  2920  106   0  31  0  2444528   2216 -  S+ 
 0 ttys0000:00.03 upsmon -D 2:06PM


> From the NAS, can you execute commands such as
> 
>   upsc UPS@Mac ups.status

upsc UPS@  ups.status
Error: Connection failure: Connection refused

> Does upsmon.conf on the NAS contain a MONITOR statement for the Mac? 

No it doesn’t and do I need to configure this. 

>  Do you propose shutting down on LB or after a time interval: in other words, 
> do you need upssched?

I don’t know yet. 


Kind Regards,



Rob 



smime.p7s
Description: S/MIME cryptographic signature
___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Re: [Nut-upsuser] Apple Mac slave

2017-06-06 Thread Roger Price

On Tue, 6 Jun 2017, Robbie van der Walle wrote:


I am running NUT on a Synology NAS with attached a USB APC UPS.


Do you have upsd and upsmon running as daemons on the Synology DSM?
Does the NAS shut down (and restart) correctly when wall power fails?


I am trying to connect and shutdown a Mac OS X system.


Is the Mac protected by the same APC UPS as the Synology NAS?

I have installed the NUT software and it looks like there is connection 
with the master but when battery gets low the Mac is not shutdown.


Do you have upsd and possibly upsmon running on the Mac?  What does 
command


   ps -elf | grep -E "ups[dms]|nut"

report on the Mac?


From the NAS, can you execute commands such as


   upsc UPS@Mac ups.status

Does upsmon.conf on the NAS contain a MONITOR statement for the Mac? Do 
you propose shutting down on LB or after a time interval: in other words, 
do you need upssched?


Roger

___
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser