Refactoring: Changed all check parameters starting with a 'p' to the new rulespec...
[check_mk.git] / livestatus / src / ServiceListStateColumn.h
blob23d555741ffc982753071364a1765ed5aeab7017
1 // +------------------------------------------------------------------+
2 // | ____ _ _ __ __ _ __ |
3 // | / ___| |__ ___ ___| | __ | \/ | |/ / |
4 // | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
5 // | | |___| | | | __/ (__| < | | | | . \ |
6 // | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
7 // | |
8 // | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
9 // +------------------------------------------------------------------+
11 // This file is part of Check_MK.
12 // The official homepage is at http://mathias-kettner.de/check_mk.
14 // check_mk is free software; you can redistribute it and/or modify it
15 // under the terms of the GNU General Public License as published by
16 // the Free Software Foundation in version 2. check_mk is distributed
17 // in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
18 // out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19 // PARTICULAR PURPOSE. See the GNU General Public License for more de-
20 // tails. You should have received a copy of the GNU General Public
21 // License along with GNU Make; see the file COPYING. If not, write
22 // to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 // Boston, MA 02110-1301 USA.
25 #ifndef ServiceListStateColumn_h
26 #define ServiceListStateColumn_h
28 #include "config.h" // IWYU pragma: keep
29 #include <cstdint>
30 #include <string>
31 #include "IntColumn.h"
32 class MonitoringCore;
33 class Row;
35 #ifdef CMC
36 #include "Host.h"
37 #include "cmc.h"
38 #else
39 #include "nagios.h"
40 #endif
42 class ServiceListStateColumn : public IntColumn {
43 public:
44 // TODO(sp) Remove the magic arithmetic
45 enum class Type {
46 num_ok = 0,
47 num_warn = 1,
48 num_crit = 2,
49 num_unknown = 3,
50 num_pending = 4,
51 worst_state = -2,
52 num_hard_ok = (0 + 64),
53 num_hard_warn = (1 + 64),
54 num_hard_crit = (2 + 64),
55 num_hard_unknown = (3 + 64),
56 worst_hard_state = (-2 + 64),
57 num = -1
60 ServiceListStateColumn(const std::string &name,
61 const std::string &description, int indirect_offset,
62 int extra_offset, int extra_extra_offset, int offset,
63 MonitoringCore *mc, Type logictype)
64 : IntColumn(name, description, indirect_offset, extra_offset,
65 extra_extra_offset, offset)
66 , _mc(mc)
67 , _logictype(logictype) {}
69 int32_t getValue(Row row, const contact *auth_user) const override;
71 #ifdef CMC
72 using service_list = const Host::services_t *;
73 #else
74 using service_list = servicesmember *;
75 #endif
77 static int32_t getValueFromServices(MonitoringCore *mc, Type logictype,
78 service_list mem,
79 const contact *auth_user);
81 private:
82 MonitoringCore *_mc;
83 const Type _logictype;
85 static void update(Type logictype, service *svc, int32_t &result);
88 #endif // ServiceListStateColumn_h