[Nut-upsuser] Variable use in upssched-cmd

tarbeite tarbeite at fit.edu
Tue Nov 4 17:47:34 UTC 2008


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 


More information about the Nut-upsuser mailing list