1

I need to generate a SMS / Email alert when the server´s UPS is finishing its charge. We have a car battery connected to the motherboard that works as a UPS (http://www.mini-box.com/M2-ATX-160w-Intelligent-Automotive-DC-DC-Power-Supply) When this device detects that battery is lowering the voltage, its send an ON pulse to the motherboard. Somehow Ubuntu (i´m using version 11) detects this pulse and shows a screen telling that in 60 seconds ubuntu will shutdown. I need to execute a script to call a webservice to notify this situation. How can I trap that alert? I have also tried also using a script in rc0.d but it is not calling my WS (seems that network is down before it is executed). How can I alternatively execute something in runlevel 0 before network is down?

Ezequiel
  • 137
  • 7

1 Answers1

1

There is maybe a cleaner way to achieve this, however the following works on my Ubuntu 12.04 (sorry, don't have 11 under hands).

Under /etc/rc0.d you should find a file named S35networking which is in fact a link to /etc/init.d/networking.

In this file locate the stop) for the case statement and add your command line/script here, at first line. It will be executed before the NIC goes down.

e.g :

case "$1" in
start)
        ....
        ;;

stop)
        send_sms_email
        ...
        ;;
....
esac

To summarize, i just suggest to modify the system init.d networking script to add your command on stop event.

It will work, but once again it is maybe not the cleanest way...it is a way...

krisFR
  • 12,830
  • 3
  • 31
  • 40