|
|
b404a9 |
From d3ac6c888953d0bcd304d30dfa0f1c731987f358 Mon Sep 17 00:00:00 2001
|
|
|
b404a9 |
From: Denys Vlasenko <dvlasenk@redhat.com>
|
|
|
b404a9 |
Date: Mon, 6 Jan 2014 16:46:48 +0100
|
|
|
b404a9 |
Subject: [ABRT PATCH 20/27] move MCE handling in event to
|
|
|
b404a9 |
abrt-action-check-oops-for-hw-error
|
|
|
b404a9 |
|
|
|
b404a9 |
Having a separate tool should help with internationalization
|
|
|
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 |
configure.ac | 1 +
|
|
|
b404a9 |
doc/Makefile.am | 1 +
|
|
|
b404a9 |
po/POTFILES.in | 1 +
|
|
|
b404a9 |
src/plugins/Makefile.am | 3 +
|
|
|
b404a9 |
src/plugins/abrt-action-check-oops-for-hw-error.in | 118 +++++++++++++++++++++
|
|
|
b404a9 |
src/plugins/koops_event.conf | 57 +---------
|
|
|
b404a9 |
8 files changed, 129 insertions(+), 55 deletions(-)
|
|
|
b404a9 |
create mode 100644 src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
|
|
|
b404a9 |
diff --git a/configure.ac b/configure.ac
|
|
|
b404a9 |
index 3bd13bc..346faa8 100644
|
|
|
b404a9 |
--- a/configure.ac
|
|
|
b404a9 |
+++ b/configure.ac
|
|
|
b404a9 |
@@ -279,6 +279,7 @@ AC_CONFIG_FILES([
|
|
|
b404a9 |
src/dbus/Makefile
|
|
|
b404a9 |
src/plugins/abrt-action-install-debuginfo
|
|
|
b404a9 |
src/plugins/abrt-action-analyze-vmcore
|
|
|
b404a9 |
+ src/plugins/abrt-action-check-oops-for-hw-error
|
|
|
b404a9 |
src/python-problem/Makefile
|
|
|
b404a9 |
src/python-problem/doc/Makefile
|
|
|
b404a9 |
src/python-problem/tests/Makefile
|
|
|
b404a9 |
diff --git a/doc/Makefile.am b/doc/Makefile.am
|
|
|
b404a9 |
index f1abef8..e76abde 100644
|
|
|
b404a9 |
--- a/doc/Makefile.am
|
|
|
b404a9 |
+++ b/doc/Makefile.am
|
|
|
b404a9 |
@@ -32,6 +32,7 @@ MAN1_TXT += abrt-action-save-package-data.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-action-save-kernel-data.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-install-ccpp-hook.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-action-analyze-vmcore.txt
|
|
|
b404a9 |
+MAN1_TXT += abrt-action-check-oops-for-hw-error.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-action-analyze-ccpp-local.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-watch-log.txt
|
|
|
b404a9 |
MAN1_TXT += abrt-upload-watch.txt
|
|
|
b404a9 |
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
|
|
b404a9 |
index 5f883c0..6d90162 100644
|
|
|
b404a9 |
--- a/po/POTFILES.in
|
|
|
b404a9 |
+++ b/po/POTFILES.in
|
|
|
b404a9 |
@@ -25,6 +25,7 @@ src/plugins/abrt-action-analyze-oops.c
|
|
|
b404a9 |
src/plugins/abrt-action-analyze-xorg.c
|
|
|
b404a9 |
src/plugins/abrt-action-analyze-python.c
|
|
|
b404a9 |
src/plugins/abrt-action-analyze-vmcore.in
|
|
|
b404a9 |
+src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
src/plugins/abrt-action-generate-backtrace.c
|
|
|
b404a9 |
src/plugins/abrt-action-generate-core-backtrace.c
|
|
|
b404a9 |
src/plugins/abrt-action-install-debuginfo.in
|
|
|
b404a9 |
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
|
|
|
b404a9 |
index 60246f2..dd32c7d 100644
|
|
|
b404a9 |
--- a/src/plugins/Makefile.am
|
|
|
b404a9 |
+++ b/src/plugins/Makefile.am
|
|
|
b404a9 |
@@ -5,6 +5,7 @@ bin_SCRIPTS = \
|
|
|
b404a9 |
abrt-action-analyze-core \
|
|
|
b404a9 |
abrt-action-analyze-vulnerability \
|
|
|
b404a9 |
abrt-action-analyze-vmcore \
|
|
|
b404a9 |
+ abrt-action-check-oops-for-hw-error \
|
|
|
b404a9 |
abrt-action-list-dsos \
|
|
|
b404a9 |
abrt-action-perform-ccpp-analysis \
|
|
|
b404a9 |
abrt-action-save-kernel-data \
|
|
|
b404a9 |
@@ -74,6 +75,7 @@ PYTHON_FILES = \
|
|
|
b404a9 |
abrt-action-analyze-core \
|
|
|
b404a9 |
abrt-action-analyze-vulnerability \
|
|
|
b404a9 |
abrt-action-analyze-vmcore.in \
|
|
|
b404a9 |
+ abrt-action-check-oops-for-hw-error.in \
|
|
|
b404a9 |
abrt-action-perform-ccpp-analysis.in \
|
|
|
b404a9 |
abrt-action-notify
|
|
|
b404a9 |
|
|
|
b404a9 |
@@ -88,6 +90,7 @@ EXTRA_DIST = \
|
|
|
b404a9 |
analyze_RetraceServer.xml.in \
|
|
|
b404a9 |
analyze_VMcore.xml.in \
|
|
|
b404a9 |
abrt-action-analyze-vmcore \
|
|
|
b404a9 |
+ abrt-action-check-oops-for-hw-error \
|
|
|
b404a9 |
abrt-action-save-kernel-data \
|
|
|
b404a9 |
abrt-action-ureport \
|
|
|
b404a9 |
abrt-gdb-exploitable \
|
|
|
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 |
new file mode 100644
|
|
|
b404a9 |
index 0000000..83c0f22
|
|
|
b404a9 |
--- /dev/null
|
|
|
b404a9 |
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
|
|
|
b404a9 |
@@ -0,0 +1,118 @@
|
|
|
b404a9 |
+#!/usr/bin/python -u
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+import sys
|
|
|
b404a9 |
+import os
|
|
|
b404a9 |
+import locale
|
|
|
b404a9 |
+import gettext
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+GETTEXT_PROGNAME = "abrt"
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+_ = gettext.lgettext
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+def file_has_string(filename, string):
|
|
|
b404a9 |
+ try:
|
|
|
b404a9 |
+ f = open(filename, "r")
|
|
|
b404a9 |
+ except IOError as e:
|
|
|
b404a9 |
+ #print e
|
|
|
b404a9 |
+ return False
|
|
|
b404a9 |
+ for line in f:
|
|
|
b404a9 |
+ if string in line:
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
+ return True
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
+ return False
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+def tail_with_search(filename, string, maxlen):
|
|
|
b404a9 |
+ try:
|
|
|
b404a9 |
+ f = open(filename, "r")
|
|
|
b404a9 |
+ except IOError as e:
|
|
|
b404a9 |
+ #print e
|
|
|
b404a9 |
+ return []
|
|
|
b404a9 |
+ l = []
|
|
|
b404a9 |
+ for line in f:
|
|
|
b404a9 |
+ if string in line:
|
|
|
b404a9 |
+ l.append(line)
|
|
|
b404a9 |
+ if len(l) > maxlen:
|
|
|
b404a9 |
+ del l[0]
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
+ return l
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+if __name__ == "__main__":
|
|
|
b404a9 |
+ try:
|
|
|
b404a9 |
+ locale.setlocale(locale.LC_ALL, "")
|
|
|
b404a9 |
+ except locale.Error:
|
|
|
b404a9 |
+ os.environ['LC_ALL'] = 'C'
|
|
|
b404a9 |
+ locale.setlocale(locale.LC_ALL, "")
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+ # Defeat "AttributeError: 'module' object has no attribute 'nl_langinfo'"
|
|
|
b404a9 |
+ try:
|
|
|
b404a9 |
+ gettext.bind_textdomain_codeset(GETTEXT_PROGNAME,
|
|
|
b404a9 |
+ locale.nl_langinfo(locale.CODESET))
|
|
|
b404a9 |
+ except AttributeError:
|
|
|
b404a9 |
+ pass
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+ gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale')
|
|
|
b404a9 |
+ gettext.textdomain(GETTEXT_PROGNAME)
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+ #
|
|
|
b404a9 |
+ # So far we only look for Machine Check Exceptions here.
|
|
|
b404a9 |
+ #
|
|
|
b404a9 |
+
|
|
|
b404a9 |
+ # See if MCEs were seen
|
|
|
b404a9 |
+ if not file_has_string("dmesg", "Machine check events logged"):
|
|
|
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.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.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 |
+ f.write("=========================================\n")
|
|
|
b404a9 |
+ #tail -n20 /var/log/mcelog 2>&1
|
|
|
b404a9 |
+ l = tail_with_search("/var/log/mcelog", "", 20)
|
|
|
b404a9 |
+ for line in l:
|
|
|
b404a9 |
+ f.write(line)
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
+ sys.exit(0)
|
|
|
b404a9 |
+ #
|
|
|
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.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 |
+ f.write("==========================================\n")
|
|
|
b404a9 |
+ #grep -Fi 'mcelog:' /var/log/messages | tail -n20 2>&1
|
|
|
b404a9 |
+ l = tail_with_search("/var/log/messages", "mcelog:", 20)
|
|
|
b404a9 |
+ for line in l:
|
|
|
b404a9 |
+ f.write(line)
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
+ sys.exit(0)
|
|
|
b404a9 |
+ #
|
|
|
b404a9 |
+ # Apparently, there is no running mcelog daemon!
|
|
|
b404a9 |
+ # Let user know that he needs one.
|
|
|
b404a9 |
+ f = open("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 |
+ f.write("Most likely reason is that mcelog is not installed or not configured\n")
|
|
|
b404a9 |
+ f.write("to be started during boot.\n")
|
|
|
b404a9 |
+ f.write("Without this tool running, the binary data saved by kernel\n")
|
|
|
b404a9 |
+ f.write("is of limited usefulness.\n")
|
|
|
b404a9 |
+ f.write("(You can save this data anyway by running 'cat </dev/mcelog >FILE').\n")
|
|
|
b404a9 |
+ f.write("The recommended course of action is to install mcelog.\n")
|
|
|
b404a9 |
+ f.write("If another hardware error would occur, a user-readable description\n")
|
|
|
b404a9 |
+ f.write("of it will be saved in system log or /var/log/mcelog.\n")
|
|
|
b404a9 |
+ f.close()
|
|
|
b404a9 |
diff --git a/src/plugins/koops_event.conf b/src/plugins/koops_event.conf
|
|
|
b404a9 |
index 7dfbe36..3740f65 100644
|
|
|
b404a9 |
--- a/src/plugins/koops_event.conf
|
|
|
b404a9 |
+++ b/src/plugins/koops_event.conf
|
|
|
b404a9 |
@@ -3,61 +3,8 @@ EVENT=post-create analyzer=Kerneloops
|
|
|
b404a9 |
# >> instead of > is due to bugzilla.redhat.com/show_bug.cgi?id=854266
|
|
|
b404a9 |
abrt-action-analyze-oops &&
|
|
|
b404a9 |
dmesg >>dmesg &&
|
|
|
b404a9 |
- abrt-action-save-kernel-data
|
|
|
b404a9 |
- abrt-action-save-kernel-data || exit $?
|
|
|
b404a9 |
- #
|
|
|
b404a9 |
- # If it exists, we can save a copy of MCE log here:
|
|
|
b404a9 |
- #test -f /var/log/mcelog && cp /var/log/mcelog .
|
|
|
b404a9 |
- # but in current config, sosreport already does that.
|
|
|
b404a9 |
- #
|
|
|
b404a9 |
- # See if MCEs were seen but mcelog isn't installed or running
|
|
|
b404a9 |
- grep -qFi 'Machine check events logged' dmesg || exit 0
|
|
|
b404a9 |
- #
|
|
|
b404a9 |
- # There was an MCE. IOW: it's not a bug, it's a HW error.
|
|
|
b404a9 |
- # Did mcelog logged it to /var/log/mcelog
|
|
|
b404a9 |
- # (RHEL6 by default does this)?
|
|
|
b404a9 |
- test -f /var/log/mcelog &&
|
|
|
b404a9 |
- {
|
|
|
b404a9 |
- # (Ab)use user comment field to inform user about it.
|
|
|
b404a9 |
- echo "The kernel log indicates that hardware errors were detected."
|
|
|
b404a9 |
- echo "/var/log/mcelog file may have more information."
|
|
|
b404a9 |
- echo "The last 20 lines of /var/log/mcelog are:"
|
|
|
b404a9 |
- echo "========================================="
|
|
|
b404a9 |
- # Redirecting sterr in case selinux makes it unreadable
|
|
|
b404a9 |
- # (annoying anyway, but at least user knows what's going on):
|
|
|
b404a9 |
- tail -n20 /var/log/mcelog 2>&1
|
|
|
b404a9 |
- exit 0
|
|
|
b404a9 |
- } >comment
|
|
|
b404a9 |
- #
|
|
|
b404a9 |
- # On RHEL7, mcelog is run so that its output ends up in syslog.
|
|
|
b404a9 |
- # Do we see that?
|
|
|
b404a9 |
- grep -qFi 'mcelog: Hardware event' /var/log/messages &&
|
|
|
b404a9 |
- {
|
|
|
b404a9 |
- echo "The kernel log indicates that hardware errors were detected."
|
|
|
b404a9 |
- echo "System log may have more information."
|
|
|
b404a9 |
- echo "The last 20 mcelog lines of system log are:"
|
|
|
b404a9 |
- echo "========================================="
|
|
|
b404a9 |
- # Redirecting sterr in case selinux makes it unreadable
|
|
|
b404a9 |
- # (annoying anyway, but at least user knows what's going on):
|
|
|
b404a9 |
- grep -Fi 'mcelog:' /var/log/messages | tail -n20 2>&1
|
|
|
b404a9 |
- exit 0
|
|
|
b404a9 |
- } >comment
|
|
|
b404a9 |
- #
|
|
|
b404a9 |
- # Apparently, there is no running mcelog daemon!
|
|
|
b404a9 |
- # Let user know that he needs one.
|
|
|
b404a9 |
- {
|
|
|
b404a9 |
- echo "The kernel log indicates that hardware errors were detected."
|
|
|
b404a9 |
- echo "The data was saved by kernel for processing by the mcelog tool."
|
|
|
b404a9 |
- echo "However, neither /var/log/mcelog nor system log contain mcelog messages."
|
|
|
b404a9 |
- echo "Most likely reason is that mcelog is not installed or not configured"
|
|
|
b404a9 |
- echo "to be started during boot."
|
|
|
b404a9 |
- echo "Without this tool running, the binary data saved by kernel"
|
|
|
b404a9 |
- echo "is of limited usefulness."
|
|
|
b404a9 |
- echo "(You can save this data anyway by running 'cat </dev/mcelog >FILE')."
|
|
|
b404a9 |
- echo "The recommended course of action is to install mcelog."
|
|
|
b404a9 |
- echo "If another hardware error would occur, a user-readable description"
|
|
|
b404a9 |
- echo "of it will be saved in system log or /var/log/mcelog."
|
|
|
b404a9 |
- } >comment
|
|
|
b404a9 |
+ abrt-action-save-kernel-data &&
|
|
|
b404a9 |
+ abrt-action-check-oops-for-hw-error
|
|
|
b404a9 |
|
|
|
b404a9 |
# If you want behavior similar to one provided by kerneloops daemon
|
|
|
b404a9 |
# distributed by kerneloops.org - that is, if you want
|
|
|
b404a9 |
--
|
|
|
b404a9 |
1.8.3.1
|
|
|
b404a9 |
|