1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #ifndef EXTERNALCOMMANDPROCESSOR_H
4 #define EXTERNALCOMMANDPROCESSOR_H
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/command.hpp"
8 #include "base/string.hpp"
9 #include <boost/signals2.hpp>
15 typedef std::function<void (double, const std::vector<String>& arguments)> ExternalCommandCallback;
17 struct ExternalCommandInfo
19 ExternalCommandCallback Callback;
24 class ExternalCommandProcessor {
26 static void Execute(const String& line);
27 static void Execute(double time, const String& command, const std::vector<String>& arguments);
29 static boost::signals2::signal<void(double, const String&, const std::vector<String>&)> OnNewExternalCommand;
32 ExternalCommandProcessor();
34 static void ExecuteFromFile(const String& line, std::deque< std::vector<String> >& file_queue);
36 static void ProcessHostCheckResult(double time, const std::vector<String>& arguments);
37 static void ProcessServiceCheckResult(double time, const std::vector<String>& arguments);
38 static void ScheduleHostCheck(double time, const std::vector<String>& arguments);
39 static void ScheduleForcedHostCheck(double time, const std::vector<String>& arguments);
40 static void ScheduleSvcCheck(double time, const std::vector<String>& arguments);
41 static void ScheduleForcedSvcCheck(double time, const std::vector<String>& arguments);
42 static void EnableHostCheck(double time, const std::vector<String>& arguments);
43 static void DisableHostCheck(double time, const std::vector<String>& arguments);
44 static void EnableSvcCheck(double time, const std::vector<String>& arguments);
45 static void DisableSvcCheck(double time, const std::vector<String>& arguments);
46 static void ShutdownProcess(double time, const std::vector<String>& arguments);
47 static void RestartProcess(double time, const std::vector<String>& arguments);
48 static void ScheduleForcedHostSvcChecks(double time, const std::vector<String>& arguments);
49 static void ScheduleHostSvcChecks(double time, const std::vector<String>& arguments);
50 static void EnableHostSvcChecks(double time, const std::vector<String>& arguments);
51 static void DisableHostSvcChecks(double time, const std::vector<String>& arguments);
52 static void AcknowledgeSvcProblem(double time, const std::vector<String>& arguments);
53 static void AcknowledgeSvcProblemExpire(double time, const std::vector<String>& arguments);
54 static void RemoveSvcAcknowledgement(double time, const std::vector<String>& arguments);
55 static void AcknowledgeHostProblem(double time, const std::vector<String>& arguments);
56 static void AcknowledgeHostProblemExpire(double time, const std::vector<String>& arguments);
57 static void RemoveHostAcknowledgement(double time, const std::vector<String>& arguments);
58 static void EnableHostgroupSvcChecks(double time, const std::vector<String>& arguments);
59 static void DisableHostgroupSvcChecks(double time, const std::vector<String>& arguments);
60 static void EnableServicegroupSvcChecks(double time, const std::vector<String>& arguments);
61 static void DisableServicegroupSvcChecks(double time, const std::vector<String>& arguments);
62 static void EnablePassiveHostChecks(double time, const std::vector<String>& arguments);
63 static void DisablePassiveHostChecks(double time, const std::vector<String>& arguments);
64 static void EnablePassiveSvcChecks(double time, const std::vector<String>& arguments);
65 static void DisablePassiveSvcChecks(double time, const std::vector<String>& arguments);
66 static void EnableServicegroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
67 static void DisableServicegroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
68 static void EnableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
69 static void DisableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
70 static void ProcessFile(double time, const std::vector<String>& arguments);
71 static void ScheduleSvcDowntime(double time, const std::vector<String>& arguments);
72 static void DelSvcDowntime(double time, const std::vector<String>& arguments);
73 static void ScheduleHostDowntime(double time, const std::vector<String>& arguments);
74 static void ScheduleAndPropagateHostDowntime(double, const std::vector<String>& arguments);
75 static void ScheduleAndPropagateTriggeredHostDowntime(double, const std::vector<String>& arguments);
76 static void DelHostDowntime(double time, const std::vector<String>& arguments);
77 static void DelDowntimeByHostName(double, const std::vector<String>& arguments);
78 static void ScheduleHostSvcDowntime(double time, const std::vector<String>& arguments);
79 static void ScheduleHostgroupHostDowntime(double time, const std::vector<String>& arguments);
80 static void ScheduleHostgroupSvcDowntime(double time, const std::vector<String>& arguments);
81 static void ScheduleServicegroupHostDowntime(double time, const std::vector<String>& arguments);
82 static void ScheduleServicegroupSvcDowntime(double time, const std::vector<String>& arguments);
83 static void AddHostComment(double time, const std::vector<String>& arguments);
84 static void DelHostComment(double time, const std::vector<String>& arguments);
85 static void AddSvcComment(double time, const std::vector<String>& arguments);
86 static void DelSvcComment(double time, const std::vector<String>& arguments);
87 static void DelAllHostComments(double time, const std::vector<String>& arguments);
88 static void DelAllSvcComments(double time, const std::vector<String>& arguments);
89 static void SendCustomHostNotification(double time, const std::vector<String>& arguments);
90 static void SendCustomSvcNotification(double time, const std::vector<String>& arguments);
91 static void DelayHostNotification(double time, const std::vector<String>& arguments);
92 static void DelaySvcNotification(double time, const std::vector<String>& arguments);
93 static void EnableHostNotifications(double time, const std::vector<String>& arguments);
94 static void DisableHostNotifications(double time, const std::vector<String>& arguments);
95 static void EnableSvcNotifications(double time, const std::vector<String>& arguments);
96 static void DisableSvcNotifications(double time, const std::vector<String>& arguments);
97 static void EnableHostSvcNotifications(double, const std::vector<String>& arguments);
98 static void DisableHostSvcNotifications(double, const std::vector<String>& arguments);
99 static void DisableHostgroupHostChecks(double, const std::vector<String>& arguments);
100 static void DisableHostgroupPassiveHostChecks(double, const std::vector<String>& arguments);
101 static void DisableServicegroupHostChecks(double, const std::vector<String>& arguments);
102 static void DisableServicegroupPassiveHostChecks(double, const std::vector<String>& arguments);
103 static void EnableHostgroupHostChecks(double, const std::vector<String>& arguments);
104 static void EnableHostgroupPassiveHostChecks(double, const std::vector<String>& arguments);
105 static void EnableServicegroupHostChecks(double, const std::vector<String>& arguments);
106 static void EnableServicegroupPassiveHostChecks(double, const std::vector<String>& arguments);
107 static void EnableSvcFlapping(double time, const std::vector<String>& arguments);
108 static void DisableSvcFlapping(double time, const std::vector<String>& arguments);
109 static void EnableHostFlapping(double time, const std::vector<String>& arguments);
110 static void DisableHostFlapping(double time, const std::vector<String>& arguments);
111 static void EnableNotifications(double time, const std::vector<String>& arguments);
112 static void DisableNotifications(double time, const std::vector<String>& arguments);
113 static void EnableFlapDetection(double time, const std::vector<String>& arguments);
114 static void DisableFlapDetection(double time, const std::vector<String>& arguments);
115 static void EnableEventHandlers(double time, const std::vector<String>& arguments);
116 static void DisableEventHandlers(double time, const std::vector<String>& arguments);
117 static void EnablePerformanceData(double time, const std::vector<String>& arguments);
118 static void DisablePerformanceData(double time, const std::vector<String>& arguments);
119 static void StartExecutingSvcChecks(double time, const std::vector<String>& arguments);
120 static void StopExecutingSvcChecks(double time, const std::vector<String>& arguments);
121 static void StartExecutingHostChecks(double time, const std::vector<String>& arguments);
122 static void StopExecutingHostChecks(double time, const std::vector<String>& arguments);
124 static void ChangeNormalSvcCheckInterval(double time, const std::vector<String>& arguments);
125 static void ChangeNormalHostCheckInterval(double time, const std::vector<String>& arguments);
126 static void ChangeRetrySvcCheckInterval(double time, const std::vector<String>& arguments);
127 static void ChangeRetryHostCheckInterval(double time, const std::vector<String>& arguments);
128 static void EnableHostEventHandler(double time, const std::vector<String>& arguments);
129 static void DisableHostEventHandler(double time, const std::vector<String>& arguments);
130 static void EnableSvcEventHandler(double time, const std::vector<String>& arguments);
131 static void DisableSvcEventHandler(double time, const std::vector<String>& arguments);
132 static void ChangeHostEventHandler(double time, const std::vector<String>& arguments);
133 static void ChangeSvcEventHandler(double time, const std::vector<String>& arguments);
134 static void ChangeHostCheckCommand(double time, const std::vector<String>& arguments);
135 static void ChangeSvcCheckCommand(double time, const std::vector<String>& arguments);
136 static void ChangeMaxHostCheckAttempts(double time, const std::vector<String>& arguments);
137 static void ChangeMaxSvcCheckAttempts(double time, const std::vector<String>& arguments);
138 static void ChangeHostCheckTimeperiod(double time, const std::vector<String>& arguments);
139 static void ChangeSvcCheckTimeperiod(double time, const std::vector<String>& arguments);
140 static void ChangeCustomHostVar(double time, const std::vector<String>& arguments);
141 static void ChangeCustomSvcVar(double time, const std::vector<String>& arguments);
142 static void ChangeCustomUserVar(double time, const std::vector<String>& arguments);
143 static void ChangeCustomCheckcommandVar(double time, const std::vector<String>& arguments);
144 static void ChangeCustomEventcommandVar(double time, const std::vector<String>& arguments);
145 static void ChangeCustomNotificationcommandVar(double time, const std::vector<String>& arguments);
147 static void EnableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
148 static void EnableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
149 static void DisableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
150 static void DisableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
151 static void EnableServicegroupHostNotifications(double time, const std::vector<String>& arguments);
152 static void EnableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
153 static void DisableServicegroupHostNotifications(double time, const std::vector<String>& arguments);
154 static void DisableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
157 static void ChangeCustomCommandVarInternal(const Command::Ptr& command, const String& name, const Value& value);
159 static void RegisterCommand(const String& command, const ExternalCommandCallback& callback, size_t minArgs = 0, size_t maxArgs = UINT_MAX);
160 static void RegisterCommands();
162 static boost::mutex& GetMutex();
163 static std::map<String, ExternalCommandInfo>& GetCommands();
169 #endif /* EXTERNALCOMMANDPROCESSOR_H */