blob: 95a4602be2000236c2e29eff072736c0102fe830 [file] [log] [blame]
Jason M. Bills5e049d32018-10-19 12:59:38 -07001/*
2// Copyright (c) 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#include <systemd/sd-journal.h>
17
Jason M. Billsc4a336f2019-04-23 10:43:10 -070018#include <boost/algorithm/string.hpp>
Ed Tanousc3526342023-03-06 13:37:53 -080019#include <boost/asio/io_context.hpp>
Jason M. Bills5e049d32018-10-19 12:59:38 -070020#include <boost/container/flat_map.hpp>
21#include <boost/container/flat_set.hpp>
Zhikui Ren672bdfc2020-07-14 11:37:01 -070022#include <pulse_event_monitor.hpp>
23#include <sdbusplus/asio/object_server.hpp>
24#include <sel_logger.hpp>
25#include <threshold_event_monitor.hpp>
Charles Hsudbd77b92020-10-29 11:20:34 +080026#include <watchdog_event_monitor.hpp>
George Hung486e42e2021-04-14 20:20:42 +080027#ifdef SEL_LOGGER_MONITOR_THRESHOLD_ALARM_EVENTS
28#include <threshold_alarm_event_monitor.hpp>
29#endif
JinFuLin7c2810b2022-12-02 13:55:28 +080030#ifdef SEL_LOGGER_MONITOR_HOST_ERROR_EVENTS
31#include <host_error_event_monitor.hpp>
32#endif
Zhikui Ren672bdfc2020-07-14 11:37:01 -070033
Jason M. Billsc4a336f2019-04-23 10:43:10 -070034#include <filesystem>
35#include <fstream>
Jason M. Bills5e049d32018-10-19 12:59:38 -070036#include <iomanip>
37#include <iostream>
Jason M. Bills5e049d32018-10-19 12:59:38 -070038#include <sstream>
Jason M. Bills5e049d32018-10-19 12:59:38 -070039
40struct DBusInternalError final : public sdbusplus::exception_t
41{
Zhikui Ren672bdfc2020-07-14 11:37:01 -070042 const char* name() const noexcept override
Jason M. Bills5e049d32018-10-19 12:59:38 -070043 {
44 return "org.freedesktop.DBus.Error.Failed";
Patrick Williamsa138ebd2021-09-08 15:46:34 -050045 }
Zhikui Ren672bdfc2020-07-14 11:37:01 -070046 const char* description() const noexcept override
Jason M. Bills5e049d32018-10-19 12:59:38 -070047 {
48 return "internal error";
Patrick Williamsa138ebd2021-09-08 15:46:34 -050049 }
Zhikui Ren672bdfc2020-07-14 11:37:01 -070050 const char* what() const noexcept override
Jason M. Bills5e049d32018-10-19 12:59:38 -070051 {
52 return "org.freedesktop.DBus.Error.Failed: "
53 "internal error";
Patrick Williamsa138ebd2021-09-08 15:46:34 -050054 }
55
56 int get_errno() const noexcept override
57 {
58 return EACCES;
59 }
Jason M. Bills5e049d32018-10-19 12:59:38 -070060};
61
Lei YUe526b862020-12-03 15:41:59 +080062#ifndef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
Zhikui Ren672bdfc2020-07-14 11:37:01 -070063static bool getSELLogFiles(std::vector<std::filesystem::path>& selLogFiles)
Jason M. Billsc4a336f2019-04-23 10:43:10 -070064{
65 // Loop through the directory looking for ipmi_sel log files
Zhikui Ren672bdfc2020-07-14 11:37:01 -070066 for (const std::filesystem::directory_entry& dirEnt :
Jason M. Billsc4a336f2019-04-23 10:43:10 -070067 std::filesystem::directory_iterator(selLogDir))
68 {
69 std::string filename = dirEnt.path().filename();
70 if (boost::starts_with(filename, selLogFilename))
71 {
72 // If we find an ipmi_sel log file, save the path
73 selLogFiles.emplace_back(selLogDir / filename);
74 }
75 }
76 // As the log files rotate, they are appended with a ".#" that is higher for
77 // the older logs. Since we don't expect more than 10 log files, we
78 // can just sort the list to get them in order from newest to oldest
79 std::sort(selLogFiles.begin(), selLogFiles.end());
80
81 return !selLogFiles.empty();
82}
83
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -060084static void saveClearSelTimestamp()
85{
86 int fd = open("/var/lib/ipmi/sel_erase_time",
87 O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
88 if (fd < 0)
89 {
90 std::cerr << "Failed to open file\n";
91 return;
92 }
93
94 if (futimens(fd, NULL) < 0)
95 {
96 std::cerr << "Failed to update SEL cleared timestamp: "
97 << std::string(strerror(errno));
98 }
99 close(fd);
100}
101
102#ifdef SEL_LOGGER_ENABLE_SEL_DELETE
103std::vector<uint16_t> nextRecordsCache;
104
105static void backupCacheToFile()
106{
107 std::ofstream nextRecordStream(selLogDir / nextRecordFilename);
108 for (auto recordIds : nextRecordsCache)
109 {
110 nextRecordStream << recordIds << '\n';
111 }
112}
113
114static uint16_t getNewRecordId()
115{
116 uint16_t nextRecordId = nextRecordsCache.back();
117 // Check if SEL is full
118 if (nextRecordId == selInvalidRecID)
119 {
120 return nextRecordId;
121 }
122 nextRecordsCache.pop_back();
123 if (nextRecordsCache.empty())
124 {
125 nextRecordsCache.push_back(nextRecordId + 1);
126 }
127 backupCacheToFile();
128 return nextRecordId;
129}
130
131static void initializeRecordId()
132{
133 std::ifstream nextRecordStream(selLogDir / nextRecordFilename);
134 if (!nextRecordStream.is_open())
135 {
136 std::ofstream newStream(selLogDir / nextRecordFilename);
137 newStream << '1' << '\n';
138 newStream.close();
139 nextRecordStream.open(selLogDir / nextRecordFilename);
140 }
141 std::string line;
142 while (std::getline(nextRecordStream, line))
143 {
144 nextRecordsCache.push_back(std::stoi(line));
145 }
146}
147
148void clearSelLogFiles()
149{
150 saveClearSelTimestamp();
151
152 // Clear the SEL by deleting the log files
153 std::vector<std::filesystem::path> selLogFiles;
154 if (getSELLogFiles(selLogFiles))
155 {
156 for (const std::filesystem::path& file : selLogFiles)
157 {
158 std::error_code ec;
159 std::filesystem::remove(file, ec);
160 }
161 }
162 // Reload rsyslog so it knows to start new log files
163 boost::asio::io_context io;
164 auto dbus = std::make_shared<sdbusplus::asio::connection>(io);
165 sdbusplus::message_t rsyslogReload = dbus->new_method_call(
166 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
167 "org.freedesktop.systemd1.Manager", "ReloadUnit");
168 rsyslogReload.append("rsyslog.service", "replace");
169 try
170 {
171 sdbusplus::message_t reloadResponse = dbus->call(rsyslogReload);
172 }
173 catch (const sdbusplus::exception_t& e)
174 {
175 std::cerr << e.what() << "\n";
176 }
177 // Set next record to 1
178 nextRecordsCache.clear();
179 nextRecordsCache.push_back(1);
180 // Update backup file as well
181 std::ofstream nextRecordStream(selLogDir / nextRecordFilename);
182 nextRecordStream << '1' << '\n';
183}
184
185static bool selDeleteTargetRecord(const uint16_t& targetId)
186{
187 bool targetEntryFound = false;
188 // Check if the ipmi_sel exist and save the path
189 std::vector<std::filesystem::path> selLogFiles;
190 if (!getSELLogFiles(selLogFiles))
191 {
192 return targetEntryFound;
193 }
194
195 // Go over all the ipmi_sel files to remove the entry with the target ID
196 for (const std::filesystem::path& file : selLogFiles)
197 {
198 std::fstream logStream(file, std::ios::in);
199 std::fstream tempFile(selLogDir / "temp", std::ios::out);
200 if (!logStream.is_open())
201 {
202 return targetEntryFound;
203 }
204 std::string line;
205 while (std::getline(logStream, line))
206 {
207 // Get the recordId of the current entry
208 int left = line.find(" ");
209 int right = line.find(",");
210 int recordLen = right - left;
211 std::string recordId = line.substr(left, recordLen);
212 int newRecordId = std::stoi(recordId);
213
214 if (newRecordId != targetId)
215 {
216 // Copy the entry from the original ipmi_sel to the temp file
217 tempFile << line << '\n';
218 }
219 else
220 {
221 // Skip copying the target entry
222 targetEntryFound = true;
223 }
224 }
225 logStream.close();
226 tempFile.close();
227 if (targetEntryFound)
228 {
229 std::fstream logStream(file, std::ios::out);
230 std::fstream tempFile(selLogDir / "temp", std::ios::in);
231 while (std::getline(tempFile, line))
232 {
233 logStream << line << '\n';
234 }
235 logStream.close();
236 tempFile.close();
237 std::error_code ec;
238 if (!std::filesystem::remove(selLogDir / "temp", ec))
239 {
240 std::cerr << ec.message() << std::endl;
241 }
242 break;
243 }
244 }
245 return targetEntryFound;
246}
247
248static uint16_t selDeleteRecord(const uint16_t& recordId)
249{
250 std::filesystem::file_time_type prevAddTime =
251 std::filesystem::last_write_time(selLogDir / selLogFilename);
252 bool targetEntryFound = selDeleteTargetRecord(recordId);
253
254 // Check if the Record Id was found
255 if (!targetEntryFound)
256 {
257 return selInvalidRecID;
258 }
259 // Add to next record cache for reuse
260 nextRecordsCache.push_back(recordId);
261 // Add to backup file
262 std::ofstream nextRecordStream(selLogDir / nextRecordFilename,
263 std::ios::app);
264 nextRecordStream << recordId << '\n';
265 // Keep Last Add Time the same
266 std::filesystem::last_write_time(selLogDir / selLogFilename, prevAddTime);
267 // Update Last Del Time
268 saveClearSelTimestamp();
269 return recordId;
270}
271#else
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500272static unsigned int initializeRecordId()
Jason M. Bills5e049d32018-10-19 12:59:38 -0700273{
Jason M. Billsc4a336f2019-04-23 10:43:10 -0700274 std::vector<std::filesystem::path> selLogFiles;
275 if (!getSELLogFiles(selLogFiles))
Jason M. Bills5e049d32018-10-19 12:59:38 -0700276 {
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500277 return 0;
Jason M. Bills5e049d32018-10-19 12:59:38 -0700278 }
Jason M. Billsc4a336f2019-04-23 10:43:10 -0700279 std::ifstream logStream(selLogFiles.front());
280 if (!logStream.is_open())
Jason M. Bills5e049d32018-10-19 12:59:38 -0700281 {
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500282 return 0;
Jason M. Billsc4a336f2019-04-23 10:43:10 -0700283 }
284 std::string line;
285 std::string newestEntry;
286 while (std::getline(logStream, line))
287 {
288 newestEntry = line;
289 }
Jason M. Bills5e049d32018-10-19 12:59:38 -0700290
Jason M. Billsc4a336f2019-04-23 10:43:10 -0700291 std::vector<std::string> newestEntryFields;
292 boost::split(newestEntryFields, newestEntry, boost::is_any_of(" ,"),
293 boost::token_compress_on);
294 if (newestEntryFields.size() < 4)
295 {
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500296 return 0;
Jason M. Bills5e049d32018-10-19 12:59:38 -0700297 }
Jason M. Billsc4a336f2019-04-23 10:43:10 -0700298
299 return std::stoul(newestEntryFields[1]);
Jason M. Bills5e049d32018-10-19 12:59:38 -0700300}
301
Charles Boyer9f476e82021-07-29 16:33:01 -0500302static unsigned int recordId = initializeRecordId();
303
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600304static unsigned int getNewRecordId()
Alexander Hansen8c023192023-09-26 09:15:18 +0200305{
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600306 if (++recordId >= selInvalidRecID)
Alexander Hansen8c023192023-09-26 09:15:18 +0200307 {
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600308 recordId = selInvalidRecID;
Alexander Hansen8c023192023-09-26 09:15:18 +0200309 }
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600310 return recordId;
Alexander Hansen8c023192023-09-26 09:15:18 +0200311}
312
Charles Boyer9f476e82021-07-29 16:33:01 -0500313void clearSelLogFiles()
314{
Alexander Hansen8c023192023-09-26 09:15:18 +0200315 saveClearSelTimestamp();
316
Charles Boyer9f476e82021-07-29 16:33:01 -0500317 // Clear the SEL by deleting the log files
318 std::vector<std::filesystem::path> selLogFiles;
319 if (getSELLogFiles(selLogFiles))
320 {
321 for (const std::filesystem::path& file : selLogFiles)
322 {
323 std::error_code ec;
324 std::filesystem::remove(file, ec);
325 }
326 }
327
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500328 recordId = 0;
Charles Boyer9f476e82021-07-29 16:33:01 -0500329
330 // Reload rsyslog so it knows to start new log files
Ed Tanousc3526342023-03-06 13:37:53 -0800331 boost::asio::io_context io;
Charles Boyer9f476e82021-07-29 16:33:01 -0500332 auto dbus = std::make_shared<sdbusplus::asio::connection>(io);
Patrick Williamsccef2272022-07-22 19:26:54 -0500333 sdbusplus::message_t rsyslogReload = dbus->new_method_call(
Charles Boyer9f476e82021-07-29 16:33:01 -0500334 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
335 "org.freedesktop.systemd1.Manager", "ReloadUnit");
336 rsyslogReload.append("rsyslog.service", "replace");
337 try
338 {
Patrick Williamsccef2272022-07-22 19:26:54 -0500339 sdbusplus::message_t reloadResponse = dbus->call(rsyslogReload);
Charles Boyer9f476e82021-07-29 16:33:01 -0500340 }
Patrick Williams3f4cd972021-10-06 12:42:50 -0500341 catch (const sdbusplus::exception_t& e)
Charles Boyer9f476e82021-07-29 16:33:01 -0500342 {
343 std::cerr << e.what() << "\n";
344 }
345}
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600346#endif
Lei YUe526b862020-12-03 15:41:59 +0800347#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700348
Zhikui Ren672bdfc2020-07-14 11:37:01 -0700349static void toHexStr(const std::vector<uint8_t>& data, std::string& hexStr)
Jason M. Bills5e049d32018-10-19 12:59:38 -0700350{
351 std::stringstream stream;
352 stream << std::hex << std::uppercase << std::setfill('0');
William A. Kennington III2e437262021-07-30 12:04:19 -0700353 for (int v : data)
Jason M. Bills5e049d32018-10-19 12:59:38 -0700354 {
355 stream << std::setw(2) << v;
356 }
357 hexStr = stream.str();
358}
359
Jason M. Bills97be3532018-11-02 13:09:16 -0700360template <typename... T>
Vincent Chou92721502024-01-24 15:09:24 -0600361static uint16_t selAddSystemRecord(
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000362 [[maybe_unused]] std::shared_ptr<sdbusplus::asio::connection> conn,
363 [[maybe_unused]] const std::string& message, const std::string& path,
364 const std::vector<uint8_t>& selData, const bool& assert,
365 const uint16_t& genId, [[maybe_unused]] T&&... metadata)
Jason M. Bills5e049d32018-10-19 12:59:38 -0700366{
367 // Only 3 bytes of SEL event data are allowed in a system record
368 if (selData.size() > selEvtDataMaxSize)
369 {
370 throw std::invalid_argument("Event data too large");
371 }
372 std::string selDataStr;
373 toHexStr(selData, selDataStr);
374
Lei YUe526b862020-12-03 15:41:59 +0800375#ifdef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000376 sdbusplus::message_t AddToLog = conn->new_method_call(
377 "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
378 "xyz.openbmc_project.Logging.Create", "Create");
379
380 std::string journalMsg(message + " from " + path + ": " +
381 " RecordType=" + std::to_string(selSystemType) +
382 ", GeneratorID=" + std::to_string(genId) +
383 ", EventDir=" + std::to_string(assert) +
384 ", EventData=" + selDataStr);
385
386 AddToLog.append(journalMsg,
387 "xyz.openbmc_project.Logging.Entry.Level.Informational",
388 std::map<std::string, std::string>(
389 {{"SENSOR_PATH", path},
390 {"GENERATOR_ID", std::to_string(genId)},
391 {"RECORD_TYPE", std::to_string(selSystemType)},
392 {"EVENT_DIR", std::to_string(assert)},
393 {"SENSOR_DATA", selDataStr}}));
394 conn->call(AddToLog);
Vincent Chou92721502024-01-24 15:09:24 -0600395 return 0;
Lei YUe526b862020-12-03 15:41:59 +0800396#else
Jason M. Bills5e049d32018-10-19 12:59:38 -0700397 unsigned int recordId = getNewRecordId();
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500398 if (recordId < selInvalidRecID)
399 {
400 sd_journal_send(
401 "MESSAGE=%s", message.c_str(), "PRIORITY=%i", selPriority,
402 "MESSAGE_ID=%s", selMessageId, "IPMI_SEL_RECORD_ID=%d", recordId,
403 "IPMI_SEL_RECORD_TYPE=%x", selSystemType,
404 "IPMI_SEL_GENERATOR_ID=%x", genId, "IPMI_SEL_SENSOR_PATH=%s",
405 path.c_str(), "IPMI_SEL_EVENT_DIR=%x", assert, "IPMI_SEL_DATA=%s",
406 selDataStr.c_str(), std::forward<T>(metadata)..., NULL);
407 }
Vincent Chou92721502024-01-24 15:09:24 -0600408 return recordId;
Lei YUe526b862020-12-03 15:41:59 +0800409#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700410}
411
Vincent Chou92721502024-01-24 15:09:24 -0600412static uint16_t selAddOemRecord(
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000413 [[maybe_unused]] std::shared_ptr<sdbusplus::asio::connection> conn,
414 [[maybe_unused]] const std::string& message,
415 const std::vector<uint8_t>& selData, const uint8_t& recordType)
Jason M. Bills5e049d32018-10-19 12:59:38 -0700416{
417 // A maximum of 13 bytes of SEL event data are allowed in an OEM record
418 if (selData.size() > selOemDataMaxSize)
419 {
420 throw std::invalid_argument("Event data too large");
421 }
422 std::string selDataStr;
423 toHexStr(selData, selDataStr);
424
Lei YUe526b862020-12-03 15:41:59 +0800425#ifdef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000426 sdbusplus::message_t AddToLog = conn->new_method_call(
427 "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
428 "xyz.openbmc_project.Logging.Create", "Create");
429
430 std::string journalMsg(
431 message + ": " + " RecordType=" + std::to_string(recordType) +
432 ", GeneratorID=" + std::to_string(0) +
433 ", EventDir=" + std::to_string(0) + ", EventData=" + selDataStr);
434
435 AddToLog.append(journalMsg,
436 "xyz.openbmc_project.Logging.Entry.Level.Informational",
437 std::map<std::string, std::string>(
438 {{"SENSOR_PATH", ""},
439 {"GENERATOR_ID", std::to_string(0)},
440 {"RECORD_TYPE", std::to_string(recordType)},
441 {"EVENT_DIR", std::to_string(0)},
442 {"SENSOR_DATA", selDataStr}}));
443 conn->call(AddToLog);
Vincent Chou92721502024-01-24 15:09:24 -0600444 return 0;
Lei YUe526b862020-12-03 15:41:59 +0800445#else
Jason M. Bills5e049d32018-10-19 12:59:38 -0700446 unsigned int recordId = getNewRecordId();
Jonico Eustaquio0acff272024-04-23 15:12:06 -0500447 if (recordId < selInvalidRecID)
448 {
449 sd_journal_send("MESSAGE=%s", message.c_str(), "PRIORITY=%i",
450 selPriority, "MESSAGE_ID=%s", selMessageId,
451 "IPMI_SEL_RECORD_ID=%d", recordId,
452 "IPMI_SEL_RECORD_TYPE=%x", recordType,
453 "IPMI_SEL_DATA=%s", selDataStr.c_str(), NULL);
454 }
Vincent Chou92721502024-01-24 15:09:24 -0600455 return recordId;
Lei YUe526b862020-12-03 15:41:59 +0800456#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700457}
458
William A. Kennington IIId585c592021-07-30 12:10:25 -0700459int main(int, char*[])
Jason M. Bills5e049d32018-10-19 12:59:38 -0700460{
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600461#ifndef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
462#ifdef SEL_LOGGER_ENABLE_SEL_DELETE
463 initializeRecordId();
464#endif
465#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700466 // setup connection to dbus
Ed Tanousc3526342023-03-06 13:37:53 -0800467 boost::asio::io_context io;
Jason M. Bills5e049d32018-10-19 12:59:38 -0700468 auto conn = std::make_shared<sdbusplus::asio::connection>(io);
469
470 // IPMI SEL Object
471 conn->request_name(ipmiSelObject);
472 auto server = sdbusplus::asio::object_server(conn);
473
474 // Add SEL Interface
475 std::shared_ptr<sdbusplus::asio::dbus_interface> ifaceAddSel =
476 server.add_interface(ipmiSelPath, ipmiSelAddInterface);
477
478 // Add a new SEL entry
479 ifaceAddSel->register_method(
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000480 "IpmiSelAdd",
481 [conn](const std::string& message, const std::string& path,
482 const std::vector<uint8_t>& selData, const bool& assert,
483 const uint16_t& genId) {
484 return selAddSystemRecord(conn, message, path, selData, assert, genId);
Patrick Williamsc68ea052023-10-20 11:19:00 -0500485 });
Jason M. Bills5e049d32018-10-19 12:59:38 -0700486 // Add a new OEM SEL entry
Patrick Williams69f7fa32023-05-10 07:50:41 -0500487 ifaceAddSel->register_method("IpmiSelAddOem",
Konstantin Aladyshev6f5342d2023-04-19 09:23:11 +0000488 [conn](const std::string& message,
489 const std::vector<uint8_t>& selData,
490 const uint8_t& recordType) {
491 return selAddOemRecord(conn, message, selData, recordType);
Patrick Williams69f7fa32023-05-10 07:50:41 -0500492 });
Charles Boyer9f476e82021-07-29 16:33:01 -0500493
Charles Boyer9f476e82021-07-29 16:33:01 -0500494#ifndef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
495 // Clear SEL entries
496 ifaceAddSel->register_method("Clear", []() { clearSelLogFiles(); });
Jonico Eustaquio9fa224c2024-01-10 13:08:52 -0600497#ifdef SEL_LOGGER_ENABLE_SEL_DELETE
498 // Delete a SEL entry
499 ifaceAddSel->register_method("IpmiSelDelete", [](const uint16_t& recordId) {
500 return selDeleteRecord(recordId);
501 });
502#endif
Charles Boyer9f476e82021-07-29 16:33:01 -0500503#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700504 ifaceAddSel->initialize();
505
506#ifdef SEL_LOGGER_MONITOR_THRESHOLD_EVENTS
Patrick Williamsccef2272022-07-22 19:26:54 -0500507 sdbusplus::bus::match_t thresholdAssertMonitor =
Zhikui Ren25b26e12020-06-26 20:18:19 -0700508 startThresholdAssertMonitor(conn);
Jason M. Bills5e049d32018-10-19 12:59:38 -0700509#endif
510
Nikhil Potadeafbaa092019-03-06 16:18:13 -0800511#ifdef REDFISH_LOG_MONITOR_PULSE_EVENTS
Patrick Williamsccef2272022-07-22 19:26:54 -0500512 sdbusplus::bus::match_t pulseEventMonitor = startPulseEventMonitor(conn);
Nikhil Potadeafbaa092019-03-06 16:18:13 -0800513#endif
514
Charles Hsudbd77b92020-10-29 11:20:34 +0800515#ifdef SEL_LOGGER_MONITOR_WATCHDOG_EVENTS
Patrick Williamsccef2272022-07-22 19:26:54 -0500516 sdbusplus::bus::match_t watchdogEventMonitor =
Charles Hsudbd77b92020-10-29 11:20:34 +0800517 startWatchdogEventMonitor(conn);
518#endif
George Hung486e42e2021-04-14 20:20:42 +0800519
520#ifdef SEL_LOGGER_MONITOR_THRESHOLD_ALARM_EVENTS
521 startThresholdAlarmMonitor(conn);
522#endif
JinFuLin7c2810b2022-12-02 13:55:28 +0800523
524#ifdef SEL_LOGGER_MONITOR_HOST_ERROR_EVENTS
525 startHostErrorEventMonitor(conn);
526#endif
Jason M. Bills5e049d32018-10-19 12:59:38 -0700527 io.run();
528
529 return 0;
530}