1 /******************************************************************************
3 * Copyright (C) 2012-present 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 ******************************************************************************/
20 #ifndef COMPATUTILITY_H
21 #define COMPATUTILITY_H
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"
49 * Compatibility utility functions.
53 class I2_ICINGA_API CompatUtility
58 static String GetHostAlias(const Host::Ptr& host);
59 static String GetHostAddress(const Host::Ptr& host);
60 static String GetHostAddress6(const Host::Ptr& host);
61 static Host2dCoords GetHost2dCoords(const Host::Ptr& host);
62 static int GetHostNotifyOnDown(const Host::Ptr& host);
63 static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
66 static int GetServiceCurrentState(const Service::Ptr& service);
67 static int GetServiceShouldBeScheduled(const Service::Ptr& service);
68 static int GetServiceCheckType(const Service::Ptr& service);
69 static double GetServiceCheckInterval(const Service::Ptr& service);
70 static double GetServiceRetryInterval(const Service::Ptr& service);
71 static String GetServiceCheckPeriod(const Service::Ptr& service);
72 static int GetServiceHasBeenChecked(const Service::Ptr& service);
73 static int GetServiceProblemHasBeenAcknowledged(const Service::Ptr& service);
74 static int GetServiceAcknowledgementType(const Service::Ptr& service);
75 static int GetServicePassiveChecksEnabled(const Service::Ptr& service);
76 static int GetServiceActiveChecksEnabled(const Service::Ptr& service);
77 static int GetServiceEventHandlerEnabled(const Service::Ptr& service);
78 static int GetServiceFlapDetectionEnabled(const Service::Ptr& service);
79 static int GetServiceIsFlapping(const Service::Ptr& service);
80 static String GetServicePercentStateChange(const Service::Ptr& service);
81 static int GetServiceProcessPerformanceData(const Service::Ptr& service);
83 static String GetServiceEventHandler(const Service::Ptr& service);
84 static String GetServiceCheckCommand(const Service::Ptr& service);
86 static int GetServiceIsVolatile(const Service::Ptr& service);
87 static double GetServiceLowFlapThreshold(const Service::Ptr& service);
88 static double GetServiceHighFlapThreshold(const Service::Ptr& service);
89 static int GetServiceFreshnessChecksEnabled(const Service::Ptr& service);
90 static int GetServiceFreshnessThreshold(const Service::Ptr& service);
91 static double GetServiceStaleness(const Service::Ptr& service);
92 static int GetServiceIsAcknowledged(const Service::Ptr& service);
93 static int GetServiceNoMoreNotifications(const Service::Ptr& service);
94 static int GetServiceInCheckPeriod(const Service::Ptr& service);
95 static int GetServiceInNotificationPeriod(const Service::Ptr& service);
98 static int GetServiceNotificationsEnabled(const Service::Ptr& service);
99 static int GetServiceNotificationLastNotification(const Service::Ptr& service);
100 static int GetServiceNotificationNextNotification(const Service::Ptr& service);
101 static int GetServiceNotificationNotificationNumber(const Service::Ptr& service);
102 static double GetServiceNotificationNotificationInterval(const Service::Ptr& service);
103 static String GetServiceNotificationNotificationPeriod(const Service::Ptr& service);
104 static String GetServiceNotificationNotificationOptions(const Service::Ptr& service);
105 static int GetServiceNotificationTypeFilter(const Service::Ptr& service);
106 static int GetServiceNotificationStateFilter(const Service::Ptr& service);
107 static int GetServiceNotifyOnWarning(const Service::Ptr& service);
108 static int GetServiceNotifyOnCritical(const Service::Ptr& service);
109 static int GetServiceNotifyOnUnknown(const Service::Ptr& service);
110 static int GetServiceNotifyOnRecovery(const Service::Ptr& service);
111 static int GetServiceNotifyOnFlapping(const Service::Ptr& service);
112 static int GetServiceNotifyOnDowntime(const Service::Ptr& service);
114 static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
115 static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
118 static String GetCommandLine(const Command::Ptr& command);
120 /* custom attribute */
121 static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
122 static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
125 static String GetCheckResultOutput(const CheckResult::Ptr& cr);
126 static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
127 static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
130 static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
132 static int MapNotificationReasonType(NotificationType type);
133 static int MapExternalCommandType(const String& name);
135 static String EscapeString(const String& str);
143 #endif /* COMPATUTILITY_H */