Changes

Jump to navigation Jump to search
Added modifying shutdown time delay & modified additional info
Line 113: Line 113:     
- Templating example: http://forums.contribs.org/index.php?topic=40668.0
 
- Templating example: http://forums.contribs.org/index.php?topic=40668.0
 +
 +
==Modifying shutdown time delay==
 +
 +
The following changes to NUT configuration will shut down the server a specified time after receiving the "on battery" signal (the example given is for 2 minutes).
 +
 +
To create a timed shutdown before the BATTLOW signal is received, it is necessary to configure upssched and have a script handle the UPS events (upsmon cannot do this).
 +
config setprop nut status enabled
 +
config setprop nut Model megatec_usb
 +
config setprop nut Type auto
 +
 +
Create and edit a custom template
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/upsmon.conf
 +
pico -w /etc/e-smith/templates-custom/etc/ups/upsmon.conf/NOTIFYCMD
 +
 +
Add the following:
 +
NOTIFYCMD /usr/sbin/upssched
 +
 +
Save & exit
 +
Ctrl o
 +
Ctrl x
 +
 +
Create and edit a custom template
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/upssched.conf
 +
pico -w /etc/e-smith/templates-custom/etc/ups/upssched.conf/01CONFIG
 +
 +
Add the following:
 +
CMDSCRIPT /sbin/e-smith/nutUPS.cmd
 +
PIPEFN /tmp/upspipe
 +
LOCKFN /tmp/upslock
 +
AT COMMBAD * EXECUTE commbad
 +
AT COMMOK * EXECUTE commok
 +
AT NOCOMM * EXECUTE nocomm
 +
AT ONBATT * EXECUTE powerout
 +
AT ONBATT * START-TIMER shutdownnow 120   
 +
AT LOWBATT * EXECUTE shutdowncritical
 +
AT ONLINE * CANCEL-TIMER shutdownnow
 +
AT ONLINE * EXECUTE powerup
 +
 +
In the above set the line
 +
AT ONBATT * START-TIMER shutdownnow 120
 +
to how many seconds after ONBATT signal you want to shut down
 +
 +
Save & exit
 +
Ctrl o
 +
Ctrl x
 +
 +
Create the script
 +
pico -w /sbin/e-smith/nutUPS.cmd
 +
 +
Add the following:
 +
 +
#! /bin/sh
 +
        case $1 in
 +
                commbad)
 +
                        /bin/echo "UPS communications failure on `date`." | /bin/mail -s"UPS communications LOST" admin
 +
                        /usr/bin/wall "UPS communications failure."
 +
                        ;;
 +
                commok)
 +
                        /bin/echo "UPS communications restored on `date`." | /bin/mail -s"UPS communications restored" admin
 +
                        /usr/bin/wall "UPS communications restored."
 +
                        ;;
 +
                nocomm)
 +
                        /bin/echo "UPS communications cannot be established on `date`." | /bin/mail -s"UPS uncontactable" admin
 +
                        /usr/bin/wall "UPS communications cannot be established."
 +
                        ;;
 +
                powerout)
 +
                        /bin/echo "Power failure on `date`." | /bin/mail -s"UPS on battery" admin
 +
                        /usr/bin/wall "UPS on battery. Shutdown in 60 seconds...."
 +
                        ;;
 +
                shutdownnow)
 +
                        /bin/echo "UPS has been on battery for 60 seconds. Starting orderly shutdown on `date`." | /bin/mail -s"UPS on battery for 60 seconds" admin
 +
                        /usr/bin/wall "UPS has been on battery for 60 seconds. Shutting down NOW!!!!"
 +
                        /usr/bin/sudo /sbin/e-smith/signal-event halt
 +
                        ;;
 +
                shutdowncritical)
 +
                        /bin/echo "UPS battery level CRITICAL. Starting EMERGENCY shutdown on `date`." | /bin/mail -s"UPS battery CRITICAL" admin
 +
                        /usr/bin/wall "UPS battery level CRITICAL. Shutting down NOW!!!!"
 +
                        /usr/bin/sudo /sbin/e-smith/signal-event halt
 +
                        ;;
 +
                powerup)
 +
                        /bin/echo "Power restored on `date`." | /bin/mail -s"UPS on line" admin
 +
                        /usr/bin/wall "UPS on line. Shutdown aborted."
 +
                        ;;
 +
                *)
 +
                        /bin/echo "Unrecognized command: $1"
 +
                        ;;
 +
        esac
 +
 +
 +
Create a custom template
 +
mkdir -p /etc/e-smith/templates-custom/etc/sudoers/30nut
 +
 +
Add the following
 +
nut  ALL=NOPASSWD: ALL
 +
 +
To complete the process
 +
signal-event post-upgrade
 +
signal-event reboot
 +
    
==Aditional Information==
 
==Aditional Information==
Line 130: Line 229:  
  man upsd
 
  man upsd
 
  man nutupsdrv
 
  man nutupsdrv
 +
 +
The NUT website is here
 +
 +
http://www.networkupstools.org/
 +
 +
From that website you can glean which configuration setting does what function
 +
 +
Then modify the NUT config file, by creating a custom template, expanding template and restarting service
 +
 
----
 
----
 
<noinclude>[[Category:Howto]]</noinclude>
 
<noinclude>[[Category:Howto]]</noinclude>
624

edits

Navigation menu