02.12.2015 Views

Network UPS Tools User Manual

Network UPS Tools User Manual

Network UPS Tools User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Network</strong> <strong>UPS</strong> <strong>Tools</strong> <strong>User</strong> <strong>Manual</strong> 33 / 84<br />

7.1.4 Suppressing notify storms<br />

upsmon will call your script every time an event happens that has the EXEC flag set. This means a quick power failure that<br />

lasts mere seconds might generate a notification storm. To suppress this sort of annoyance, use upssched as your NOTIFYCMD<br />

program, and configure it to call your command after a timer has elapsed.<br />

7.2 The advanced approach, using upssched<br />

upssched is a helper for upsmon that will invoke commands for you at some interval relative to a <strong>UPS</strong> event. It can be used to<br />

send pages, mail out notices about things, or even shut down the box early.<br />

There will be examples scattered throughout. Change them to suit your pathnames, <strong>UPS</strong> locations, and so forth.<br />

7.2.1 How upssched works relative to upsmon<br />

When an event occurs, upsmon will call whatever you specify as a NOTIFYCMD in your upsmon.conf, if you also enable the<br />

EXEC in your NOTIFYFLAGS. In this case, we want upsmon to call upssched as the notifier, since it will be doing all the work<br />

for us. So, in the upsmon.conf:<br />

NOTIFYCMD /usr/local/ups/bin/upssched<br />

Then we want upsmon to actually use it for the notify events, so again in the upsmon.conf we set the flags:<br />

NOTIFYFLAG ONLINE SYSLOG+EXEC<br />

NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC<br />

NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC<br />

... and so on.<br />

For the purposes of this document I will only use those three, but you can set the flags for any of the valid notify types.<br />

7.2.2 Setting up your upssched.conf<br />

Once upsmon has been configured with the NOTIFYCMD and EXEC flags, you’re ready to deal with the upssched.conf details.<br />

In this file, you specify just what will happen when a given event occurs on a particular <strong>UPS</strong>.<br />

First you need to define the name of the script or program that will handle timers that trigger. This is your CMDSCRIPT, and<br />

needs to be above any AT defines. There’s an example provided with the program, so we’ll use that here:<br />

CMDSCRIPT /usr/local/ups/bin/upssched-cmd<br />

Then you have to define the variables PIPEFN and LOCKFN; the former sets the file name of the FIFO that will pass communications<br />

between processes to start and stop timers, while the latter sets the file name for a temporary file created by upssched<br />

in order to avoid a race condition under some circumstances. Please see the relevant comments in upssched.conf for additional<br />

information and advice about these variables.<br />

Now you can tell your CMDSCRIPT what to do when it is called by upsmon.<br />

The big picture<br />

The design in a nutshell is:<br />

upsmon ---> calls upssched ---> calls your CMDSCRIPT<br />

Ultimately, the CMDSCRIPT does the actual useful work, whether that’s initiating an early shutdown with upsmon -c fsd, sending<br />

a page by calling sendmail, or opening a subspace channel to V’ger.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!