[Nut-upsuser] NOTIFYMSG as content of email

Simon Wilson simon at simonandkate.net
Sun Nov 27 03:29:47 GMT 2022


I worked it out, apologies to all for the unnecessary emails.

I missed the line in man upsmon that says:

"It also receives the notification message (see below) as the first  
(and only) argument, so you can deliver a preformatted message too."

This works fine:

echo -e "Subject: UPS alert: $1\n\nUPS: $UPSNAME\r\nAlert type:  
$NOTIFYTYPE\r\nDetail: $1" | msmtp $EMAIL

Simon.


----- Message from Simon Wilson via Nut-upsuser  
<nut-upsuser at alioth-lists.debian.net> ---------
     Date: Sun, 27 Nov 2022 13:01:14 +1000
     From: Simon Wilson via Nut-upsuser <nut-upsuser at alioth-lists.debian.net>
Reply-To: simon at simonandkate.net
  Subject: [Nut-upsuser] NOTIFYMSG as content of email
       To: nut-upsuser at alioth-lists.debian.net


> Hi, new NUT user here, so please bear with me.
>
> I have setup my Eaton 5SX, and am trying to do a simple notification  
> email, without going to the more complex upssched examples.
>
> I have a simple notification command listed in upsmon.conf, and have  
> added +EXEC to the NOTIFYFLAGs:
>
> NOTIFYCMD /etc/ups/notifycmd.sh
> NOTIFYFLAG ONLINE     SYSLOG+EXEC
> NOTIFYFLAG ONBATT     SYSLOG+EXEC
>
> ...the script passes the variables to msmtp to send an email on an event:
>
> #!/bin/bash
> EMAIL='simon at simonandkate.net'
> echo -e "Subject: UPS ALERT: $NOTIFYTYPE\n\nUPS: $UPSNAME\r\nAlert  
> type: $NOTIFYTYPE" | msmtp $EMAIL
>
> That results in an email saying (e.g.):
>
> Subject: UPS ALERT: ONBATT
> UPS: eaton5sx at localhost
> Alert type: ONBATT
>
> I'd like it to read per the NOTIFYMSG content in upsmon.conf, e.g.:
>
> Subject: UPS ALERT: UPS eaton5sx is on battery
> UPS: eaton5sx at localhost
> Alert type: UPS eaton5sx is on battery
>
>
> ...but I can't work out how to read the NOTIFYMSG into the script  
> instead of NOTIFYTYPE. How do I do that?
>
> Simon.


----- End message from Simon Wilson via Nut-upsuser  
<nut-upsuser at alioth-lists.debian.net> -----



-- 
Simon Wilson
M: 0400 12 11 16




More information about the Nut-upsuser mailing list