blob: ccf3a44fc40bd66851ff07640786d6b35bca8e75 (
plain)
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
53
54
55
56
57
58
59
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef ML_HOST_H
#define ML_HOST_H
#include "Config.h"
#include "Dimension.h"
#include "Chart.h"
#include "Queue.h"
#include "ml-private.h"
#include "json/single_include/nlohmann/json.hpp"
namespace ml
{
class Host {
public:
Host(RRDHOST *RH) :
RH(RH),
MLS(),
TS(),
HostAnomalyRate(0.0)
{ }
void addChart(Chart *C);
void removeChart(Chart *C);
void getConfigAsJson(nlohmann::json &Json) const;
void getModelsAsJson(nlohmann::json &Json);
void getDetectionInfoAsJson(nlohmann::json &Json) const;
void startAnomalyDetectionThreads();
void stopAnomalyDetectionThreads();
void scheduleForTraining(TrainingRequest TR);
void train();
void detect();
void detectOnce();
private:
RRDHOST *RH;
MachineLearningStats MLS;
TrainingStats TS;
CalculatedNumber HostAnomalyRate{0.0};
Queue<TrainingRequest> TrainingQueue;
std::mutex Mutex;
std::unordered_map<RRDSET *, Chart *> Charts;
std::thread TrainingThread;
std::thread DetectionThread;
};
} // namespace ml
#endif /* ML_HOST_H */
|