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
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*
0 comments:
Post a Comment