Menu

Send Email Alert When Hardware Errors Detected

[root@instructor script]# yum install mcelog -y
Default Mcelog cron file is here /etc/cron.hourly/mcelog.cron
[root@instructor script]# vi /etc/cron.hourly/mcelog.cron

#!/bin/bash

# do not run if mcelogd is running

service mcelogd status >& /dev/null

[ $? -eq 0 ] && exit 0

# is mcelog supported?

/usr/sbin/mcelog --supported >& /dev/null

if [ $? -eq 1 ]; then

       exit 1;

fi

/usr/sbin/mcelog --ignorenodev --filter >> /var/log/mcelog 

After that paste bellow line into you hardwareerror.sh file.. 
[root@instructor script]# touch hardwareerror.sh
[root@instructor script]# vi hardwareerror.sh

#!/bin/bash

[ $(grep -c "error" /var/log/mcelog) -gt 0 ] && echo "Hardware Error Found $(hostname) @ $(date)" | 

cat /var/log/mcelog | mail -s 'H/w Error' info@hackthesec.co.in

exit 0 
and run the script through cronjob
Note : - If your system get any hardware issue then the script will send you a mail other wise you did 
not get any email... *Only when your system detected any issue*

About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a Comment

 
Top