1 /******************************************************************************
3 * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
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. *
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. *
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 ******************************************************************************/
23 enum Bunit { BunitB = 0, BunitkB = 1, BunitMB = 2, BunitGB = 3, BunitTB = 4 };
24 enum Tunit { TunitMS, TunitS, TunitM, TunitH };
25 enum state { OK = 0, WARNING = 1, CRITICAL = 2 };
31 //TRUE means everything BELOW upper/outside [lower-upper] is fine
32 bool legal, perc, set;
34 threshold(bool l = true)
35 : set(false), legal(l) {}
37 threshold(const double v, const double c, bool l = true, bool p = false)
38 : lower(v), upper(c), legal(l), perc(p), set(true) {}
40 //return TRUE if the threshold is broken
41 bool rend(const double b)
46 return b > upper == legal;
48 return (b < lower || upper < b) != legal;
51 //returns a printable string of the threshold
52 std::wstring pString()
63 s.append(L"[").append(std::to_wstring(lower)).append(L"%").append(L"-")
64 .append(std::to_wstring(upper)).append(L"%").append(L"]");
66 s.append(L"[").append(std::to_wstring(lower)).append(L"-")
67 .append(std::to_wstring(upper)).append(L"]");
70 s = std::to_wstring(lower).append(L"%");
72 s = std::to_wstring(lower);
78 threshold parse(const std::wstring&);
79 Bunit parseBUnit(const wchar_t *);
80 std::wstring BunitStr(const Bunit&);
81 Tunit parseTUnit(const wchar_t *);
82 std::wstring TunitStr(const Tunit&);