How to setup an alert to know about server crash situation ?

Many times our server crashes and reboots and we remain unaware about the situation.

To know this situation, we cam setup alerts on our server and take corrective action immediately in case of issues.

Setup Script to send email about any server crash Situation

1. Verify Path of crash dump.
First lets verify the path of crash dump.

[root@ngelinux]# cat /etc/kdump.conf  | grep -I path
# Currently only one dump target and path may be configured at a time. If dump
# path  		- Append path to the filesystem device which you are
#			  //%HOST-%DATE/, supports DNS.
#			  :/%HOST-%DATE/ via SSH,
#		 	  /proc/vmcore to /mnt//
# 			  non-boot-path dump targets that might otherwise
# sshkey 
#			- Specifies the path of the ssh identity file you want
path /var/crash

2. Now create your command to search for vmcore.
I have searched for vmcore files created in last 60 minutes.

[root@ngelinux crash]# find /var/crash -mmin -60 -type f -name *vmcore*

3. Create below script and place in /etc/cron.hourly.

[root@ngelinux cron.hourly]# vim

[root@ngelinux cron.hourly]# cat 
getfiles=`find /var/crash -mmin -60 -type f -name *vmcore*`
if [[ $getfiles == "" ]]; then
      echo "Your Server \"$(hostname)\" encountered a suspected crash situation. Please Check " | mail -s "Alarm: Check Your Server $(hostname)" root@localhost

[root@ngelinux cron.hourly]# 

Make the script executable.

[root@ngelinux cron.hourly]# 
[root@ngelinux cron.hourly]# chmod +x 
[root@ngelinux cron.hourly]# 

4. Now you will get mail in case there is any vmcore file is generated in last 60 minutes.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments