krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone
Blob Blame History Raw
From 4b64649eb5740027f58377f6c29d1554d9792b97 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Date: Fri, 31 May 2013 16:16:44 -0300
Subject: [PATCH 09/32] ras-mc-ctl: report errors also for PCIe AER and MCE

Show also PCIe AER and MCE when used with --errors parameter.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 util/ras-mc-ctl.in |   73 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
index 118af7b..30d3078 100755
--- a/util/ras-mc-ctl.in
+++ b/util/ras-mc-ctl.in
@@ -883,22 +883,81 @@ sub summary
 sub errors
 {
     require DBI;
+    my ($query, $query_handle, $id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail, $out);
+    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);
 
     my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", {});
 
-    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";
-
-    my $query_handle = $dbh->prepare($query);
+    # Memory controller mc_event errors
+    $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";
+    $query_handle = $dbh->prepare($query);
     $query_handle->execute();
+    $query_handle->bind_columns(\($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
+    $out = "";
+    while($query_handle->fetch()) {
+        $out .= "$id $time $count $type error(s): $msg at $label location: $mc:$top:$mid:$low, addr $addr, grain $grain, syndrome $syndrome $detail\n";
+    }
+    if ($out ne "") {
+        print "PCIe AER events:\n$out\n";
+    } else {
+        print "No PCIe AER errors.\n\n";
+    }
+    $query_handle->finish;
 
-    $query_handle->bind_columns(\my($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
-
-    print "Memory controller events:\n";
+    # PCIe AER aer_event errors
+    $query = "select id, timestamp, err_type, err_msg from aer_event order by id";
+    $query_handle = $dbh->prepare($query);
+    $query_handle->execute();
+    $query_handle->bind_columns(\($id, $time, $type, $msg));
+    $out = "";
     while($query_handle->fetch()) {
-        print "$id $time $count $type error(s): $msg at $label location: $mc:$top:$mid:$low, addr $addr, grain $grain, syndrome $syndrome $detail\n";
+        $out .= "$id $time $type error: $msg\n";
     }
+    if ($out ne "") {
+        print "MCE events:\n$out\n";
+    } else {
+        print "No MCE errors.\n\n";
+    }
+    $query_handle->finish;
 
+    # MCE mce_record errors
+    $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";
+    $query_handle = $dbh->prepare($query);
+    $query_handle->execute();
+    $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));
+    $out = "";
+    while($query_handle->fetch()) {
+        $out .= "$id $time error: $msg";
+	$out .= ", CPU $cpuvendor" if ($cpuvendor);
+	$out .= ", bank $bank_name" if ($bank_name);
+	$out .= ", mcg $mcgstatus_msg" if ($mcgstatus_msg);
+	$out .= ", mci $mcistatus_msg" if ($mcistatus_msg);
+	$out .= ", $mc_location" if ($mc_location);
+	$out .= ", $user_action" if ($user_action);
+	$out .= sprintf ", mcgcap=0x%08x", $mcgcap if ($mcgcap);
+	$out .= sprintf ", mcgstatus=0x%08x", $mcgstatus if ($mcgstatus);
+	$out .= sprintf ", status=0x%08x", $status if ($status);
+	$out .= sprintf ", addr=0x%08x", $addr if ($addr);
+	$out .= sprintf ", misc=0x%08x", $misc if ($misc);
+	$out .= sprintf ", ip=0x%08x", $ip if ($ip);
+	$out .= sprintf ", tsc=0x%08x", $tsc if ($tsc);
+	$out .= sprintf ", walltime=0x%08x", $walltime if ($walltime);
+	$out .= sprintf ", cpu=0x%08x", $cpu if ($cpu);
+	$out .= sprintf ", cpuid=0x%08x", $cpuid if ($cpuid);
+	$out .= sprintf ", apicid=0x%08x", $apicid if ($apicid);
+	$out .= sprintf ", socketid=0x%08x", $socketid if ($socketid);
+	$out .= sprintf ", cs=0x%08x", $cs if ($cs);
+	$out .= sprintf ", bank=0x%08x", $bank if ($bank);
+
+	$out .= "\n";
+    }
+    if ($out ne "") {
+        print "Memory controller events:\n$out\n";
+    } else {
+        print "No Memory errors.\n\n";
+    }
     $query_handle->finish;
+
     undef($dbh);
 }
 
-- 
1.7.1