Koozali.org: home of the SME Server

Modifying NUT UPS shutdown delay.

Offline Arnie

  • ***
  • 81
  • +0/-0
  • Old Dog, New Tricks.
Modifying NUT UPS shutdown delay.
« on: July 15, 2009, 05:50:35 AM »
Hello All!

I've recently configured a new Power Shield Defender 650VA UPS on my home SME server and it is working well. I would, however, like to change the shutdown behavior of the server.

At the moment, when the UPS goes to battery, the server continues to operate until the UPS sends the "battery low" warning, at which point it auto-shuts down. I would like to change the configuration so that the server will shut down 2 minutes after receiving the "on battery" signal.

What is the best way to achieve this?

Thanks in advance.

P.S. For those Aussies who are thinking about getting one of these UPS', I configured NUT to use the megatec_usb driver and set the port to "auto".
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Modifying NUT UPS shutdown delay.
« Reply #1 on: July 15, 2009, 02:30:54 PM »
Hello All!

I've recently configured a new Power Shield Defender 650VA UPS on my home SME server and it is working well. I would, however, like to change the shutdown behavior of the server.

At the moment, when the UPS goes to battery, the server continues to operate until the UPS sends the "battery low" warning, at which point it auto-shuts down. I would like to change the configuration so that the server will shut down 2 minutes after receiving the "on battery" signal.

What is the best way to achieve this?

Thanks in advance.

P.S. For those Aussies who are thinking about getting one of these UPS', I configured NUT to use the megatec_usb driver and set the port to "auto".
Not sure if some external script is called but perhaps youc an make it sleep 2 minutes before starting the shutdown.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: Modifying NUT UPS shutdown delay.
« Reply #2 on: July 18, 2009, 08:55:52 AM »
Arnie

Quote
I would like to change the configuration so that the server will shut down 2 minutes after receiving the "on battery" signal.
What is the best way to achieve this?

Look here
http://wiki.contribs.org/Uninterruptable_Power_Supply#Aditional_Information
and here
http://forums.contribs.org/index.php?topic=40668.0

The NUT website is here
http://www.networkupstools.org/
where you can glean which configuration setting does what

Then modify the NUT config file, by creating a custom template, expanding template and restarting service





Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline Arnie

  • ***
  • 81
  • +0/-0
  • Old Dog, New Tricks.
Re: Modifying NUT UPS shutdown delay.
« Reply #3 on: July 20, 2009, 09:16:55 AM »
Thanks for the advice mary.

It turns out that if you want a timed shutdown before the BATTLOW signal, you can't rely on upsmon, you have to configure upssched and have a script to handle the UPS events.

Anyway, I got it working now.
...

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: Modifying NUT UPS shutdown delay.
« Reply #4 on: July 20, 2009, 09:22:47 AM »
Arnie

Please share a more detailed answer with us, and it can be added to the wiki.
ie what was the script and where did you put it etc.

I expect your requirement may also be desirable to others in certain situations.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline thomasch

  • *
  • 232
  • +0/-0
Re: Modifying NUT UPS shutdown delay.
« Reply #5 on: July 21, 2009, 06:29:49 AM »
It turns out that if you want a timed shutdown before the BATTLOW signal, you can't rely on upsmon, you have to configure upssched and have a script to handle the UPS events.

Anyway, I got it working now.

How? Please share.

thanks

Offline Arnie

  • ***
  • 81
  • +0/-0
  • Old Dog, New Tricks.
Re: Modifying NUT UPS shutdown delay.
« Reply #6 on: July 22, 2009, 04:47:01 PM »
I did the following:

config setprop nut status enabled
config setprop nut Model megatec_usb
config setprop nut Type auto

/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD:
Code: [Select]
NOTIFYCMD /usr/sbin/upssched
/etc/e-smith/templates/etc/ups/upssched.conf/01CONFIG:
Code: [Select]
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 60     <------ Set this to how many seconds after ONBATT signal you want to shut down
AT LOWBATT * EXECUTE shutdowncritical
AT ONLINE * CANCEL-TIMER shutdownnow
AT ONLINE * EXECUTE powerup

/sbin/e-smith/nutUPS.cmd:
Code: [Select]
#! /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

/etc/e-smith/templates/etc/sudoers/30nut:
Code: [Select]
nut   ALL=NOPASSWD: ALL
signal-event post-upgrade
signal-event reboot


It ain't pretty, but it works. :P
« Last Edit: July 22, 2009, 04:49:54 PM by Arnie »
...

Offline Stefano

  • *
  • 10,836
  • +2/-0
Re: Modifying NUT UPS shutdown delay.
« Reply #7 on: July 22, 2009, 04:52:42 PM »
did you edit directly /etc/e-smith/templates/etc/ups/upssched.conf/ files?

that's wrong.. you'd create the same fragments in /etc/e-smith/templates-custom/etc/ups/upssched.conf/ dir, otherwise your customizations will be lost at the first update.

Stefano

Offline Arnie

  • ***
  • 81
  • +0/-0
  • Old Dog, New Tricks.
Re: Modifying NUT UPS shutdown delay.
« Reply #8 on: July 23, 2009, 02:31:33 AM »
Who does updates???????

 :lol: :lol: :lol: :lol: :lol: :lol:
...

Offline raem

  • *
  • 3,972
  • +4/-0
Re: Modifying NUT UPS shutdown delay.
« Reply #9 on: July 31, 2009, 03:18:07 PM »
Added here
http://wiki.contribs.org/Uninterruptable_Power_Supply#Modifying_shutdown_time_delay

Would someone please review it, as I have not yet had time or the opportunity to test the instructions myself.
...

Offline Arnie

  • ***
  • 81
  • +0/-0
  • Old Dog, New Tricks.
Re: Modifying NUT UPS shutdown delay.
« Reply #10 on: August 03, 2009, 05:56:42 PM »
Quote
config setprop nut Model megatec_usb
config setprop nut Type auto

Those two lines are specific to the Power Shield Defender 650VA and other compatible UPS' with a USB port. It may be better to leave those lines out and have the user figure out which drivers work for their UPS.
...