summaryrefslogtreecommitdiffstats
path: root/plugins/thresholds.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
commit56ae875861ab260b80a030f50c4aff9f9dc8fff0 (patch)
tree531412110fc901a5918c7f7442202804a83cada9 /plugins/thresholds.hpp
parentInitial commit. (diff)
downloadicinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.tar.xz
icinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.zip
Adding upstream version 2.14.2.upstream/2.14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/thresholds.hpp')
-rw-r--r--plugins/thresholds.hpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/thresholds.hpp b/plugins/thresholds.hpp
new file mode 100644
index 0000000..4c47ddb
--- /dev/null
+++ b/plugins/thresholds.hpp
@@ -0,0 +1,64 @@
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
+
+#ifndef THRESHOLDS_H
+#define THRESHOLDS_H
+
+#include <string>
+#include <vector>
+#include <windows.h>
+
+enum Bunit
+{
+ BunitB = 0, BunitkB = 1, BunitMB = 2, BunitGB = 3, BunitTB = 4
+};
+
+enum Tunit
+{
+ TunitMS, TunitS, TunitM, TunitH
+};
+
+enum state
+{
+ OK = 0, WARNING = 1, CRITICAL = 2
+};
+
+class threshold
+{
+public:
+ // doubles are always enough for ANY 64 bit value
+ double lower;
+ double upper;
+ // true means everything BELOW upper/outside [lower-upper] is fine
+ bool legal;
+ bool perc;
+ bool set;
+
+ threshold();
+
+ threshold(const double v, const double c, bool l = true, bool p = false);
+
+ threshold(const std::wstring&);
+
+ // returns true if the threshold is broken
+ bool rend(const double val, const double max = 100.0);
+
+ // returns a printable string of the threshold
+ std::wstring pString(const double max = 100.0);
+
+ threshold toSeconds(const Tunit& fromUnit);
+};
+
+std::wstring removeZero(double);
+std::vector<std::wstring> splitMultiOptions(const std::wstring&);
+
+Bunit parseBUnit(const std::wstring&);
+std::wstring BunitStr(const Bunit&);
+Tunit parseTUnit(const std::wstring&);
+std::wstring TunitStr(const Tunit&);
+
+void printErrorInfo(unsigned long err = 0);
+std::wstring formatErrorInfo(unsigned long err);
+
+std::wstring stateToString(const state&);
+
+#endif /* THRESHOLDS_H */