blob: 865ed9146c649e425699b74924315e3aacdd5fb6 [file] [log] [blame]
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -05001#include "config.h"
2
3#include "dump_manager_system.hpp"
4
5#include "system_dump_entry.hpp"
6
7#include <phosphor-logging/elog.hpp>
8
9namespace phosphor
10{
11namespace dump
12{
13namespace system
14{
15
16using namespace phosphor::logging;
17
18void Manager::notify(NewDump::DumpType dumpType, uint32_t dumpId, uint64_t size)
19{
20
21 if (dumpType != NewDump::DumpType::System)
22 {
23 log<level::ERR>("Only system dump is supported",
24 entry("DUMPTYPE=%d", dumpType));
25 return;
26 }
27 // Get the timestamp
28 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
29 std::chrono::system_clock::now().time_since_epoch())
30 .count();
31 // Get the id
32 auto id = lastEntryId + 1;
33 auto idString = std::to_string(id);
34 auto objPath = fs::path(baseEntryPath) / idString;
35 entries.insert(std::make_pair(
36 id, std::make_unique<system::Entry>(bus, objPath.c_str(), id, ms, size,
37 dumpId, *this)));
38 lastEntryId++;
39}
40
Dhruvaraj Subhashchandran7040bce2020-09-16 00:50:19 -050041uint32_t Manager::createDump()
42{
43 constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
44 constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
45 constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
46 constexpr auto DIAG_MOD_TARGET = "obmc-host-diagnostic-mode@0.target";
47 auto b = sdbusplus::bus::new_default();
48 auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
49 SYSTEMD_INTERFACE, "StartUnit");
50 method.append(DIAG_MOD_TARGET); // unit to activate
51 method.append("replace");
52 bus.call_noreply(method);
53 return ++lastEntryId;
54}
55
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050056} // namespace system
57} // namespace dump
58} // namespace phosphor