From eb6d9624a539cf9f996e039e3eb2dbc7fd6de177 Mon Sep 17 00:00:00 2001 From: "Evgeny Alekseev (IBS Group)" Date: Wed, 3 Aug 2022 17:20:02 +0300 Subject: IBS: rsyslog add redfish2phosphor logs --- .../rsyslog/rsyslog/redfish2phosphor-logs.sh | 33 ++++++++++++++++++++++ .../recipes-extended/rsyslog/rsyslog/rsyslog.conf | 33 ++++++++++++++++++++++ .../recipes-extended/rsyslog/rsyslog_%.bbappend | 6 ++++ 3 files changed, 72 insertions(+) create mode 100755 meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/redfish2phosphor-logs.sh diff --git a/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/redfish2phosphor-logs.sh b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/redfish2phosphor-logs.sh new file mode 100755 index 0000000000..4dd757dc3c --- /dev/null +++ b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/redfish2phosphor-logs.sh @@ -0,0 +1,33 @@ +#!/bin/bash +DBG_OUTPUT=/dev/null +. /etc/default/redfish/error-types.conf +STR_SEVERITIES=("xyz.openbmc_project.Logging.Entry.Level.Emergency"\ + "xyz.openbmc_project.Logging.Entry.Level.Alert"\ + "xyz.openbmc_project.Logging.Entry.Level.Critical"\ + "xyz.openbmc_project.Logging.Entry.Level.Error"\ + "xyz.openbmc_project.Logging.Entry.Level.Warning"\ + "xyz.openbmc_project.Logging.Entry.Level.Notice"\ + "xyz.openbmc_project.Logging.Entry.Level.Informational"\ + "xyz.openbmc_project.Logging.Entry.Level.Debug") +echo $1 >> $DBG_OUTPUT +IFS='$' read -ra PARAMS <<< "$1" +SEVERITY=$((${PARAMS[1]})) +echo ${PARAMS[0]} >> $DBG_OUTPUT +echo ${PARAMS[1]} >> $DBG_OUTPUT +echo ${PARAMS[2]} >> $DBG_OUTPUT +echo ${PARAMS[3]} >> $DBG_OUTPUT +SUBSTR=$(echo ${PARAMS[2]} | cut -b 13-) +echo $SUBSTR >> $DBG_OUTPUT +echo ${STR_SEVERITIES[${ERR_TYPE_MAP[$SUBSTR]}]} >> $DBG_OUTPUT +IFS=',' read -ra REDFISH_ARGS <<< ${PARAMS[3]} +FORMAT_STR="${ERR_STR_MAP[$SUBSTR]}" +echo $FORMAT_STR >> $DBG_OUTPUT +echo ${REDFISH_ARGS[@]} >> $DBG_OUTPUT +MESSAGE="$(printf "$FORMAT_STR" "${REDFISH_ARGS[@]}")" +echo $MESSAGE >> $DBG_OUTPUT +if [ -n "$MESSAGE" ] +then + busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create Create ssa{ss} "$MESSAGE" "${STR_SEVERITIES[${ERR_TYPE_MAP[$SUBSTR]}]}" 0 +else + echo "Unknown journal entry: $1" | systemd-cat -p 4 -t rsyslog2redfish +fi diff --git a/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.conf b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.conf index 46a287eefb..fa073a8479 100644 --- a/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.conf +++ b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.conf @@ -7,6 +7,7 @@ # # Ported from debian's sysklogd.conf + # Journal-style logging # Limit to no more than 2000 entries in one minute and enable the # journal workaround to avoid duplicate entries @@ -44,6 +45,21 @@ template(name="RedfishTemplate" type="list") { constant(value="\n") } +# Template for Redfish messages to phosphor +# "$$$" +template(name="RedfishPhosphorTemplate" type="list") { +# property(name="timereported" dateFormat="rfc3339") +# constant(value=" ") + property(name="$!MESSAGE") + constant(value="$") + property(name="$!PRIORITY") + constant(value="$") + property(name="$!REDFISH_MESSAGE_ID") + constant(value="$") + property(name="$!REDFISH_MESSAGE_ARGS") + constant(value="\n") +} + # Template for Application Crashes # " ," template(name="CrashTemplate" type="list") { @@ -55,6 +71,20 @@ template(name="CrashTemplate" type="list") { constant(value="\n") } +# Template for Application Crashes + Redfish ID +# "$$$" +template(name="CrashTemplateRedfish" type="list") { + property(name="$!MESSAGE") + constant(value="$") + property(name="$!PRIORITY") + constant(value="$") + constant(value="OpenBMC.0.1.ServiceFailure") + constant(value="$") + property(name="$!UNIT") + constant(value="\n") +} + + # If the journal entry has the IPMI SEL MESSAGE_ID, save as IPMI SEL # The MESSAGE_ID string is generated using journalctl and must match the @@ -66,11 +96,14 @@ if ($!MESSAGE_ID == "b370836ccf2f4850ac5bee185b77893a") then { # If the journal entry has a Redfish MessageId, save as a Redfish event if ($!REDFISH_MESSAGE_ID != "") then { action(type="omfile" file="/var/log/redfish" template="RedfishTemplate") + ^/usr/sbin/redfish2phosphor-logs.sh;RedfishPhosphorTemplate } + # If the journal entry has a Exit Code, save as a Redfish event if ($!EXIT_STATUS != "" and $!EXIT_STATUS != "0") then { action(type="omfile" file="/var/log/redfish" template="CrashTemplate") + ^/usr/sbin/redfish2phosphor-logs.sh;CrashTemplateRedfish } # diff --git a/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend index 20cbaf8cd7..4d2b4b0d01 100644 --- a/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend +++ b/meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend @@ -5,12 +5,17 @@ SRC_URI += "file://rsyslog.conf \ file://rotate-event-logs.service \ file://rotate-event-logs.sh \ file://rsyslog-override.conf \ + file://redfish2phosphor-logs.sh \ " FILES:${PN} += "${systemd_system_unitdir}/rsyslog.service.d/rsyslog-override.conf" PACKAGECONFIG:append = " imjournal" +RDEPENDS:${PN}:append = " \ + bash \ +" + do_install:append() { install -m 0644 ${WORKDIR}/rotate-event-logs.service ${D}${systemd_system_unitdir} install -d ${D}${systemd_system_unitdir}/rsyslog.service.d @@ -18,6 +23,7 @@ do_install:append() { ${D}${systemd_system_unitdir}/rsyslog.service.d/rsyslog-override.conf install -d ${D}${bindir} install -m 0755 ${WORKDIR}/rotate-event-logs.sh ${D}/${bindir}/rotate-event-logs.sh + install -m 0755 ${WORKDIR}/redfish2phosphor-logs.sh ${D}/${sbindir}/redfish2phosphor-logs.sh rm ${D}${sysconfdir}/rsyslog.d/imjournal.conf } -- cgit v1.2.3