<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">On Nov 7, 2020, at 11:18 AM, Jason Antman <<a href="mailto:jason@jasonantman.com" class="">jason@jasonantman.com</a>> wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<div class=""><br class=""></div><div class="">I'm quite new to NUT, currently setting it up on a few machines in my home lab because I switched from an APC UPS to a CyberPower unit. This is running in a home lab, and I'm trying to implement some apparently unusual logic around load-shedding.</div></div></div></blockquote><div><br class=""></div><div>The interesting thing to me is the shift from a single server being able to be supplied from one or more UPSes for redundancy, to a single UPS powering a number of smaller systems.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> I'm strongly considering writing my own custom script to replace upsmon in order to achieve the desired result.</div><div class=""><br class=""></div><div class="">I see a lot of mention in the documentation on upsmon and upssched about "events", as in an ONBATT, LOWBATT, ONLINE, etc., however I see nothing about these in the Network protocol documentation.</div></div></div></blockquote></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Can someone please confirm whether there are actual "events" being sent out to clients by upsd, or whether these events are completely derived/generated within upsmon, just based on polling upsd and detecting a change in something (such as ups.status)?</div><div class=""><br class=""></div></div></div></blockquote><div><div>The latter description is correct: upsmon polls the "ups.status" variable. When the state changes, upsmon generates the events internally. The majority of the mapping is in the comments here: <a href="https://github.com/networkupstools/nut/blob/v2.7.4/clients/upsmon.h" class="">https://github.com/networkupstools/nut/blob/v2.7.4/clients/upsmon.h</a> and the code here: <a href="https://github.com/networkupstools/nut/blob/v2.7.4/clients/upsmon.c#L1466-L1489" class="">https://github.com/networkupstools/nut/blob/v2.7.4/clients/upsmon.c#L1466-L1489</a></div><div><br class=""></div><div>There is a lot of business logic in upsmon devoted to logging, reconnecting, and detecting the status changes (potentially across disconnects). If you didn't want to rewrite and test that code in your own script, you could use the EXEC flag in upsmon to start your script from NOTIFYCMD when the UPS goes on battery, and then poll battery level from there. You could then set up another section of your script for ONLINE (which only gets called on a transition from OB to OL, not at startup) that does wake-on-LAN and kills the script started for ONBATT.</div><div><br class=""></div><div>The key to on-battery/online is the NOTIFYTYPE environment variable: <a href="https://networkupstools.org/docs/man/upsmon.conf.html" class="">https://networkupstools.org/docs/man/upsmon.conf.html</a></div><div><br class=""></div></div></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Thanks so much,</div><div class="">Jason Antman</div><div class=""><br class=""></div><div class="">PS - Since someone may ask about it, given my introduction, here's the setup I have:</div><div class=""><br class=""></div><div class="">* One CyberPower UPS powering everything</div><div class="">* Three Linux machines, "A", "B", and "C"</div><div class="">* A bunch of network devices, as well as two Raspberry Pis</div><div class=""><br class=""></div><div class="">I'm trying to achieve the following shutdown behavior:</div><div class="">* Kill host A when battery drops to 80%</div><div class="">* Kill host B at 50%</div><div class="">* Kill host C at 10%</div><div class="">* Leave the outputs turned on always, so the network and Pis keep running</div><div class="">* If the power comes back before the battery is exhausted, a script will turn on hosts A, B, and C via wake-on-lan.</div><div class=""><br class=""></div></div>
_______________________________________________<br class="">Nut-upsuser mailing list<br class=""><a href="mailto:Nut-upsuser@alioth-lists.debian.net" class="">Nut-upsuser@alioth-lists.debian.net</a><br class="">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</div></blockquote></div><br class=""></body></html>