krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/0009-ras-mc-ctl-report-errors-also-for-PCIe-AER-and-MCE.patch

ac32bf
From 4b64649eb5740027f58377f6c29d1554d9792b97 Mon Sep 17 00:00:00 2001
ac32bf
From: Mauro Carvalho Chehab <mchehab@redhat.com>
ac32bf
Date: Fri, 31 May 2013 16:16:44 -0300
ac32bf
Subject: [PATCH 09/32] ras-mc-ctl: report errors also for PCIe AER and MCE
ac32bf
ac32bf
Show also PCIe AER and MCE when used with --errors parameter.
ac32bf
ac32bf
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ac32bf
---
ac32bf
 util/ras-mc-ctl.in |   73 +++++++++++++++++++++++++++++++++++++++++++++++-----
ac32bf
 1 files changed, 66 insertions(+), 7 deletions(-)
ac32bf
ac32bf
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
ac32bf
index 118af7b..30d3078 100755
ac32bf
--- a/util/ras-mc-ctl.in
ac32bf
+++ b/util/ras-mc-ctl.in
ac32bf
@@ -883,22 +883,81 @@ sub summary
ac32bf
 sub errors
ac32bf
 {
ac32bf
     require DBI;
ac32bf
+    my ($query, $query_handle, $id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail, $out);
ac32bf
+    my ($mcgcap,$mcgstatus, $status, $misc, $ip, $tsc, $walltime, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $bank_name, $mcgstatus_msg, $mcistatus_msg, $user_action, $mc_location);
ac32bf
 
ac32bf
     my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", {});
ac32bf
 
ac32bf
-    my $query = "select id, timestamp, err_count, err_type, err_msg, label, mc, top_layer,middle_layer,lower_layer, address, grain, syndrome, driver_detail from mc_event order by id";
ac32bf
-
ac32bf
-    my $query_handle = $dbh->prepare($query);
ac32bf
+    # Memory controller mc_event errors
ac32bf
+    $query = "select id, timestamp, err_count, err_type, err_msg, label, mc, top_layer,middle_layer,lower_layer, address, grain, syndrome, driver_detail from mc_event order by id";
ac32bf
+    $query_handle = $dbh->prepare($query);
ac32bf
     $query_handle->execute();
ac32bf
+    $query_handle->bind_columns(\($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
ac32bf
+    $out = "";
ac32bf
+    while($query_handle->fetch()) {
ac32bf
+        $out .= "$id $time $count $type error(s): $msg at $label location: $mc:$top:$mid:$low, addr $addr, grain $grain, syndrome $syndrome $detail\n";
ac32bf
+    }
ac32bf
+    if ($out ne "") {
ac32bf
+        print "PCIe AER events:\n$out\n";
ac32bf
+    } else {
ac32bf
+        print "No PCIe AER errors.\n\n";
ac32bf
+    }
ac32bf
+    $query_handle->finish;
ac32bf
 
ac32bf
-    $query_handle->bind_columns(\my($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
ac32bf
-
ac32bf
-    print "Memory controller events:\n";
ac32bf
+    # PCIe AER aer_event errors
ac32bf
+    $query = "select id, timestamp, err_type, err_msg from aer_event order by id";
ac32bf
+    $query_handle = $dbh->prepare($query);
ac32bf
+    $query_handle->execute();
ac32bf
+    $query_handle->bind_columns(\($id, $time, $type, $msg));
ac32bf
+    $out = "";
ac32bf
     while($query_handle->fetch()) {
ac32bf
-        print "$id $time $count $type error(s): $msg at $label location: $mc:$top:$mid:$low, addr $addr, grain $grain, syndrome $syndrome $detail\n";
ac32bf
+        $out .= "$id $time $type error: $msg\n";
ac32bf
     }
ac32bf
+    if ($out ne "") {
ac32bf
+        print "MCE events:\n$out\n";
ac32bf
+    } else {
ac32bf
+        print "No MCE errors.\n\n";
ac32bf
+    }
ac32bf
+    $query_handle->finish;
ac32bf
 
ac32bf
+    # MCE mce_record errors
ac32bf
+    $query = "select id, timestamp, mcgcap, mcgstatus, status, addr, misc, ip, tsc, walltime, cpu, cpuid, apicid, socketid, cs, bank, cpuvendor, bank_name, error_msg, mcgstatus_msg, mcistatus_msg, user_action, mc_location from mce_record order by id";
ac32bf
+    $query_handle = $dbh->prepare($query);
ac32bf
+    $query_handle->execute();
ac32bf
+    $query_handle->bind_columns(\($id, $time, $mcgcap,$mcgstatus, $status, $addr, $misc, $ip, $tsc, $walltime, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $bank_name, $msg, $mcgstatus_msg, $mcistatus_msg, $user_action, $mc_location));
ac32bf
+    $out = "";
ac32bf
+    while($query_handle->fetch()) {
ac32bf
+        $out .= "$id $time error: $msg";
ac32bf
+	$out .= ", CPU $cpuvendor" if ($cpuvendor);
ac32bf
+	$out .= ", bank $bank_name" if ($bank_name);
ac32bf
+	$out .= ", mcg $mcgstatus_msg" if ($mcgstatus_msg);
ac32bf
+	$out .= ", mci $mcistatus_msg" if ($mcistatus_msg);
ac32bf
+	$out .= ", $mc_location" if ($mc_location);
ac32bf
+	$out .= ", $user_action" if ($user_action);
ac32bf
+	$out .= sprintf ", mcgcap=0x%08x", $mcgcap if ($mcgcap);
ac32bf
+	$out .= sprintf ", mcgstatus=0x%08x", $mcgstatus if ($mcgstatus);
ac32bf
+	$out .= sprintf ", status=0x%08x", $status if ($status);
ac32bf
+	$out .= sprintf ", addr=0x%08x", $addr if ($addr);
ac32bf
+	$out .= sprintf ", misc=0x%08x", $misc if ($misc);
ac32bf
+	$out .= sprintf ", ip=0x%08x", $ip if ($ip);
ac32bf
+	$out .= sprintf ", tsc=0x%08x", $tsc if ($tsc);
ac32bf
+	$out .= sprintf ", walltime=0x%08x", $walltime if ($walltime);
ac32bf
+	$out .= sprintf ", cpu=0x%08x", $cpu if ($cpu);
ac32bf
+	$out .= sprintf ", cpuid=0x%08x", $cpuid if ($cpuid);
ac32bf
+	$out .= sprintf ", apicid=0x%08x", $apicid if ($apicid);
ac32bf
+	$out .= sprintf ", socketid=0x%08x", $socketid if ($socketid);
ac32bf
+	$out .= sprintf ", cs=0x%08x", $cs if ($cs);
ac32bf
+	$out .= sprintf ", bank=0x%08x", $bank if ($bank);
ac32bf
+
ac32bf
+	$out .= "\n";
ac32bf
+    }
ac32bf
+    if ($out ne "") {
ac32bf
+        print "Memory controller events:\n$out\n";
ac32bf
+    } else {
ac32bf
+        print "No Memory errors.\n\n";
ac32bf
+    }
ac32bf
     $query_handle->finish;
ac32bf
+
ac32bf
     undef($dbh);
ac32bf
 }
ac32bf
 
ac32bf
-- 
ac32bf
1.7.1
ac32bf