mcelog: Shell Script To Send Email Alert When Hardware Errors Detected

in Categories Monitoring last updated June 3, 2009
# Linux 64 bit kernel shell script to collect hardware errors via /var/log/mcelog
# and send email alert.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
# Tested under RHEL and Debian Linux 64 bit version.
# mcelog must be installed. 
# See:
ASUB="H/W Error - $(hostname)"
AMESS="Warning - Hardware errors found on $(hostname) @ $(date). See log file for the details /var/log/mcelog."
OK_MESS="$0 - OK: NO Hardware Error Found."
WARN_MESS="$0 - ERROR: Hardware Error Found."
	echo "$@"
	exit 999
	echo $AMESS | email -s "${ASUB}" ${AEMAIL}
[ ! -f "$FILE" ] && die "Error - No $FILE exists or mcelog is not configured"
[ $(grep -c -i "hardware error" $FILE) -gt 0 ] && warn || $LOGGER $OK_MESS

Share this on:

6 comment

  1. Vivek;

    I tried the script on my ubuntu904 (i386 machine) but I get this error;
    (I apt-get install mcelog ) but still get;
    Error – No /var/log/mcelog exists or mcelog is not configured

    How do I configure the mcelog?


Leave a Comment