summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Alekseev (IBS Group) <ealekseev@ibs.sila.ru>2022-08-03 17:20:02 +0300
committerAndrey V.Kosteltsev <AKosteltsev@IBS.RU>2022-08-04 16:28:58 +0300
commiteb6d9624a539cf9f996e039e3eb2dbc7fd6de177 (patch)
tree32110ada34577d7caee8b6880676025f7640f9f7
parent18d33dc0ae0a3fc23ed978d597801a7c2349fd64 (diff)
downloadopenbmc-eb6d9624a539cf9f996e039e3eb2dbc7fd6de177.tar.xz
IBS: rsyslog add redfish2phosphor logs
-rwxr-xr-xmeta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/redfish2phosphor-logs.sh33
-rw-r--r--meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.conf33
-rw-r--r--meta-ibs/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend6
3 files changed, 72 insertions, 0 deletions
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
+# "<Message>$<PRIORITY>$<RedfishId>$<REDFISH_MESSAGE_ARGS>"
+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
# "<timestamp> <MessageId>,<MessageArgs>"
template(name="CrashTemplate" type="list") {
@@ -55,6 +71,20 @@ template(name="CrashTemplate" type="list") {
constant(value="\n")
}
+# Template for Application Crashes + Redfish ID
+# "<Message>$<PRIORITY>$<RedfishId>$<REDFISH_MESSAGE_ARGS>"
+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
}