File: //scripts.20110531.215904.25158/oopscheck
#!/usr/bin/perl
# cpanel - oopscheck Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::iContact qw( );
chomp($hostname = `hostname`);
$inoops=0;
@DMESG=split(/\n/,`dmesg`);
foreach $_ (@DMESG) {
s/\n|\r//g;
if ( /^EIP/ || ((/invalid operand: /i || /Unable to handle/i) && !/^PCI/)) {
$inoops = 1;
}
if ($inoops) {
$oops .= $_ . "\n";
}
if (/^code:/i) {
$inoops = 0;
}
}
if ($oops ne "") {
$subject = "[oopscheck] KERNEL Oops on ${hostname} !!!";
$msg .= "IMPORTANT: Do not ignore this email.\n";
$msg .= "Your kernel had an Oops!\n\n";
$msg .= "This is the result of bad hardware or a kernel bug.\n";
$msg .= "Your system may continue to function as normal, however\n";
$msg .= "there is a good chance bad things are happening right now.\n";
$msg .= "\tBad things include: files disappearing, daemons crashing,\n";
$msg .= "\tcomplete server crashs, disk corruption and many others.\n\n";
$msg .= "You might want to check your RAM with memtest86 as this is\n";
$msg .= "usually the cause of the problem.\n";
$msg .= "\thttp://www.memtest86.com/\n\n";
$msg .= "The Oops is below:\n";
$msg .= "$oops\n";
Cpanel::iContact::icontact('application' => 'oopscheck',
'level' => 1,
'subject' => $subject,
'message' => $msg,
'msgtype' => '');
print "Oops detected .. sent email\n";
}