]> granicus.if.org Git - icinga2/blob - lib/icinga/checkable-downtime.cpp
Fix spelling errors.
[icinga2] / lib / icinga / checkable-downtime.cpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
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"
9
10 using namespace icinga;
11
12 void Checkable::RemoveAllDowntimes()
13 {
14         for (const Downtime::Ptr& downtime : GetDowntimes()) {
15                 Downtime::RemoveDowntime(downtime->GetName(), true, true);
16         }
17 }
18
19 void Checkable::TriggerDowntimes()
20 {
21         for (const Downtime::Ptr& downtime : GetDowntimes()) {
22                 downtime->TriggerDowntime();
23         }
24 }
25
26 bool Checkable::IsInDowntime() const
27 {
28         for (const Downtime::Ptr& downtime : GetDowntimes()) {
29                 if (downtime->IsInEffect())
30                         return true;
31         }
32
33         return false;
34 }
35
36 int Checkable::GetDowntimeDepth() const
37 {
38         int downtime_depth = 0;
39
40         for (const Downtime::Ptr& downtime : GetDowntimes()) {
41                 if (downtime->IsInEffect())
42                         downtime_depth++;
43         }
44
45         return downtime_depth;
46 }
47
48 std::set<Downtime::Ptr> Checkable::GetDowntimes() const
49 {
50         boost::mutex::scoped_lock lock(m_DowntimeMutex);
51         return m_Downtimes;
52 }
53
54 void Checkable::RegisterDowntime(const Downtime::Ptr& downtime)
55 {
56         boost::mutex::scoped_lock lock(m_DowntimeMutex);
57         m_Downtimes.insert(downtime);
58 }
59
60 void Checkable::UnregisterDowntime(const Downtime::Ptr& downtime)
61 {
62         boost::mutex::scoped_lock lock(m_DowntimeMutex);
63         m_Downtimes.erase(downtime);
64 }