Sometime ago I had blogged about Monitor Linux Host Restart
The simple solution: How to email admins automatically after a Linux server starts?
Here is the example from root’s cron:
# crontab -l
@reboot su oracle -c '/home/oracle/scripts/host_restart_alert.sh' > /tmp/host_restart_alert.out 2>&1
Shell script is used because mail cannot be sent from local host and will need to be sent from remote host.
#!/bin/bash -x
MAILFROM=
MAILTO=
SUBJECT="Node reboot detected for $(hostname)"
EMAILMESSAGE="$(hostname) was restarted `uptime -p| awk -F'up' '{print $2}'` ago at `uptime -s`"
# uptime reports minutely and need to sleep for at least 60s after host restart
sleep 63
ssh oracle@remotehost /bin/bash <<EOF
/home/oracle/scripts/send_email.sh "$EMAILMESSAGE" "$SUBJECT" "$MAILFROM" "$MAILTO"
EOF
exit
Why is there a need to detect host restart and isn’t there monitoring for the host?
This is Oracle Exadata Cloud@Customer (ExaCC) environment.
When Oracle support performs patching, they do not provide any sort of communication or status and monitoring is disable for all hosts beforehand.
OPatchAuto to Patch a GI/RAC Environment.
After the patching is complete and your servers are restarted, you should check your product software to verify that the issue has been resolved.
This is why there is a need to detect and be notified for server restart.