-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (43 loc) · 1.28 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "src/Master.h"
#include "src/Clickhouse.h"
#include "src/util.h"
//#include "test/test.h"
#include <fmt/printf.h>
#include "src/Collector/CpuCollector.cpp"
#include "src/Collector/SelfStatsCollector.cpp"
#include "src/Collector/HddCollector.cpp"
#include "src/Collector/MemoryCollector.cpp"
int main() {
YAML::Node config;
std::vector<std::string> settingsFileLocations;
auto envConfig = getenv("CONFIG");
if (envConfig) {
settingsFileLocations.emplace_back(envConfig);
} else {
settingsFileLocations = {
"config.yml",
"../config.yml",
"example.yml",
"../example.yml"
};
}
START_TIME;
for (auto &path:settingsFileLocations) {
if (file_exists(path)) {
config = YAML::LoadFile(path);
message_ok("Loaded configuration file = %s in %d ms", path.c_str(), END_TIME_MS);
break;
}
}
if (config.size() == 0) {
message_error("Could not load any configuration file, check your paths");
exit(1);
}
Master f(config);
CpuCollector cpuCollector(&f);
SelfStatsCollector selfStatsCollector(&f);
HddCollector hddCollector(&f);
MemoryCollector memoryCollector(&f);
f.work();
return 0;
}