2013-01-29 14:50:51 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
#include "icinga/service.h"
|
|
|
|
#include "base/dynamictype.h"
|
|
|
|
#include "base/objectlock.h"
|
|
|
|
#include "base/logger_fwd.h"
|
2013-03-18 11:02:18 +01:00
|
|
|
#include "base/timer.h"
|
2013-03-25 18:36:15 +01:00
|
|
|
#include "base/utility.h"
|
2013-03-15 18:21:29 +01:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
2013-03-16 21:18:53 +01:00
|
|
|
#include <boost/smart_ptr/make_shared.hpp>
|
|
|
|
#include <boost/foreach.hpp>
|
2013-01-29 14:50:51 +01:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
static int l_NextDowntimeID = 1;
|
|
|
|
static boost::mutex l_DowntimeMutex;
|
|
|
|
static std::map<int, String> l_LegacyDowntimesCache;
|
|
|
|
static std::map<String, Service::WeakPtr> l_DowntimesCache;
|
|
|
|
static bool l_DowntimesCacheNeedsUpdate = false;
|
|
|
|
static Timer::Ptr l_DowntimesCacheTimer;
|
|
|
|
static Timer::Ptr l_DowntimesExpireTimer;
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
int Service::GetNextDowntimeID(void)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
2013-03-02 09:07:47 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
return l_NextDowntimeID;
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 18:39:43 +01:00
|
|
|
Dictionary::Ptr Service::GetDowntimes(void) const
|
|
|
|
{
|
2013-02-26 10:13:54 +01:00
|
|
|
return m_Downtimes;
|
2013-02-09 18:39:43 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
String Service::AddDowntime(const String& author, const String& comment,
|
|
|
|
double startTime, double endTime, bool fixed,
|
|
|
|
const String& triggeredBy, double duration)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
|
|
|
Dictionary::Ptr downtime = boost::make_shared<Dictionary>();
|
|
|
|
downtime->Set("entry_time", Utility::GetTime());
|
|
|
|
downtime->Set("author", author);
|
|
|
|
downtime->Set("comment", comment);
|
|
|
|
downtime->Set("start_time", startTime);
|
|
|
|
downtime->Set("end_time", endTime);
|
|
|
|
downtime->Set("fixed", fixed);
|
|
|
|
downtime->Set("duration", duration);
|
|
|
|
downtime->Set("triggered_by", triggeredBy);
|
2013-01-31 13:57:14 +01:00
|
|
|
downtime->Set("triggers", boost::make_shared<Dictionary>());
|
2013-01-29 14:50:51 +01:00
|
|
|
downtime->Set("trigger_time", 0);
|
2013-02-27 12:44:51 +01:00
|
|
|
|
|
|
|
int legacy_id;
|
|
|
|
|
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
|
|
|
legacy_id = l_NextDowntimeID++;
|
2013-02-27 12:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
downtime->Set("legacy_id", legacy_id);
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
if (!triggeredBy.IsEmpty()) {
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr otherOwner = GetOwnerByDowntimeID(triggeredBy);
|
2013-01-31 13:57:14 +01:00
|
|
|
Dictionary::Ptr otherDowntimes = otherOwner->Get("downtimes");
|
|
|
|
Dictionary::Ptr otherDowntime = otherDowntimes->Get(triggeredBy);
|
|
|
|
Dictionary::Ptr triggers = otherDowntime->Get("triggers");
|
2013-06-19 10:42:28 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
ObjectLock olock(otherOwner);
|
|
|
|
triggers->Set(triggeredBy, triggeredBy);
|
|
|
|
otherOwner->Touch("downtimes");
|
|
|
|
}
|
2013-01-31 13:57:14 +01:00
|
|
|
}
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-03-04 15:52:42 +01:00
|
|
|
Dictionary::Ptr downtimes;
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-03-04 15:52:42 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(this);
|
|
|
|
|
|
|
|
downtimes = m_Downtimes;
|
|
|
|
|
|
|
|
if (!downtimes)
|
|
|
|
downtimes = boost::make_shared<Dictionary>();
|
|
|
|
|
|
|
|
m_Downtimes = downtimes;
|
|
|
|
}
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-05-03 11:26:18 +02:00
|
|
|
String id = Utility::NewUniqueID();
|
2013-01-30 09:59:22 +01:00
|
|
|
downtimes->Set(id, downtime);
|
2013-02-26 10:13:54 +01:00
|
|
|
|
2013-06-19 10:42:28 +02:00
|
|
|
{
|
|
|
|
ObjectLock olock(this);
|
|
|
|
Touch("downtimes");
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) AddComment(CommentDowntime, author, comment, endTime);
|
2013-01-29 15:00:06 +01:00
|
|
|
|
|
|
|
return id;
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
void Service::RemoveDowntime(const String& id)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
if (!owner)
|
|
|
|
return;
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-03-02 09:07:47 +01:00
|
|
|
Dictionary::Ptr downtimes = owner->GetDowntimes();
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
if (!downtimes)
|
|
|
|
return;
|
|
|
|
|
2013-06-19 10:42:28 +02:00
|
|
|
{
|
|
|
|
ObjectLock olock(owner);
|
|
|
|
downtimes->Remove(id);
|
|
|
|
owner->Touch("downtimes");
|
|
|
|
}
|
2013-01-31 13:57:14 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
void Service::TriggerDowntimes(void)
|
2013-01-31 13:57:14 +01:00
|
|
|
{
|
2013-03-02 09:07:47 +01:00
|
|
|
Dictionary::Ptr downtimes = GetDowntimes();
|
2013-01-31 13:57:14 +01:00
|
|
|
|
|
|
|
if (!downtimes)
|
|
|
|
return;
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-03-18 12:55:41 +01:00
|
|
|
std::vector<String> ids;
|
2013-02-27 12:44:51 +01:00
|
|
|
|
2013-03-18 12:55:41 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(downtimes);
|
|
|
|
|
|
|
|
String id;
|
|
|
|
BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) {
|
|
|
|
ids.push_back(id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_FOREACH(const String& id, ids) {
|
2013-01-31 13:57:14 +01:00
|
|
|
TriggerDowntime(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
void Service::TriggerDowntime(const String& id)
|
2013-01-31 13:57:14 +01:00
|
|
|
{
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
2013-01-31 13:57:14 +01:00
|
|
|
Dictionary::Ptr downtime = GetDowntimeByID(id);
|
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
if (!downtime)
|
|
|
|
return;
|
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
double now = Utility::GetTime();
|
|
|
|
|
|
|
|
if (now < downtime->Get("start_time") ||
|
|
|
|
now > downtime->Get("end_time"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (downtime->Get("trigger_time") == 0)
|
|
|
|
downtime->Set("trigger_time", now);
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
Dictionary::Ptr triggers = downtime->Get("triggers");
|
2013-03-04 15:52:42 +01:00
|
|
|
ObjectLock olock(triggers);
|
2013-01-31 13:57:14 +01:00
|
|
|
String tid;
|
2013-03-15 18:21:29 +01:00
|
|
|
BOOST_FOREACH(boost::tie(tid, boost::tuples::ignore), triggers) {
|
2013-01-31 13:57:14 +01:00
|
|
|
TriggerDowntime(tid);
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-01-31 13:57:14 +01:00
|
|
|
owner->Touch("downtimes");
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
String Service::GetDowntimeIDFromLegacyID(int id)
|
2013-01-30 09:59:22 +01:00
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
2013-02-09 01:16:43 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
std::map<int, String>::iterator it = l_LegacyDowntimesCache.find(id);
|
2013-01-30 13:02:20 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (it == l_LegacyDowntimesCache.end())
|
2013-01-31 13:57:14 +01:00
|
|
|
return Empty;
|
2013-01-30 13:02:20 +01:00
|
|
|
|
|
|
|
return it->second;
|
2013-01-30 09:59:22 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr Service::GetOwnerByDowntimeID(const String& id)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
|
|
|
return l_DowntimesCache[id].lock();
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
Dictionary::Ptr Service::GetDowntimeByID(const String& id)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
2013-01-29 16:29:09 +01:00
|
|
|
|
|
|
|
if (!owner)
|
2013-01-31 13:57:14 +01:00
|
|
|
return Dictionary::Ptr();
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-03-02 09:07:47 +01:00
|
|
|
Dictionary::Ptr downtimes = owner->GetDowntimes();
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-03-02 09:07:47 +01:00
|
|
|
if (downtimes)
|
|
|
|
return downtimes->Get(id);
|
2013-01-29 14:50:51 +01:00
|
|
|
|
|
|
|
return Dictionary::Ptr();
|
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
bool Service::IsDowntimeActive(const Dictionary::Ptr& downtime)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
|
|
|
double now = Utility::GetTime();
|
|
|
|
|
2013-01-30 14:28:13 +01:00
|
|
|
if (now < downtime->Get("start_time") ||
|
|
|
|
now > downtime->Get("end_time"))
|
2013-01-29 14:50:51 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (static_cast<bool>(downtime->Get("fixed")))
|
|
|
|
return true;
|
|
|
|
|
2013-01-30 14:28:13 +01:00
|
|
|
double triggerTime = downtime->Get("trigger_time");
|
2013-01-29 14:50:51 +01:00
|
|
|
|
|
|
|
if (triggerTime == 0)
|
|
|
|
return false;
|
|
|
|
|
2013-01-30 14:28:13 +01:00
|
|
|
return (triggerTime + downtime->Get("duration") < now);
|
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime)
|
2013-01-30 14:28:13 +01:00
|
|
|
{
|
|
|
|
return (downtime->Get("end_time") < Utility::GetTime());
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-02-27 15:23:25 +01:00
|
|
|
void Service::InvalidateDowntimesCache(void)
|
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
2013-02-27 16:04:49 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (l_DowntimesCacheNeedsUpdate)
|
2013-03-06 11:03:50 +01:00
|
|
|
return; /* Someone else has already requested a refresh. */
|
2013-02-27 16:04:49 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (!l_DowntimesCacheTimer) {
|
|
|
|
l_DowntimesCacheTimer = boost::make_shared<Timer>();
|
|
|
|
l_DowntimesCacheTimer->SetInterval(0.5);
|
|
|
|
l_DowntimesCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshDowntimesCache));
|
|
|
|
l_DowntimesCacheTimer->Start();
|
2013-03-06 11:03:50 +01:00
|
|
|
}
|
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
l_DowntimesCacheNeedsUpdate = true;
|
2013-02-27 15:23:25 +01:00
|
|
|
}
|
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
void Service::RefreshDowntimesCache(void)
|
2013-01-29 14:50:51 +01:00
|
|
|
{
|
2013-02-27 15:23:25 +01:00
|
|
|
{
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
2013-02-27 15:23:25 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (!l_DowntimesCacheNeedsUpdate)
|
2013-03-06 13:01:51 +01:00
|
|
|
return;
|
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
l_DowntimesCacheNeedsUpdate = false;
|
2013-02-27 15:23:25 +01:00
|
|
|
}
|
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
Log(LogDebug, "icinga", "Updating Service downtimes cache.");
|
2013-03-06 13:01:51 +01:00
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
std::map<int, String> newLegacyDowntimesCache;
|
|
|
|
std::map<String, Service::WeakPtr> newDowntimesCache;
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
|
|
|
|
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-03-04 15:52:42 +01:00
|
|
|
Dictionary::Ptr downtimes = service->GetDowntimes();
|
2013-01-30 09:59:22 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
if (!downtimes)
|
|
|
|
continue;
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
ObjectLock olock(downtimes);
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
String id;
|
|
|
|
Dictionary::Ptr downtime;
|
2013-03-15 18:21:29 +01:00
|
|
|
BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
|
2013-02-27 12:44:51 +01:00
|
|
|
int legacy_id = downtime->Get("legacy_id");
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (legacy_id >= l_NextDowntimeID)
|
|
|
|
l_NextDowntimeID = legacy_id + 1;
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
if (newLegacyDowntimesCache.find(legacy_id) != newLegacyDowntimesCache.end()) {
|
|
|
|
/* The legacy_id is already in use by another downtime;
|
|
|
|
* this shouldn't usually happen - assign it a new ID. */
|
2013-03-18 11:02:18 +01:00
|
|
|
legacy_id = l_NextDowntimeID++;
|
2013-02-27 12:44:51 +01:00
|
|
|
downtime->Set("legacy_id", legacy_id);
|
|
|
|
service->Touch("downtimes");
|
|
|
|
}
|
2013-01-29 14:50:51 +01:00
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
newLegacyDowntimesCache[legacy_id] = id;
|
|
|
|
newDowntimesCache[id] = service;
|
|
|
|
}
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
2013-02-27 12:44:51 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
l_DowntimesCache.swap(newDowntimesCache);
|
|
|
|
l_LegacyDowntimesCache.swap(newLegacyDowntimesCache);
|
2013-01-30 14:28:13 +01:00
|
|
|
|
2013-03-18 11:02:18 +01:00
|
|
|
if (!l_DowntimesExpireTimer) {
|
|
|
|
l_DowntimesExpireTimer = boost::make_shared<Timer>();
|
|
|
|
l_DowntimesExpireTimer->SetInterval(300);
|
|
|
|
l_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler));
|
|
|
|
l_DowntimesExpireTimer->Start();
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-09 01:16:43 +01:00
|
|
|
void Service::RemoveExpiredDowntimes(void)
|
2013-01-30 14:28:13 +01:00
|
|
|
{
|
2013-03-02 09:07:47 +01:00
|
|
|
Dictionary::Ptr downtimes = GetDowntimes();
|
2013-01-30 14:28:13 +01:00
|
|
|
|
|
|
|
if (!downtimes)
|
|
|
|
return;
|
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
std::vector<String> expiredDowntimes;
|
2013-01-30 14:28:13 +01:00
|
|
|
|
2013-03-04 15:52:42 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(downtimes);
|
2013-02-27 12:44:51 +01:00
|
|
|
|
2013-03-04 15:52:42 +01:00
|
|
|
String id;
|
|
|
|
Dictionary::Ptr downtime;
|
2013-03-15 18:21:29 +01:00
|
|
|
BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
|
2013-03-04 15:52:42 +01:00
|
|
|
if (IsDowntimeExpired(downtime))
|
|
|
|
expiredDowntimes.push_back(id);
|
|
|
|
}
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
|
|
|
|
2013-03-06 15:41:13 +01:00
|
|
|
if (!expiredDowntimes.empty()) {
|
2013-03-04 15:52:42 +01:00
|
|
|
BOOST_FOREACH(const String& id, expiredDowntimes) {
|
2013-01-30 14:28:13 +01:00
|
|
|
downtimes->Remove(id);
|
|
|
|
}
|
|
|
|
|
2013-06-19 14:28:46 +02:00
|
|
|
{
|
|
|
|
ObjectLock olock(this);
|
|
|
|
Touch("downtimes");
|
|
|
|
}
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 22:36:24 +01:00
|
|
|
void Service::DowntimesExpireTimerHandler(void)
|
2013-01-30 14:28:13 +01:00
|
|
|
{
|
2013-02-18 23:44:24 +01:00
|
|
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
|
2013-02-09 01:16:43 +01:00
|
|
|
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
|
|
|
service->RemoveExpiredDowntimes();
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
2013-01-29 14:50:51 +01:00
|
|
|
}
|
2013-02-09 17:27:32 +01:00
|
|
|
|
|
|
|
bool Service::IsInDowntime(void) const
|
|
|
|
{
|
|
|
|
Dictionary::Ptr downtimes = GetDowntimes();
|
|
|
|
|
|
|
|
if (!downtimes)
|
|
|
|
return false;
|
|
|
|
|
2013-02-27 12:44:51 +01:00
|
|
|
ObjectLock olock(downtimes);
|
|
|
|
|
2013-02-09 17:27:32 +01:00
|
|
|
Dictionary::Ptr downtime;
|
2013-03-15 18:21:29 +01:00
|
|
|
BOOST_FOREACH(boost::tie(boost::tuples::ignore, downtime), downtimes) {
|
2013-02-09 17:27:32 +01:00
|
|
|
if (Service::IsDowntimeActive(downtime))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|