Hi all I have most of the NUT system up and running. I?m in the process of writing the script to send email notifications for certain events. This is my upsshed-cmd file so far: # EC130 Commands ec130onbatt) echo "EC130 UPS has been on Battery for more then 10 seconds" \ | mailx -r "ups at fit.edu" -s"EC130 on battery" tarbeite at fit.edu ;; ec130combad) echo "Communications to EC130 UPS have degraded." \ | mailx -r "ups at fit.edu" -s"EC130 bad Communications" tarbeite at fit.edu ;; ec130cbatt) echo "Battery in EC130 UPS needs to be replaced" \ | mailx -r "ups at fit.edu" -s"EC130 bad battery" tarbeite at fit.edu ;; ec130lowbatt) echo "Battery in EC130 UPS is low" \ | mailx -r "ups at fit.edu" -s"EC130 low battery" tarbeite at fit.edu ;; #EC132 Commands ec132onbatt) echo "EC132 UPS has been on Battery for more then 10 seconds" \ | mailx -r "ups at fit.edu" -s"EC132 on battery" tarbeite at fit.edu ;; ec132combad) echo "Communications to EC132 UPS have degraded." \ | mailx -r "ups at fit.edu" -s"EC130 bad Communications" tarbeite at fit.edu ;; ec132cbatt) echo "Battery in EC132 UPS needs to be replaced" \ | mailx -r "ups at fit.edu" -s"EC132 bad battery" tarbeite at fit.edu ;; ec132lowbatt) echo "Battery in EC132 UPS is low: \ | Mailx -r "ups at fit.edu" -s"EC132 low battery" tarbeite at fit.edu I have somewhere around 12 ups?s that the server watches and would like to thin out this code a little bit. Is there anyway to have UPSMON send a command such as a COMMBAD * and then have upssched-cmd pickup the upsname from the * and use it to send the approriate email. Example being a communication error happens on ec132 and sends a commbad * to upssched-cmd. I want upsched-cmd to then send the appriate email ?UPS EC132 has bad communications? when this happens. I want to do this using variables so that I only have to write the command out once for each event instead of for each event 12 times. Hopefully that made sense and pardon the length of the email Thanks ~Tim -- Timothy Arbeiter Lead Lab Support Technician Florida Institute of Technology tarbeite at fit.edu (321)674-8023 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20081104/18edc7ad/attachment.htm
Citeren tarbeite <tarbeite at fit.edu>: [...]> I have somewhere around 12 ups?s that the server watches and would like to > thin out this code a little bit. Is there anyway to have UPSMON send a > command such as a COMMBAD * and then have upssched-cmd pickup the upsname > from the * and use it to send the approriate email.This is described almost literally in 'man 8 upssched' and 'man 5 upssched.conf'. The name of the UPS is passed in the environment variable UPSNAME and the reason in NOTIFYTYPE. In your upssched-cmd script you can use these variables like any other environment variable. Best regards, Arjen -- Please keep list traffic on the list
On Tue, Nov 4, 2008 at 12:47 PM, tarbeite <tarbeite at fit.edu> wrote:> Hi all > > I have most of the NUT system up and running. I'm in the process of writing > the script to send email notifications for certain events. This is my > upsshed-cmd file so far: > > # EC130 Commands > > ec130onbatt) > echo "EC130 UPS has been on Battery for more then 10 > seconds" \ > | mailx -r "ups at fit.edu" -s"EC130 on battery" > tarbeite at fit.edu > ;; > ec130combad) > echo "Communications to EC130 UPS have degraded." \ > | mailx -r "ups at fit.edu" -s"EC130 bad Communications" > tarbeite at fit.eduAs an aside, you can use wildcards in case statements. I think the variables that Arjen pointed out should help, though. -- - Charles Lepple