2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-01-22 02:34:29 -05:00
|
|
|
|
2013-01-29 09:00:39 -05:00
|
|
|
#ifndef EXTERNALCOMMANDPROCESSOR_H
|
|
|
|
|
#define EXTERNALCOMMANDPROCESSOR_H
|
2013-01-22 02:34:29 -05:00
|
|
|
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
|
|
|
|
#include "icinga/command.hpp"
|
2025-05-22 11:56:16 -04:00
|
|
|
#include "base/wait-group.hpp"
|
2014-10-19 08:48:19 -04:00
|
|
|
#include "base/string.hpp"
|
2013-09-30 13:32:32 -04:00
|
|
|
#include <boost/signals2.hpp>
|
2013-03-18 06:02:18 -04:00
|
|
|
#include <vector>
|
2013-03-17 15:19:29 -04:00
|
|
|
|
2013-01-22 02:34:29 -05:00
|
|
|
namespace icinga
|
|
|
|
|
{
|
2013-02-09 09:20:10 -05:00
|
|
|
|
2025-05-22 11:56:16 -04:00
|
|
|
typedef std::function<void(const WaitGroup::Ptr&, double, const std::vector<String>& arguments)> ExternalCommandCallback;
|
|
|
|
|
typedef std::function<void(double, const std::vector<String>& arguments)> ExternalCommandCallbackLite;
|
2017-11-23 03:31:39 -05:00
|
|
|
|
|
|
|
|
struct ExternalCommandInfo
|
|
|
|
|
{
|
|
|
|
|
ExternalCommandCallback Callback;
|
|
|
|
|
size_t MinArgs;
|
|
|
|
|
size_t MaxArgs;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-31 01:22:16 -05:00
|
|
|
class ExternalCommandProcessor {
|
2013-01-22 02:34:29 -05:00
|
|
|
public:
|
2025-05-22 11:56:16 -04:00
|
|
|
static void Execute(const WaitGroup::Ptr& producer, const String& line);
|
|
|
|
|
static void Execute(const WaitGroup::Ptr& producer, double time, const String& command, const std::vector<String>& arguments);
|
2013-01-22 02:34:29 -05:00
|
|
|
|
2014-05-03 14:02:22 -04:00
|
|
|
static boost::signals2::signal<void(double, const String&, const std::vector<String>&)> OnNewExternalCommand;
|
2013-09-30 13:32:32 -04:00
|
|
|
|
2013-02-17 13:14:34 -05:00
|
|
|
private:
|
2018-01-03 22:25:35 -05:00
|
|
|
ExternalCommandProcessor();
|
2013-02-17 13:14:34 -05:00
|
|
|
|
2025-05-22 11:56:16 -04:00
|
|
|
static void ExecuteFromFile(const WaitGroup::Ptr& producer, const String& line, std::deque<std::vector<String>>& file_queue);
|
2015-10-27 13:00:55 -04:00
|
|
|
|
2025-05-22 11:56:16 -04:00
|
|
|
static void ProcessHostCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ProcessServiceCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
2013-03-16 16:18:53 -04:00
|
|
|
static void ScheduleHostCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleForcedHostCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleSvcCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleForcedSvcCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableSvcCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableSvcCheck(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ShutdownProcess(double time, const std::vector<String>& arguments);
|
2013-08-30 08:27:24 -04:00
|
|
|
static void RestartProcess(double time, const std::vector<String>& arguments);
|
2013-03-16 16:18:53 -04:00
|
|
|
static void ScheduleForcedHostSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleHostSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AcknowledgeSvcProblem(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AcknowledgeSvcProblemExpire(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void RemoveSvcAcknowledgement(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AcknowledgeHostProblem(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AcknowledgeHostProblemExpire(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void RemoveHostAcknowledgement(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostgroupSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostgroupSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnablePassiveHostChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisablePassiveHostChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnablePassiveSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisablePassiveSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
2025-05-22 11:56:16 -04:00
|
|
|
static void ProcessFile(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
2013-03-16 16:18:53 -04:00
|
|
|
static void ScheduleSvcDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelSvcDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleHostDowntime(double time, const std::vector<String>& arguments);
|
2016-07-21 11:01:49 -04:00
|
|
|
static void ScheduleAndPropagateHostDowntime(double, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleAndPropagateTriggeredHostDowntime(double, const std::vector<String>& arguments);
|
2013-03-16 16:18:53 -04:00
|
|
|
static void DelHostDowntime(double time, const std::vector<String>& arguments);
|
2015-07-31 08:46:38 -04:00
|
|
|
static void DelDowntimeByHostName(double, const std::vector<String>& arguments);
|
2013-03-16 16:18:53 -04:00
|
|
|
static void ScheduleHostSvcDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleHostgroupHostDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleHostgroupSvcDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleServicegroupHostDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ScheduleServicegroupSvcDowntime(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AddHostComment(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelHostComment(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void AddSvcComment(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelSvcComment(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelAllHostComments(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelAllSvcComments(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void SendCustomHostNotification(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void SendCustomSvcNotification(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelayHostNotification(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DelaySvcNotification(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableSvcNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableSvcNotifications(double time, const std::vector<String>& arguments);
|
2015-02-11 10:45:52 -05:00
|
|
|
static void EnableHostSvcNotifications(double, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostSvcNotifications(double, const std::vector<String>& arguments);
|
2013-04-15 04:23:06 -04:00
|
|
|
static void DisableHostgroupHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostgroupPassiveHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupPassiveHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostgroupHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostgroupPassiveHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupHostChecks(double, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupPassiveHostChecks(double, const std::vector<String>& arguments);
|
2013-06-21 04:28:21 -04:00
|
|
|
static void EnableSvcFlapping(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableSvcFlapping(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostFlapping(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostFlapping(double time, const std::vector<String>& arguments);
|
2013-10-08 05:57:35 -04:00
|
|
|
static void EnableNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableFlapDetection(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableFlapDetection(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableEventHandlers(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableEventHandlers(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnablePerformanceData(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisablePerformanceData(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void StartExecutingSvcChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void StopExecutingSvcChecks(double time, const std::vector<String>& arguments);
|
2014-04-17 05:29:47 -04:00
|
|
|
static void StartExecutingHostChecks(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void StopExecutingHostChecks(double time, const std::vector<String>& arguments);
|
2014-04-17 09:20:28 -04:00
|
|
|
|
2013-10-16 07:02:21 -04:00
|
|
|
static void ChangeNormalSvcCheckInterval(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeNormalHostCheckInterval(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeRetrySvcCheckInterval(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeRetryHostCheckInterval(double time, const std::vector<String>& arguments);
|
2013-10-16 09:20:14 -04:00
|
|
|
static void EnableHostEventHandler(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostEventHandler(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableSvcEventHandler(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableSvcEventHandler(double time, const std::vector<String>& arguments);
|
2013-11-26 06:31:17 -05:00
|
|
|
static void ChangeHostEventHandler(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeSvcEventHandler(double time, const std::vector<String>& arguments);
|
2013-11-26 06:56:42 -05:00
|
|
|
static void ChangeHostCheckCommand(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeSvcCheckCommand(double time, const std::vector<String>& arguments);
|
2013-11-26 07:27:41 -05:00
|
|
|
static void ChangeMaxHostCheckAttempts(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeMaxSvcCheckAttempts(double time, const std::vector<String>& arguments);
|
2013-11-26 07:43:56 -05:00
|
|
|
static void ChangeHostCheckTimeperiod(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeSvcCheckTimeperiod(double time, const std::vector<String>& arguments);
|
2014-08-17 11:57:20 -04:00
|
|
|
static void ChangeCustomHostVar(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeCustomSvcVar(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeCustomUserVar(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeCustomCheckcommandVar(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeCustomEventcommandVar(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void ChangeCustomNotificationcommandVar(double time, const std::vector<String>& arguments);
|
2014-04-15 11:33:56 -04:00
|
|
|
|
2014-01-20 10:58:18 -05:00
|
|
|
static void EnableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void EnableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupHostNotifications(double time, const std::vector<String>& arguments);
|
|
|
|
|
static void DisableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
|
2014-04-17 09:20:28 -04:00
|
|
|
|
|
|
|
|
private:
|
2014-08-17 11:57:20 -04:00
|
|
|
static void ChangeCustomCommandVarInternal(const Command::Ptr& command, const String& name, const Value& value);
|
2017-11-23 03:31:39 -05:00
|
|
|
|
|
|
|
|
static void RegisterCommand(const String& command, const ExternalCommandCallback& callback, size_t minArgs = 0, size_t maxArgs = UINT_MAX);
|
2025-05-22 11:56:16 -04:00
|
|
|
static void RegisterCommand(const String& command, const ExternalCommandCallbackLite& callback, size_t minArgs = 0, size_t maxArgs = UINT_MAX);
|
2018-01-03 22:25:35 -05:00
|
|
|
static void RegisterCommands();
|
2017-11-23 03:31:39 -05:00
|
|
|
|
2021-02-02 04:16:04 -05:00
|
|
|
static std::mutex& GetMutex();
|
2018-01-03 22:25:35 -05:00
|
|
|
static std::map<String, ExternalCommandInfo>& GetCommands();
|
2017-11-23 03:31:39 -05:00
|
|
|
|
2013-01-22 02:34:29 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-29 09:00:39 -05:00
|
|
|
#endif /* EXTERNALCOMMANDPROCESSOR_H */
|