Question:
I've set the BIOS of my server to automagically resume the last state (running/switched off) after a powerloss.
Now, how can I send myself an E-Mail when the system has resumed after a powerloss ?
I know it is possible, since my Synology Diskstation can do it (which is how I got the idea in the first place). Sadly I'm not able to reverse-engineer how it does it.
Add an RC script or equivalent. Have it touch a file on normal shutdown. On startup, have it check for the file, and send an email if the file is not there. E.g:
(You'll probably have to debug it, and pay attention to security to avoid accidentally giving users access to create files to conflict with this one)
Just add something like this to
/etc/rc.local
:This will email every time it boots, not just after power loss. More logic will be required if you only want emails following power loss. Personally, I like to know whenever one of my servers reboot - especially if it wasn't an intentional reboot.
You need an Internal IPMI on the system hardware ( which can report failures of powerloss and hardware failure via email)
Secondly and i think most importantly.. and external system which checks health of systems..
Nagios & Cacti both offer these functions..
Cacti actually being the simpler of the two ( Nagios can be quite complicated to maintain ) Using SNMP or simple pings.. ( can also be other services )
Basically the tool allows you to poll every ( determined ) minutes.. for a response.. After (determined) failures, it sends you an email..
This is a typical systems administrators set of tools for notifications.. :D