xref: /openbmc/openpower-debug-collector/watchdog/watchdog_logging.cpp (revision 5ba35c6349f4d523d3f5b5e001c869392b2c5674)
1 #include "watchdog_logging.hpp"
2 
3 #include "watchdog_common.hpp"
4 #include "watchdog_dbus.hpp"
5 #include "watchdog_handler.hpp"
6 
7 #include <unistd.h>
8 
9 #include <phosphor-logging/log.hpp>
10 
11 namespace watchdog
12 {
13 namespace dump
14 {
15 
16 /**
17  * @brief Log an event handled by the dump handler
18  *
19  * @param additional - Additional PEL data
20  * @param timeout - timeout interval in seconds
21  */
event(std::map<std::string,std::string> & additional,const uint32_t timeout)22 void event(std::map<std::string, std::string>& additional,
23            const uint32_t timeout)
24 {
25     std::string eventName = "org.open_power.Host.Boot.Error.WatchdogTimedOut";
26 
27     // CreatePELWithFFDCFiles requires a vector of FFDCTuple.
28     auto emptyFfdc = std::vector<FFDCTuple>{};
29 
30     // Create PEL with additional data.
31     auto pelId = createPel(eventName, additional, emptyFfdc);
32 
33     // Collect Hostboot dump if auto reboot is enabled
34     DumpParameters dumpParameters;
35     dumpParameters.logId = pelId;
36     dumpParameters.unitId = 0; // Not used for Hostboot dump
37     dumpParameters.timeout = timeout;
38     dumpParameters.dumpType = DumpType::Hostboot;
39 
40     // will not return until dump is complete or timeout
41     requestDump(dumpParameters);
42 }
43 
eventWatchdogTimeout(const uint32_t timeout)44 void eventWatchdogTimeout(const uint32_t timeout)
45 {
46     // Additional data to be added to PEL object
47     // Currently we don't have anything to add
48     // Keeping this for now in case if we have to add
49     // any data corresponding to watchdog timeout
50     std::map<std::string, std::string> additionalData;
51     event(additionalData, timeout);
52 }
53 
54 } // namespace dump
55 } // namespace watchdog
56