]> granicus.if.org Git - icinga2/blob - plugins/thresholds.hpp
Merge pull request #7383 from K0nne/K0nne-patch-1
[icinga2] / plugins / thresholds.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef THRESHOLDS_H
4 #define THRESHOLDS_H
5
6 #include <string>
7 #include <vector>
8 #include <windows.h>
9
10 enum Bunit
11 {
12         BunitB = 0, BunitkB = 1, BunitMB = 2, BunitGB = 3, BunitTB = 4
13 };
14
15 enum Tunit
16 {
17         TunitMS, TunitS, TunitM, TunitH
18 };
19
20 enum state
21 {
22         OK = 0, WARNING = 1, CRITICAL = 2
23 };
24
25 class threshold
26 {
27 public:
28         // doubles are always enough for ANY 64 bit value
29         double lower;
30         double upper;
31         // true means everything BELOW upper/outside [lower-upper] is fine
32         bool legal;
33         bool perc;
34         bool set;
35
36         threshold();
37
38         threshold(const double v, const double c, bool l = true, bool p = false);
39
40         threshold(const std::wstring&);
41
42         // returns true if the threshold is broken
43         bool rend(const double val, const double max = 100.0);
44
45         // returns a printable string of the threshold
46         std::wstring pString(const double max = 100.0);
47
48         threshold toSeconds(const Tunit& fromUnit);
49 };
50
51 std::wstring removeZero(double);
52 std::vector<std::wstring> splitMultiOptions(const std::wstring&);
53
54 Bunit parseBUnit(const std::wstring&);
55 std::wstring BunitStr(const Bunit&);
56 Tunit parseTUnit(const std::wstring&);
57 std::wstring TunitStr(const Tunit&);
58
59 void printErrorInfo(unsigned long err = 0);
60 std::wstring formatErrorInfo(unsigned long err);
61
62 std::wstring stateToString(const state&);
63
64 #endif /* THRESHOLDS_H */