power outage
How can one tell if your linux server has experienced a power outage. For example, i have 2 servers in a datacenter. If the power goes out, is there a log that will tell me that the power went out unexpectedly?? I am using redhat enterprise 4 advanced server.
|
Well, who -b will tell you when the system was last booted; you could have a script check this periodically and email you if it changes.
So something like a combination of the following would email you only on unexpected reboots. /etc/rc0.d/S30shutdownonpurpose: #!/bin/sh touch /deliberateshutdown crontab entry: */5 * * * * /usr/local/bin/check-reboot /usr/local/bin/check-reboot: #!/bin/bash if [ -f /deliberateshutdown ]; then rm /deliberateshutdown who -b > /var/run/lastboot elif ! cmp /var/run/lastboot <(who -b) >/dev/null; then mail root -s power <<<"There may have been a power outage" who -b > /var/run/lastboot fi |
All times are GMT -5. The time now is 02:04 PM. |