]> granicus.if.org Git - icinga2/blob - plugins/thresholds.h
Fix performance output of check_perfmon
[icinga2] / plugins / thresholds.h
1 /******************************************************************************
2 * Icinga 2                                                                   *
3 * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
4 *                                                                            *
5 * This program is free software; you can redistribute it and/or              *
6 * modify it under the terms of the GNU General Public License                *
7 * as published by the Free Software Foundation; either version 2             *
8 * of the License, or (at your option) any later version.                     *
9 *                                                                            *
10 * This program is distributed in the hope that it will be useful,            *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13 * GNU General Public License for more details.                               *
14 *                                                                            *
15 * You should have received a copy of the GNU General Public License          *
16 * along with this program; if not, write to the Free Software Foundation     *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18 ******************************************************************************/
19
20 #ifndef THRESHOLDS_H
21 #define THRESHOLDS_H
22
23 #include <string>
24 #include <Windows.h>
25 #include <vector>
26
27 enum Bunit
28 {
29         BunitB = 0, BunitkB = 1, BunitMB = 2, BunitGB = 3, BunitTB = 4
30 };
31
32 enum Tunit
33 {
34         TunitMS, TunitS, TunitM, TunitH
35 };
36
37 enum state
38 {
39         OK = 0, WARNING = 1, CRITICAL = 2
40 };
41
42 class threshold
43 {
44 public:
45         //DOUBLEs are always enough for ANY 64 bit value
46         DOUBLE lower, upper;
47         //TRUE means everything BELOW upper/outside [lower-upper] is fine
48         BOOL legal, perc, set;
49
50         threshold();
51
52         threshold(CONST DOUBLE v, CONST DOUBLE c, BOOL l = TRUE, BOOL p = FALSE);
53
54         threshold(CONST std::wstring&);
55
56         //return TRUE if the threshold is broken
57         BOOL rend(CONST DOUBLE val, CONST DOUBLE max = 100.0);
58
59         //returns a printable string of the threshold
60         std::wstring pString(CONST DOUBLE max = 100.0);
61
62 };
63 std::wstring removeZero(DOUBLE);
64 std::vector<std::wstring> splitMultiOptions(std::wstring);
65
66 Bunit parseBUnit(CONST std::wstring&);
67 std::wstring BunitStr(CONST Bunit&);
68 Tunit parseTUnit(CONST std::wstring&);
69 std::wstring TunitStr(CONST Tunit&);
70
71 VOID die(DWORD err = 0);
72
73 #endif /* THRESHOLDS_H */