Andrew Geissler | 9e3afdf | 2022-02-10 15:06:16 -0600 | [diff] [blame] | 1 | #include "systemd_service_parser.hpp" |
| 2 | |
| 3 | #include <fstream> |
| 4 | #include <iostream> |
| 5 | |
| 6 | ServiceMonitorData 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 | } |