[Nut-upsuser] Email Alerts for Multiple UPSs with upssched
Garrett Michael Hayes
Garrett at VerbalImaging.com
Wed Nov 1 15:34:51 UTC 2017
This was the secret sauce! I first modified my BASH script to stuff the output of the 'set' command into a variable, then passed that variable in to my email command. Then I triggered an event and saw what variables were there in the body of the message.
$UPSNAME and $NOTIFYTYPE were there and available. I modified the script to pump THOSE into the mail command, and the problem is (at least partially) solved.
The next challenge is going to be sorting out which UPS is being seen on which USB port.
From: Jim Klimov [mailto:jimklimov at cos.ru]
Sent: Tuesday, October 31, 2017 1:36 PM
To: nut-upsuser at lists.alioth.debian.org; Garrett Michael Hayes <Garrett at VerbalImaging.com>; nut-upsuser at lists.alioth.debian.org
Subject: Re: [Nut-upsuser] Email Alerts for Multiple UPSs with upssched
On October 31, 2017 4:09:46 PM GMT+01:00, Garrett Michael Hayes <Garrett at VerbalImaging.com> wrote:
>I have started deploying a number of NUT instances on Raspberry Pi
>machines (Raspbian Jessie) across my network. The purpose of these
>"nutcases" as we refer to them is to monitor the status of the UPSs
>supporting our network switching infrastructure and notify us of power
>and battery events via email. No shutdown or other actions are
>Everything is going spiffy as all get-out so far. But now I'm running
>up against a configuration issue I don't quite know how to address.
>Thus far each "nutcase" has been configured to monitor a single UPS.
>Now I want to deploy one to monitor three UPSs in a larger switch
>closet. Adding the additional UPSs to ups.conf and upsmon.conf is
>fairly straightforward. But I'm darned if I can figure out how to
>configure the email alerts to let me know WHICH UPS is the source of an
>I'm using upssched as my NOTIFYCMD, and it in turn is calling a little
>shell script that reads the flag that's passed and sends an email.
>What I can't figure out is how (if there is a way) to determine the
>originating UPS. It seems that only the status flag makes it across to
>the shell script. Or at least if it's passing more than that, I don't
>know how to retrieve it.
>I'm sure I must be missing something simple. Any thoughts/pointers
>would be appreciated!
>Garrett Michael Hayes
Try $UPSNAME (this and other vars are RTFMed somewhere, maybe comments to configs) - I used it in NOTIFYCMD handling by scripts directly, maybe it would pass through upssched too?
Also a script can call `set` to print out its env, as well as you can inspect /proc/PID/environ on linux to get the envvars of a running process.
Typos courtesy of K-9 Mail on my Android
More information about the Nut-upsuser