From 2efb3e7784c52d199fc21d9fcfaf709423800c75 Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Mon, 6 Feb 2017 21:43:59 -0600 Subject: Create a SEL error log Log the SEL data to the journal and call the commit interface to write the error log with the data. Change-Id: Ifcb842e37f2fdb14f80ab24651d565da05da47bf Signed-off-by: Adriana Kobylak --- Makefile.am | 6 +++--- configure.ac | 1 + storageaddsel.cpp | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 95faaf1..45860de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,8 @@ libapphandler_la_SOURCES = \ transporthandler.cpp \ globalhandler.cpp \ groupext.cpp -libapphandler_la_LDFLAGS = $(SYSTEMD_LIBS) $(libmapper_LIBS) -version-info 0:0:0 -shared -libapphandler_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS) +libapphandler_la_LDFLAGS = $(SYSTEMD_LIBS) $(libmapper_LIBS) $(PHOSPHOR_LOGGING_LIBS) -version-info 0:0:0 -shared +libapphandler_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS) $(PHOSPHOR_LOGGING_CFLAGS) libsysintfcmdsdir = ${libdir}/ipmid-providers libsysintfcmds_LTLIBRARIES = libsysintfcmds.la @@ -52,4 +52,4 @@ libhostservice_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS) nobase_include_HEADERS = \ host-ipmid/ipmid-api.h -SUBDIRS = test \ No newline at end of file +SUBDIRS = test diff --git a/configure.ac b/configure.ac index 5dc3e7f..daba2c5 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ AC_PROG_MAKE_SET # Checks for libraries. AC_CHECK_LIB([mapper], [mapper_get_service], ,[AC_MSG_ERROR([Could not find libmapper...openbmc/phosphor-objmgr package required])]) PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) +PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, [AC_MSG_ERROR([Could not find phosphor-logging...openbmc/phosphor-logging package required])]) # Checks for header files. AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])]) diff --git a/storageaddsel.cpp b/storageaddsel.cpp index 84e3092..0b40d47 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -8,12 +8,15 @@ #include #include #include +#include +#include #include "host-ipmid/ipmid-api.h" #include "sensorhandler.h" #include "storagehandler.h" using namespace std; +using namespace phosphor::logging; ////////////////////////// struct esel_section_headers_t { @@ -185,6 +188,26 @@ int send_esel_to_dbus(const char *desc, const char *sev, const char *details, ui const char *object_name = "/org/openbmc/records/events"; char *bus_name = NULL; + // Allocate enough space to represent the data in hex separated by spaces, + // to mimic how IPMI would display the data. + unique_ptr selData(new char[debuglen*3]()); + uint32_t i = 0; + for(i = 0; i < debuglen; i++) + { + sprintf(&selData[i*3], "%02x ", 0xFF & ((char*)debug)[i]); + } + log("Received Host Event", entry("ESEL=%s", selData.get())); + + try + { + elog( + prev_entry()); + } + catch (elogException& e) + { + commit(e.name()); + } + mbus = ipmid_get_sd_bus_connection(); r = mapper_get_service(mbus, object_name, &bus_name); if (r < 0) { -- cgit v1.2.1