fields1->Set("duration", downtime->GetDuration());
fields1->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
fields1->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
- fields1->Set("was_started", 0);
- fields1->Set("is_in_effect", 0);
+ fields1->Set("was_started", ((downtime->GetStartTime() <= Utility::GetTime()) ? 1 : 0));
+ fields1->Set("is_in_effect", (downtime->IsActive() ? 1 : 0));
+ fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
String node = IcingaApplication::GetInstance()->GetNodeName();
query1.Fields = fields1;
queries.push_back(query1);
+
+ /* host/service status */
+ if (!historical) {
+ Host::Ptr host;
+ Service::Ptr service;
+ tie(host, service) = GetHostService(checkable);
+
+ DbQuery query2;
+ if (service)
+ query2.Table = "servicestatus";
+ else
+ query2.Table = "hoststatus";
+
+ query2.Type = DbQueryUpdate;
+ query2.Category = DbCatState;
+ query2.StatusUpdate = true;
+ query2.Object = DbObject::GetOrCreateByObject(checkable);
+
+ Dictionary::Ptr fields2 = new Dictionary();
+ fields2->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
+
+ query2.Fields = fields2;
+
+ query2.WhereCriteria = new Dictionary();
+ if (service)
+ query2.WhereCriteria->Set("service_object_id", service);
+ else
+ query2.WhereCriteria->Set("host_object_id", host);
+
+ query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
+
+ queries.push_back(query2);
+ }
}
void DbEvents::RemoveDowntime(const Downtime::Ptr& downtime)
fields3->Set("was_cancelled", downtime->GetWasCancelled() ? 1 : 0);
fields3->Set("actual_end_time", DbValue::FromTimestamp(time_bag.first));
fields3->Set("actual_end_time_usec", time_bag.second);
+ fields3->Set("is_in_effect", 0);
query3.Fields = fields3;
query3.WhereCriteria = new Dictionary();
fields1->Set("was_started", 1);
fields1->Set("actual_start_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("actual_start_time_usec", time_bag.second);
- fields1->Set("is_in_effect", 1);
+ fields1->Set("is_in_effect", (downtime->IsActive() ? 1 : 0));
fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */