]> granicus.if.org Git - icinga2/blob - lib/icinga/compatutility.h
Update components to use the new address fields.
[icinga2] / lib / icinga / compatutility.h
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2014 Icinga Development Team (http://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 COMPATUTILITY_H
21 #define COMPATUTILITY_H
22
23 #include "icinga/i2-icinga.h"
24 #include "icinga/service.h"
25 #include "icinga/checkcommand.h"
26 #include "base/dictionary.h"
27 #include "base/dynamicobject.h"
28 #include <vector>
29
30 namespace icinga
31 {
32
33 /**
34  * @ingroup icinga
35  */
36 struct Host2dCoords {
37         int have_2d_coords;
38         String x_2d;
39         String y_2d;
40 };
41
42 /**
43  * Compatibility utility functions.
44  *
45  * @ingroup icinga
46  */
47 class I2_ICINGA_API CompatUtility
48 {
49 public:
50
51         /* host */
52         static String GetHostAlias(const Host::Ptr& host);
53         static Host2dCoords GetHost2dCoords(const Host::Ptr& host);
54         static String GetHost2dCoordX(const Host::Ptr& host);
55         static String GetHost2dCoordY(const Host::Ptr& host);
56         static int GetHostNotifyOnDown(const Host::Ptr& host);
57         static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
58
59         /* service */
60         static int GetCheckableCheckType(const Checkable::Ptr& checkable);
61         static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
62         static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
63         static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
64         static int GetCheckableHasBeenChecked(const Checkable::Ptr& checkable);
65         static int GetCheckableProblemHasBeenAcknowledged(const Checkable::Ptr& checkable);
66         static int GetCheckableAcknowledgementType(const Checkable::Ptr& checkable);
67         static int GetCheckablePassiveChecksEnabled(const Checkable::Ptr& checkable);
68         static int GetCheckableActiveChecksEnabled(const Checkable::Ptr& checkable);
69         static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable);
70         static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable);
71         static int GetCheckableIsFlapping(const Checkable::Ptr& checkable);
72         static String GetCheckablePercentStateChange(const Checkable::Ptr& checkable);
73         static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable);
74
75         static String GetCheckableEventHandler(const Checkable::Ptr& checkable);
76         static String GetCheckableCheckCommand(const Checkable::Ptr& checkable);
77
78         static int GetCheckableIsVolatile(const Checkable::Ptr& checkable);
79         static double GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable);
80         static double GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable);
81         static int GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable);
82         static int GetCheckableFreshnessThreshold(const Checkable::Ptr& checkable);
83         static double GetCheckableStaleness(const Checkable::Ptr& checkable);
84         static int GetCheckableIsAcknowledged(const Checkable::Ptr& checkable);
85         static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
86         static int GetCheckableInCheckPeriod(const Checkable::Ptr& checkable);
87         static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
88
89         /* notification */
90         static int GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable);
91         static int GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable);
92         static int GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable);
93         static int GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable);
94         static double GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable);
95         static String GetCheckableNotificationNotificationPeriod(const Checkable::Ptr& checkable);
96         static String GetCheckableNotificationNotificationOptions(const Checkable::Ptr& checkable);
97         static int GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable);
98         static int GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable);
99         static int GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable);
100         static int GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable);
101         static int GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable);
102         static int GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable);
103         static int GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable);
104         static int GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable);
105
106         static std::set<User::Ptr> GetCheckableNotificationUsers(const Checkable::Ptr& checkable);
107         static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
108
109         /* command */
110         static String GetCommandLine(const Command::Ptr& command);
111
112         /* custom attribute */
113         static bool IsLegacyAttribute(const DynamicObject::Ptr& object, const String& name);
114         static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
115         static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);
116
117         /* check result */
118         static String GetCheckResultOutput(const CheckResult::Ptr& cr);
119         static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
120         static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
121
122         /* misc */
123         static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
124
125         static int MapNotificationReasonType(NotificationType type);
126         static int MapExternalCommandType(const String& name);
127
128         static String EscapeString(const String& str);
129
130 private:
131         CompatUtility(void);
132 };
133
134 }
135
136 #endif /* COMPATUTILITY_H */