1 // +------------------------------------------------------------------+
2 // | ____ _ _ __ __ _ __ |
3 // | / ___| |__ ___ ___| | __ | \/ | |/ / |
4 // | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
5 // | | |___| | | | __/ (__| < | | | | . \ |
6 // | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 MonitoringCore_h
26 #define MonitoringCore_h
28 #include "config.h" // IWYU pragma: keep
34 #include "data_encoding.h"
39 std::string _command_line
;
47 std::chrono::system_clock::time_point _entry_time
;
48 std::chrono::system_clock::time_point _start_time
;
49 std::chrono::system_clock::time_point _end_time
;
51 std::chrono::seconds _duration
;
60 uint32_t _entry_type
; // TODO(sp) Move Comment::Type here
61 std::chrono::system_clock::time_point _entry_time
;
64 /// An abstraction layer for the monitoring core (nagios or cmc)
65 class MonitoringCore
{
73 virtual ~MonitoringCore() = default;
75 virtual Host
*getHostByDesignation(const std::string
&designation
) = 0;
76 virtual ContactGroup
*find_contactgroup(const std::string
&name
) = 0;
78 virtual bool host_has_contact(const Host
*host
, const Contact
*contact
) = 0;
79 virtual bool is_contact_member_of_contactgroup(const ContactGroup
*group
,
80 const Contact
*contact
) = 0;
82 virtual std::chrono::system_clock::time_point
last_logfile_rotation() = 0;
83 virtual size_t maxLinesPerLogFile() const = 0;
85 virtual Command
find_command(std::string name
) const = 0;
86 virtual std::vector
<Command
> commands() const = 0;
88 virtual std::vector
<DowntimeData
> downtimes_for_host(
89 const Host
*) const = 0;
90 virtual std::vector
<DowntimeData
> downtimes_for_service(
91 const Service
*) const = 0;
92 virtual std::vector
<CommentData
> comments_for_host(const Host
*) const = 0;
93 virtual std::vector
<CommentData
> comments_for_service(
94 const Service
*) const = 0;
96 virtual bool mkeventdEnabled() = 0;
98 virtual std::string
mkeventdSocketPath() = 0;
99 virtual std::string
mkLogwatchPath() = 0;
100 virtual std::string
mkInventoryPath() = 0;
101 virtual std::string
structuredStatusPath() = 0;
102 virtual std::string
pnpPath() = 0;
103 virtual std::string
historyFilePath() = 0;
104 virtual std::string
logArchivePath() = 0;
105 virtual Encoding
dataEncoding() = 0;
106 virtual size_t maxResponseSize() = 0;
107 virtual size_t maxCachedMessages() = 0;
109 virtual AuthorizationKind
hostAuthorization() const = 0;
110 virtual AuthorizationKind
serviceAuthorization() const = 0;
111 virtual AuthorizationKind
groupAuthorization() const = 0;
113 virtual Logger
*loggerLivestatus() = 0;
115 virtual Triggers
&triggers() = 0;
117 virtual size_t numQueuedNotifications() = 0;
118 virtual size_t numQueuedAlerts() = 0;
120 // Our escape hatch, this should die in the long run...
121 template <typename T
>
123 return static_cast<T
*>(implInternal());
127 virtual void *implInternal() const = 0;
130 #endif // MonitoringCore_h