blob: 46d9156a2ac2b6e33d9a6437eafc7a2545aa5825 [file] [log] [blame]
Andrew Geissler9e3afdf2022-02-10 15:06:16 -06001#include "systemd_service_parser.hpp"
2
3#include <fstream>
4#include <iostream>
5
6ServiceMonitorData parseServiceFiles(const std::vector<std::string>& filePaths)
7{
8 ServiceMonitorData systemdServiceMap;
9 for (const auto& jsonFile : filePaths)
10 {
11 if (gVerbose)
12 {
13 std::cout << "Parsing input service file " << jsonFile << std::endl;
14 }
15 std::ifstream fileStream(jsonFile);
16 auto j = json::parse(fileStream);
17
18 for (auto& service : j["services"].items())
19 {
20 if (gVerbose)
21 {
22 std::cout << "service: " << service.value() << std::endl;
23 }
24
25 systemdServiceMap.push_back(service.value());
26 }
27 }
28 return systemdServiceMap;
29}