|
|
b404a9 |
From 56c3d6950f300e98460fe196e0fe138f89ead83d Mon Sep 17 00:00:00 2001
|
|
|
b404a9 |
From: Denys Vlasenko <dvlasenk@redhat.com>
|
|
|
b404a9 |
Date: Mon, 6 Jan 2014 16:47:52 +0100
|
|
|
b404a9 |
Subject: [ABRT PATCH 21/27] abrt-action-check-oops-for-hw-error: i18n, add
|
|
|
b404a9 |
error check on open()
|
|
|
b404a9 |
|
|
|
b404a9 |
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
|
|
|
b404a9 |
|
|
|
b404a9 |
Related to rhbz#1032077
|
|
|
b404a9 |
|
|
|
b404a9 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
b404a9 |
---
|
|
|
b404a9 |
src/plugins/abrt-action-check-oops-for-hw-error.in | 23 ++++++++++++++++------
|
|
|
b404a9 |
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
|
b404a9 |
|
|
|
b404a9 |
diff --git a/src/plugins/abrt-action-check-oops-for-hw-error.in b/src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
index 83c0f22..ce13caf 100644
|
|
|
b404a9 |
--- a/src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
@@ -39,6 +39,15 @@ def tail_with_search(filename, string, maxlen):
|
|
|
b404a9 |
return l
|
|
|
b404a9 |
|
|
|
b404a9 |
|
|
|
b404a9 |
+def open_or_die(filename, mode):
|
|
|
b404a9 |
+ try:
|
|
|
b404a9 |
+ f = open(filename, mode)
|
|
|
b404a9 |
+ except IOError as e:
|
|
|
b404a9 |
+ sys.stderr.write(str(e) + "\n")
|
|
|
b404a9 |
+ sys.exit(1)
|
|
|
b404a9 |
+ return f
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+
|
|
|
b404a9 |
if __name__ == "__main__":
|
|
|
b404a9 |
try:
|
|
|
b404a9 |
locale.setlocale(locale.LC_ALL, "")
|
|
|
b404a9 |
@@ -65,16 +74,18 @@ if __name__ == "__main__":
|
|
|
b404a9 |
sys.exit(0)
|
|
|
b404a9 |
#
|
|
|
b404a9 |
# There was an MCE. IOW: it's not a bug, it's a HW error.
|
|
|
b404a9 |
- f = open("not-reportable", "w")
|
|
|
b404a9 |
- f.write("The kernel log indicates that hardware errors were detected.\n");
|
|
|
b404a9 |
- f.write("This is most likely not a software problem.\n");
|
|
|
b404a9 |
+ f = open_or_die("not-reportable", "w")
|
|
|
b404a9 |
+ f.write(_(
|
|
|
b404a9 |
+ "The kernel log indicates that hardware errors were detected.\n"
|
|
|
b404a9 |
+ "This is most likely not a software problem.\n"
|
|
|
b404a9 |
+ ))
|
|
|
b404a9 |
f.close()
|
|
|
b404a9 |
|
|
|
b404a9 |
#
|
|
|
b404a9 |
# Did mcelog logged it to /var/log/mcelog
|
|
|
b404a9 |
# (RHEL6 by default does this)?
|
|
|
b404a9 |
if os.path.exists("/var/log/mcelog"):
|
|
|
b404a9 |
- f = open("comment", "w")
|
|
|
b404a9 |
+ f = open_or_die("comment", "w")
|
|
|
b404a9 |
f.write("The kernel log indicates that hardware errors were detected.\n")
|
|
|
b404a9 |
f.write("/var/log/mcelog file may have more information.\n")
|
|
|
b404a9 |
f.write("The last 20 lines of /var/log/mcelog are:\n")
|
|
|
b404a9 |
@@ -89,7 +100,7 @@ if __name__ == "__main__":
|
|
|
b404a9 |
# On RHEL7, mcelog is run so that its output ends up in syslog.
|
|
|
b404a9 |
# Do we see that?
|
|
|
b404a9 |
if file_has_string("/var/log/messages", "mcelog: Hardware event"):
|
|
|
b404a9 |
- f = open("comment", "w")
|
|
|
b404a9 |
+ f = open_or_die("comment", "w")
|
|
|
b404a9 |
f.write("The kernel log indicates that hardware errors were detected.\n")
|
|
|
b404a9 |
f.write("System log may have more information.\n")
|
|
|
b404a9 |
f.write("The last 20 mcelog lines of system log are:\n")
|
|
|
b404a9 |
@@ -103,7 +114,7 @@ if __name__ == "__main__":
|
|
|
b404a9 |
#
|
|
|
b404a9 |
# Apparently, there is no running mcelog daemon!
|
|
|
b404a9 |
# Let user know that he needs one.
|
|
|
b404a9 |
- f = open("comment", "w")
|
|
|
b404a9 |
+ f = open_or_die("comment", "w")
|
|
|
b404a9 |
f.write("The kernel log indicates that hardware errors were detected.\n")
|
|
|
b404a9 |
f.write("The data was saved by kernel for processing by the mcelog tool.\n")
|
|
|
b404a9 |
f.write("However, neither /var/log/mcelog nor system log contain mcelog messages.\n")
|
|
|
b404a9 |
--
|
|
|
b404a9 |
1.8.3.1
|
|
|
b404a9 |
|