int id = Convert::ToLong(arguments[0]);
Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
String rid = Service::GetDowntimeIDFromLegacyID(id);
- Service::RemoveDowntime(rid);
+ Service::RemoveDowntime(rid, true);
}
void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vector<String>& arguments)
int id = Convert::ToLong(arguments[0]);
Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
String rid = Service::GetDowntimeIDFromLegacyID(id);
- Service::RemoveDowntime(rid);
+ Service::RemoveDowntime(rid, true);
}
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector<String>& arguments)
l_DowntimesCache[uid] = GetSelf();
}
+ Log(LogWarning, "icinga", "added downtime with ID '" + downtime->Get("legacy_id") + "'.");
+
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeAdded), GetSelf(), downtime, authority));
return uid;
}
-void Service::RemoveDowntime(const String& id, const String& authority)
+void Service::RemoveDowntime(const String& id, const bool& cancelled, const String& authority)
{
Service::Ptr owner = GetOwnerByDowntimeID(id);
l_LegacyDowntimesCache.erase(legacy_id);
l_DowntimesCache.erase(id);
}
-
+
RemoveComment(comment_id);
+ downtime->Set("was_cancelled", cancelled);
+
+ Log(LogWarning, "icinga", "removed downtime with ID '" + downtime->Get("legacy_id") + "' from service '" + owner->GetName() + "'.");
+
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeRemoved), owner, downtime, authority));
}
if (!downtime)
return;
+ if (IsDowntimeActive(downtime) && IsDowntimeTriggered(downtime)) {
+ Log(LogWarning, "icinga", "not triggering downtime with ID '" + downtime->Get("legacy_id") + "': already triggered.");
+ return;
+ }
+
+ if (IsDowntimeExpired(downtime)) {
+ Log(LogWarning, "icinga", "not triggering downtime with ID '" + downtime->Get("legacy_id") + "': expired.");
+ return;
+ }
+
double now = Utility::GetTime();
if (now < downtime->Get("start_time") ||
now > downtime->Get("end_time"))
return;
+ Log(LogWarning, "icinga", "triggering downtime with ID '" + downtime->Get("legacy_id") + "'.");
+
if (downtime->Get("trigger_time") == 0)
downtime->Set("trigger_time", now);
return (triggerTime + downtime->Get("duration") < now);
}
+bool Service::IsDowntimeTriggered(const Dictionary::Ptr& downtime)
+{
+ double now = Utility::GetTime();
+
+ double triggerTime = downtime->Get("trigger_time");
+
+ return (triggerTime > 0 && triggerTime <= now);
+}
+
bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime)
{
return (downtime->Get("end_time") < Utility::GetTime());
if (!expiredDowntimes.empty()) {
BOOST_FOREACH(const String& id, expiredDowntimes) {
- RemoveDowntime(id);
+ RemoveDowntime(id, false);
}
}
}
const String& triggeredBy, double duration,
const String& id = String(), const String& authority = String());
- static void RemoveDowntime(const String& id, const String& = String());
+ static void RemoveDowntime(const String& id, const bool& cancelled, const String& = String());
void TriggerDowntimes(void);
static void TriggerDowntime(const String& id);
static Dictionary::Ptr GetDowntimeByID(const String& id);
static bool IsDowntimeActive(const Dictionary::Ptr& downtime);
+ static bool IsDowntimeTriggered(const Dictionary::Ptr& downtime);
static bool IsDowntimeExpired(const Dictionary::Ptr& downtime);
bool IsInDowntime(void) const;