[Nut-upsuser] Best practice to shutdown hosts which has not NUT via upssched

Dmitri Stepanov dstep at mail.ru
Fri Jul 15 08:57:51 UTC 2016

>Четверг, 14 июля 2016, 23:58 +03:00 от Roger Price < roger at rogerprice.org >:
>On Thu, 14 Jul 2016, Dmitri Stepanov wrote:
>> Some of those hosts haven't NUT including upsmon (and other software 
>> which is not included by suppliers of the hosts) for a number of 
>> reasons. I don't need to inform not-NUT hosts about any UPS events, 
>> etc... but only shutdown all the hosts after upssched timer expired. So 
>> I think shutdown them via ssh would be enough and creating some 
>> replacement for upsmon is too much.
>Perhaps it is possible to have a micro upsmon in the form of a cron job in 
>every slave which, every minute, runs something like
>  rprice at maria:~> X=$( echo "GET VAR my-ups battery.charge" | netcat -w1 upsd-server 3493 )
>  rprice at maria:~> if [[ "$X" =~ \"([0-9]*)\" ]] ; then Y=${BASH_REMATCH[1]}; else Y=999 ; fi
>  rprice at maria:~> if [[ "$Y" -gt 35 ]] ; then echo "Carry on $Y" ; else echo "Shutdown $Y" ; fi
>  Carry on 100
>Different slaves could have different low battery values. I'm sure that a 
>netcat expert would be able to find a way of executing netcat only once.

Cool. I've never think via this way. I'm sure I'll use it. Thank you for the hint.
But a problem could be with netcat software (if it installed or not on the not-NUT slaves, moreover there are a number of Windows hosts). Unfortunately I have no ability to break in configuration and installed software of the not-NUT hosts too deeply (licenses of the suppliers of the hosts, etc...).

Thanks to Kris Jordan, I guess the problem is the uid of the upssched (CMDSCRIPT and my shutdown script and ssh) process. I hope I 'd check it as soon as I get connection to the system.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20160715/e3100c60/attachment.html>

More information about the Nut-upsuser mailing list