From 299a60e0ddea4e964ad462b6a14dc9a191836b18 Mon Sep 17 00:00:00 2001 From: "Evgeny Alekseev (IBS Group)" Date: Mon, 17 Oct 2022 17:04:49 +0300 Subject: IBS: Add logs to SMTP transfer --- .../bmcweb/0012-Transfer-logs-to-SMTP.patch | 65 ++++++++++++++++++++++ .../recipes-phosphor/interfaces/bmcweb_%.bbappend | 1 + 2 files changed, 66 insertions(+) create mode 100644 meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0012-Transfer-logs-to-SMTP.patch diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0012-Transfer-logs-to-SMTP.patch b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0012-Transfer-logs-to-SMTP.patch new file mode 100644 index 0000000000..dde316f1a2 --- /dev/null +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0012-Transfer-logs-to-SMTP.patch @@ -0,0 +1,65 @@ +From a6966a2dd8c55f94cfaf5a625d27952b66e5be36 Mon Sep 17 00:00:00 2001 +From: "Evgeny Alekseev (IBS Group)" +Date: Mon, 17 Oct 2022 13:39:13 +0300 +Subject: [PATCH] Transfer logs to SMTP + +--- + src/redfish2phosphor-logs.cpp | 28 +++++++++++++++++++++++----- + 1 file changed, 23 insertions(+), 5 deletions(-) + +diff --git a/src/redfish2phosphor-logs.cpp b/src/redfish2phosphor-logs.cpp +index beaf315e..7a1b7ea3 100644 +--- a/src/redfish2phosphor-logs.cpp ++++ b/src/redfish2phosphor-logs.cpp +@@ -24,7 +24,7 @@ using namespace std::literals; + static constexpr char ARG_DELIMITER = '$'; + static constexpr auto ARG_COUNT = 4; + +-static constexpr auto excluded_messages = std::array { "SELEntryAdded" }; ++static constexpr auto excluded_messages = std::array{"SELEntryAdded"}; + + enum class level + { +@@ -194,12 +194,15 @@ int main(int argc, char* argv[]) + + for (auto& m : strsplit_args) + BMCWEB_LOG_DEBUG << m; +- string_msg = redfish::registries::fillMessageArgs(strsplit_args, string_msg); ++ string_msg = ++ redfish::registries::fillMessageArgs(strsplit_args, string_msg); + BMCWEB_LOG_DEBUG << string_msg; + try + { +- if(std::find(excluded_messages.begin(),excluded_messages.end(),std::get<0>(*message)) == excluded_messages.end()) +- { dbusCallMethodNoReturn( ++ if (std::find(excluded_messages.begin(), excluded_messages.end(), ++ std::get<0>(*message)) == excluded_messages.end()) ++ { ++ dbusCallMethodNoReturn( + getBus(), "xyz.openbmc_project.Logging"s, + "/xyz/openbmc_project/logging"s, + "xyz.openbmc_project.Logging.Create"s, "Create"s, +@@ -210,7 +213,22 @@ int main(int argc, char* argv[]) + catch (const sdbusplus::exception_t& ex) + { + BMCWEB_LOG_CRITICAL << ex.what(); +- return -1; ++ } ++ try ++ { ++ if (std::find(excluded_messages.begin(), excluded_messages.end(), ++ std::get<0>(*message)) == excluded_messages.end()) ++ { ++ dbusCallMethodNoReturn( ++ getBus(), "xyz.openbmc_project.SMTP"s, ++ "/xyz/openbmc_project/SMTP/Messenger"s, ++ "xyz.openbmc_project.Messenger"s, "SendMail"s, ++ std::string("BMC Log Entry. Severity:")+std::string(severity_str), std::string(string_msg)); ++ } ++ } ++ catch (const sdbusplus::exception_t& ex) ++ { ++ BMCWEB_LOG_CRITICAL << ex.what(); + } + return 0; + } diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend index c7bcffa17e..be8dd34706 100644 --- a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -14,6 +14,7 @@ SRC_URI += "\ file://0009-Added-check-user-priv-before-creating-KVM-and-SOL.patch \ file://0010-Support-setting-IPMI-and-SSH-port-via-redfish.patch \ file://0011-redfish2phosphor-add-exclude-list.patch \ + file://0012-Transfer-logs-to-SMTP.patch \ " EXTRA_OEMESON += "\ -- cgit v1.2.3