]> granicus.if.org Git - icinga2/commitdiff
Implement the 'is_inside' attribute for the TimePeriod type
authorGunnar Beutner <gunnar@beutner.name>
Mon, 23 Feb 2015 13:06:32 +0000 (14:06 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 23 Feb 2015 13:08:06 +0000 (14:08 +0100)
refs #8467

doc/6-object-types.md
lib/icinga/timeperiod.cpp
lib/icinga/timeperiod.hpp
lib/icinga/timeperiod.ti

index bf2e2d141f6fd41465ba9e8ab9f49dcf7b149a58..b71d004b9eaa19439c186fef55b6b4ae64875674 100644 (file)
@@ -586,6 +586,11 @@ Configuration Attributes:
 The `/etc/icinga2/conf.d/timeperiods.conf` file is usually used to define
 timeperiods including this one.
 
+Runtime Attributes:
+
+  Name                      | Type          | Description
+  --------------------------|---------------|-----------------
+  is\_insidek               | Boolean       | Whether we're currently inside this timeperiod.
 
 ## <a id="objecttype-scheduleddowntime"></a> ScheduledDowntime
 
index e03e3a5b3300066458c89bbdc5247af809d8b1e2..f3ee7ee9ac2a30ffb73787e57f82070f0b4481d4 100644 (file)
@@ -217,6 +217,11 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
        }
 }
 
+bool TimePeriod::GetIsInside(void) const
+{
+       return IsInside(Utility::GetTime());
+}
+
 bool TimePeriod::IsInside(double ts) const
 {
        ObjectLock olock(this);
index 81b3d2de8e2db4ec9687a0929e72fce589463be5..e4482f299f6b3ce251fa995a9bceff2649d71296 100644 (file)
@@ -43,6 +43,8 @@ public:
 
        void UpdateRegion(double begin, double end, bool clearExisting);
 
+       virtual bool GetIsInside(void) const;
+
        bool IsInside(double ts) const;
        double FindNextTransition(double begin);
 
index 03971398df2806d3da693e37dd0b3f83e77d7b9d..50a9506323cefd825cad9e86153f6865f175b8e8 100644 (file)
@@ -38,6 +38,9 @@ class TimePeriod : CustomVarObject
        [state] Value valid_begin;
        [state] Value valid_end;
        [state] Array::Ptr segments;
+       [no_storage] bool is_inside {
+               get;
+       };
 };
 
 }