summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0012-Transfer-logs-to-SMTP.patch
blob: dde316f1a2994883149c730d24f8831b6045242d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From a6966a2dd8c55f94cfaf5a625d27952b66e5be36 Mon Sep 17 00:00:00 2001
From: "Evgeny Alekseev (IBS Group)" <ealekseev@ibs.sila.ru>
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;
 }