2013-07-23 09:12:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2015-01-22 12:00:23 +01:00
|
|
|
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
2013-07-23 09:12:38 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef COMPATUTILITY_H
|
|
|
|
#define COMPATUTILITY_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
|
|
|
#include "icinga/customvarobject.hpp"
|
|
|
|
#include "icinga/host.hpp"
|
|
|
|
#include "icinga/command.hpp"
|
|
|
|
#include "base/dictionary.hpp"
|
|
|
|
#include "base/array.hpp"
|
2013-07-23 09:12:38 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compatibility utility functions.
|
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
|
|
|
class I2_ICINGA_API CompatUtility
|
|
|
|
{
|
|
|
|
public:
|
2014-05-12 14:30:15 +02:00
|
|
|
/* command */
|
|
|
|
static String GetCommandLine(const Command::Ptr& command);
|
|
|
|
static String GetCommandName(const Command::Ptr command);
|
2013-07-30 18:17:13 +02:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
/* host */
|
2015-09-04 13:24:41 +02:00
|
|
|
static int GetHostCurrentState(const Host::Ptr& host);
|
|
|
|
static String GetHostStateString(const Host::Ptr& host);
|
2013-12-05 14:54:16 +01:00
|
|
|
static String GetHostAlias(const Host::Ptr& host);
|
|
|
|
static int GetHostNotifyOnDown(const Host::Ptr& host);
|
|
|
|
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
|
|
|
|
|
|
|
/* service */
|
2014-08-17 17:57:20 +02:00
|
|
|
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
|
2014-04-03 15:36:13 +02:00
|
|
|
static int GetCheckableCheckType(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
|
|
|
|
static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableHasBeenChecked(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableProblemHasBeenAcknowledged(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableAcknowledgementType(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckablePassiveChecksEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableActiveChecksEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableIsFlapping(const Checkable::Ptr& checkable);
|
2014-08-17 17:57:20 +02:00
|
|
|
static int GetCheckableIsReachable(const Checkable::Ptr& checkable);
|
2014-09-08 09:58:53 +02:00
|
|
|
static double GetCheckablePercentStateChange(const Checkable::Ptr& checkable);
|
2014-04-03 15:36:13 +02:00
|
|
|
static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable);
|
|
|
|
|
|
|
|
static String GetCheckableEventHandler(const Checkable::Ptr& checkable);
|
|
|
|
static String GetCheckableCheckCommand(const Checkable::Ptr& checkable);
|
|
|
|
|
|
|
|
static int GetCheckableIsVolatile(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableFreshnessThreshold(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableStaleness(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableIsAcknowledged(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableInCheckPeriod(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
|
2013-12-05 14:54:16 +01:00
|
|
|
|
2014-05-12 16:45:25 +02:00
|
|
|
static Array::Ptr GetModifiedAttributesList(const CustomVarObject::Ptr& object);
|
2014-04-17 16:01:44 +02:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
/* notification */
|
2014-04-03 15:36:13 +02:00
|
|
|
static int GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable);
|
|
|
|
static double GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable);
|
|
|
|
static String GetCheckableNotificationNotificationPeriod(const Checkable::Ptr& checkable);
|
|
|
|
static String GetCheckableNotificationNotificationOptions(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable);
|
|
|
|
static int GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable);
|
|
|
|
|
|
|
|
static std::set<User::Ptr> GetCheckableNotificationUsers(const Checkable::Ptr& checkable);
|
|
|
|
static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
|
2013-10-01 15:37:50 +02:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
/* custom attribute */
|
2014-05-12 16:45:25 +02:00
|
|
|
static String GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name);
|
|
|
|
static Dictionary::Ptr GetCustomAttributeConfig(const CustomVarObject::Ptr& object);
|
2013-12-05 14:54:16 +01:00
|
|
|
|
|
|
|
/* check result */
|
|
|
|
static String GetCheckResultOutput(const CheckResult::Ptr& cr);
|
|
|
|
static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
|
2013-11-09 14:22:38 +01:00
|
|
|
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
2013-09-24 18:48:24 +02:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
/* misc */
|
2013-11-11 15:06:23 +01:00
|
|
|
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-09-24 18:48:24 +02:00
|
|
|
static int MapNotificationReasonType(NotificationType type);
|
2013-09-30 20:25:53 +02:00
|
|
|
static int MapExternalCommandType(const String& name);
|
2013-09-24 18:48:24 +02:00
|
|
|
|
2013-07-23 09:12:38 +02:00
|
|
|
static String EscapeString(const String& str);
|
2015-05-27 16:05:10 +02:00
|
|
|
static String UnEscapeString(const String& str);
|
2013-07-23 09:12:38 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
CompatUtility(void);
|
2014-05-12 14:30:15 +02:00
|
|
|
|
|
|
|
static String GetCommandNamePrefix(const Command::Ptr command);
|
2013-07-23 09:12:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* COMPATUTILITY_H */
|