krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/0027-ras-mc-ctl-Print-useful-message-when-run-without-ras.patch

ac32bf
From caa44c3946ddc900896830297c28b90ce5b9034b Mon Sep 17 00:00:00 2001
ac32bf
From: Betty Dall <betty.dall@hp.com>
ac32bf
Date: Wed, 19 Mar 2014 15:54:56 -0600
ac32bf
Subject: [PATCH 27/32] ras-mc-ctl: Print useful message when run without rasdaemon -r
ac32bf
ac32bf
The utility script ras-mc-ctl requires that rasdaemon --record be run
ac32bf
to create the me_event table in the SQLite database. The current behaviour
ac32bf
is this:
ac32bf
[root@sa1 util]# ras-mc-ctl --errors
ac32bf
DBD::SQLite::db prepare failed: no such table: mc_event at
ac32bf
/usr/local/sbin/ras-mc-ctl line 914.
ac32bf
Can't call method "execute" on an undefined value at
ac32bf
/usr/local/sbin/ras-mc-ctl line 915.
ac32bf
ac32bf
With this change, the user sees:
ac32bf
[root@sa1 util]# ras-mc-ctl --errors
ac32bf
DBD::SQLite::db prepare failed: no such table: mc_event at
ac32bf
/usr/local/sbin/ras-mc-ctl line 914.
ac32bf
ras-mc-ctl: Error: mc_event table missing from
ac32bf
/usr/local/var/lib/rasdaemon/ras-mc_event.db. Run 'rasdaemon --record'.
ac32bf
ac32bf
Signed-off-by: Betty Dall <betty.dall@hp.com>
ac32bf
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
ac32bf
---
ac32bf
 util/ras-mc-ctl.in |    4 ++++
ac32bf
 1 files changed, 4 insertions(+), 0 deletions(-)
ac32bf
ac32bf
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
ac32bf
index 196a643..e9f9c59 100755
ac32bf
--- a/util/ras-mc-ctl.in
ac32bf
+++ b/util/ras-mc-ctl.in
ac32bf
@@ -912,6 +912,10 @@ sub errors
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
+    if (!$query_handle) {
ac32bf
+        log_error ("mc_event table missing from $dbname. Run 'rasdaemon --record'.\n");
ac32bf
+        exit -1
ac32bf
+    }
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
-- 
ac32bf
1.7.1
ac32bf