1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/service.hpp"
4 #include "base/configtype.hpp"
5 #include "base/objectlock.hpp"
6 #include "base/logger.hpp"
7 #include "base/utility.hpp"
8 #include "base/convert.hpp"
10 using namespace icinga;
12 void Checkable::RemoveAllDowntimes()
14 for (const Downtime::Ptr& downtime : GetDowntimes()) {
15 Downtime::RemoveDowntime(downtime->GetName(), true, true);
19 void Checkable::TriggerDowntimes()
21 for (const Downtime::Ptr& downtime : GetDowntimes()) {
22 downtime->TriggerDowntime();
26 bool Checkable::IsInDowntime() const
28 for (const Downtime::Ptr& downtime : GetDowntimes()) {
29 if (downtime->IsInEffect())
36 int Checkable::GetDowntimeDepth() const
38 int downtime_depth = 0;
40 for (const Downtime::Ptr& downtime : GetDowntimes()) {
41 if (downtime->IsInEffect())
45 return downtime_depth;
48 std::set<Downtime::Ptr> Checkable::GetDowntimes() const
50 boost::mutex::scoped_lock lock(m_DowntimeMutex);
54 void Checkable::RegisterDowntime(const Downtime::Ptr& downtime)
56 boost::mutex::scoped_lock lock(m_DowntimeMutex);
57 m_Downtimes.insert(downtime);
60 void Checkable::UnregisterDowntime(const Downtime::Ptr& downtime)
62 boost::mutex::scoped_lock lock(m_DowntimeMutex);
63 m_Downtimes.erase(downtime);