DEL_SVC_DOWNTIME | ;<downtime_id> (1) | -
SCHEDULE_HOST_DOWNTIME | ;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment> (8) | -
DEL_HOST_DOWNTIME | ;<downtime_id> (1) | -
+ DEL_DOWNTIME_BY_HOST_NAME | ;<host_name>[;<service_name;>[;<start_time;>[;<comment_text;>]]] (1) | -
SCHEDULE_HOST_SVC_DOWNTIME | ;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment> (8) | -
SCHEDULE_HOSTGROUP_HOST_DOWNTIME | ;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment> (8) | -
SCHEDULE_HOSTGROUP_SVC_DOWNTIME | ;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment> (8) | -
RegisterCommand("DEL_SVC_DOWNTIME", &ExternalCommandProcessor::DelSvcDowntime, 1);
RegisterCommand("SCHEDULE_HOST_DOWNTIME", &ExternalCommandProcessor::ScheduleHostDowntime, 8);
RegisterCommand("DEL_HOST_DOWNTIME", &ExternalCommandProcessor::DelHostDowntime, 1);
+ RegisterCommand("DEL_DOWNTIME_BY_HOST_NAME", &ExternalCommandProcessor::DelDowntimeByHostName, 1);
RegisterCommand("SCHEDULE_HOST_SVC_DOWNTIME", &ExternalCommandProcessor::ScheduleHostSvcDowntime, 8);
RegisterCommand("SCHEDULE_HOSTGROUP_HOST_DOWNTIME", &ExternalCommandProcessor::ScheduleHostgroupHostDowntime, 8);
RegisterCommand("SCHEDULE_HOSTGROUP_SVC_DOWNTIME", &ExternalCommandProcessor::ScheduleHostgroupSvcDowntime, 8);
Service::RemoveDowntime(rid, true);
}
+void ExternalCommandProcessor::DelDowntimeByHostName(double, const std::vector<String>& arguments)
+{
+ Host::Ptr host = Host::GetByName(arguments[0]);
+
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule host services downtime for non-existent host '" + arguments[0] + "'"));
+
+ String serviceName;
+ if (arguments.size() >= 2)
+ serviceName = arguments[1];
+
+ String startTime;
+ if (arguments.size() >= 3)
+ startTime = arguments[2];
+
+ String commentString;
+ if (arguments.size() >= 4)
+ commentString = arguments[3];
+
+ if (arguments.size() > 5)
+ Log(LogWarning, "ExternalCommandProcessor")
+ << ("Ignoring additional parameters for host '" + arguments[0] + "' downtime deletion.");
+
+ std::vector<String> ids;
+
+ Dictionary::Ptr hostDowntimes = host->GetDowntimes();
+ {
+ ObjectLock dhlock(hostDowntimes);
+ BOOST_FOREACH(const Dictionary::Pair& kv, hostDowntimes) {
+ ids.push_back(kv.first);
+ }
+ }
+
+ BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
+ if (!serviceName.IsEmpty() && serviceName != service->GetName())
+ continue;
+
+ Dictionary::Ptr serviceDowntimes = service->GetDowntimes();
+ {
+ ObjectLock dslock(serviceDowntimes);
+ BOOST_FOREACH(const Dictionary::Pair& kv, serviceDowntimes) {
+ ids.push_back(kv.first);
+ }
+ }
+ }
+
+ BOOST_FOREACH(const String& id, ids) {
+ Downtime::Ptr downtime = Service::GetDowntimeByID(id);
+
+ if (!startTime.IsEmpty() && downtime->GetStartTime() != Convert::ToDouble(startTime))
+ continue;
+
+ if (!commentString.IsEmpty() && downtime->GetComment() != commentString)
+ continue;
+
+ Log(LogNotice, "ExternalCommandProcessor")
+ << "Removing downtime ID " << id;
+ Service::RemoveDowntime(id, true);
+ }
+}
+
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector<String>& arguments)
{
Host::Ptr host = Host::GetByName(arguments[0]);
static void DelSvcDowntime(double time, const std::vector<String>& arguments);
static void ScheduleHostDowntime(double time, const std::vector<String>& arguments);
static void DelHostDowntime(double time, const std::vector<String>& arguments);
+ static void DelDowntimeByHostName(double, const std::vector<String>& arguments);
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);