Implement the 'is_inside' attribute for the TimePeriod type

refs #8467
This commit is contained in:
Gunnar Beutner 2015-02-23 14:06:32 +01:00
parent 47479ac4de
commit b5dbc66b22
4 changed files with 15 additions and 0 deletions

View 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

View 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);

View 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);

View 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;
};
};
}