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 ******************************************************************************/
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 String GetHost2dCoordX(const Host::Ptr& host);
63 static String GetHost2dCoordY(const Host::Ptr& host);
64 static int GetHostNotifyOnDown(const Host::Ptr& host);
65 static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
68 static int GetServiceCurrentState(const Service::Ptr& service);
69 static int GetServiceShouldBeScheduled(const Service::Ptr& service);
70 static int GetServiceCheckType(const Service::Ptr& service);
71 static double GetServiceCheckInterval(const Service::Ptr& service);
72 static double GetServiceRetryInterval(const Service::Ptr& service);
73 static String GetServiceCheckPeriod(const Service::Ptr& service);
74 static int GetServiceHasBeenChecked(const Service::Ptr& service);
75 static int GetServiceProblemHasBeenAcknowledged(const Service::Ptr& service);
76 static int GetServiceAcknowledgementType(const Service::Ptr& service);
77 static int GetServicePassiveChecksEnabled(const Service::Ptr& service);
78 static int GetServiceActiveChecksEnabled(const Service::Ptr& service);
79 static int GetServiceEventHandlerEnabled(const Service::Ptr& service);
80 static int GetServiceFlapDetectionEnabled(const Service::Ptr& service);
81 static int GetServiceIsFlapping(const Service::Ptr& service);
82 static String GetServicePercentStateChange(const Service::Ptr& service);
83 static int GetServiceProcessPerformanceData(const Service::Ptr& service);
85 static String GetServiceEventHandler(const Service::Ptr& service);
86 static String GetServiceCheckCommand(const Service::Ptr& service);
88 static int GetServiceIsVolatile(const Service::Ptr& service);
89 static double GetServiceLowFlapThreshold(const Service::Ptr& service);
90 static double GetServiceHighFlapThreshold(const Service::Ptr& service);
91 static int GetServiceFreshnessChecksEnabled(const Service::Ptr& service);
92 static int GetServiceFreshnessThreshold(const Service::Ptr& service);
93 static double GetServiceStaleness(const Service::Ptr& service);
94 static int GetServiceIsAcknowledged(const Service::Ptr& service);
95 static int GetServiceNoMoreNotifications(const Service::Ptr& service);
96 static int GetServiceInCheckPeriod(const Service::Ptr& service);
97 static int GetServiceInNotificationPeriod(const Service::Ptr& service);
100 static int GetServiceNotificationsEnabled(const Service::Ptr& service);
101 static int GetServiceNotificationLastNotification(const Service::Ptr& service);
102 static int GetServiceNotificationNextNotification(const Service::Ptr& service);
103 static int GetServiceNotificationNotificationNumber(const Service::Ptr& service);
104 static double GetServiceNotificationNotificationInterval(const Service::Ptr& service);
105 static String GetServiceNotificationNotificationPeriod(const Service::Ptr& service);
106 static String GetServiceNotificationNotificationOptions(const Service::Ptr& service);
107 static int GetServiceNotificationTypeFilter(const Service::Ptr& service);
108 static int GetServiceNotificationStateFilter(const Service::Ptr& service);
109 static int GetServiceNotifyOnWarning(const Service::Ptr& service);
110 static int GetServiceNotifyOnCritical(const Service::Ptr& service);
111 static int GetServiceNotifyOnUnknown(const Service::Ptr& service);
112 static int GetServiceNotifyOnRecovery(const Service::Ptr& service);
113 static int GetServiceNotifyOnFlapping(const Service::Ptr& service);
114 static int GetServiceNotifyOnDowntime(const Service::Ptr& service);
116 static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
117 static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
120 static String GetCommandLine(const Command::Ptr& command);
122 /* custom attribute */
123 static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
124 static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);
127 static String GetCheckResultOutput(const CheckResult::Ptr& cr);
128 static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
129 static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
132 static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
134 static int MapNotificationReasonType(NotificationType type);
135 static int MapExternalCommandType(const String& name);
137 static String EscapeString(const String& str);
145 #endif /* COMPATUTILITY_H */