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

Roger Price roger at rogerprice.org
Thu Jul 14 20:58:53 UTC 2016


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.

Roger



More information about the Nut-upsuser mailing list