“mce: [Hardware Error]: Machine check events logged” appears in syslog.

ABOUT mcelog

mcelog logs and accounts machine checks (in particular memory, IO, and CPU hardware errors) on modern x86 Linux systems.
mcelog is required by both 32bit x86 Linux kernels (since 2.6.30) and 64bit Linux kernels (since early 2.6 kernel releases) to log machine checks and should run on all Linux systems that need error handling.

The mcelog daemon accounts memory and some other errors errors in various ways. mcelog --client can be used to query a running daemon. The daemon can also execute triggers when configurable error thresholds are exceeded. This is used to implement a range of automatic predictive failure analysis algorithms: including bad page offlining and automatic cache error handling. User defined actions can be also configured.

All errors are logged to /var/log/mcelog or syslog or the journal.

For memory errors it supports modern x86 systems with integrated memory controllers; for CPU errors all modern x86 systems are supported.

Traditionally mcelog was run as a cronjob, but this usage is deprecated now. The modern way to run it is to start it at boot up time and run it always as a daemon. In addition it can be used to decode fatal machine checks on the command line (but this is also usually not needed anymore on modern kernels which log those after reboot automatically)


SHELL SESSION EXPOSURE

$sudo apt-get install mcelog
[sudo] password for jeffrin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bluez-alsa bluez-gstreamer cgmanager cups-client libcgmanager0 libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 libnih-dbus1
  libnih1
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  mcelog
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 69.9 kB of archives.
After this operation, 213 kB of additional disk space will be used.
Get:1 http://http.us.debian.org/debian stable/main amd64 mcelog amd64 147+dfsg-1 [69.9 kB]
Fetched 69.9 kB in 2s (37.8 kB/s) 
Selecting previously unselected package mcelog.
(Reading database ... 246779 files and directories currently installed.)
Preparing to unpack .../mcelog_147+dfsg-1_amd64.deb ...
Unpacking mcelog (147+dfsg-1) ...
Setting up mcelog (147+dfsg-1) ...
Processing triggers for systemd (239-15) ...
Processing triggers for man-db (2.8.4-3) ...
$

$git clone git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git
Cloning into 'mcelog'...
remote: Counting objects: 2235, done.
remote: Total 2235 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2235/2235), 577.07 KiB | 71.00 KiB/s, done.
Resolving deltas: 100% (1521/1521), done.
$

SOURCE CODE EXPOSURE

static char *skipgunk(char *s)
{
	s = skip_syslog(s);

	s = skipspace(s);
	if (*s == '<') { 
		s += strcspn(s, ">"); 
		if (*s == '>') 
			++s; 
	}
	s = skipspace(s);
	if (*s == '[') {
		s += strcspn(s, "]");
		if (*s == ']')
			++s;
	}

	s = skipspace(s);

	if (strncmp(s, "mce: [Hardware Error]:", 22) == 0)
		s += 22;

	return skipspace(s);
}

SOURCE CODE TAKEN FROM git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git

LINKS. SOURCE AND OTHER
https://en.wikipedia.org/wiki/Machine-check_exception
http://www.mcelog.org/download.html
https://www.mcelog.org/
https://github.com/andikleen/mcelog
https://askubuntu.com/questions/605369/mce-hardware-error-machine-check-events-logged-appears-in-syslog-what-sho
https://en.wikipedia.org/wiki/Substring
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.ccrug00/strcspn.htm
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.3.0/com.ibm.zos.v2r3.ccrug00/strncmp.htm#strncmp