diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index 4a9de4393..2ad7c0eb9 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -28,9 +28,11 @@ #include "base/dynamictype.h" #include "base/objectlock.h" #include "base/convert.h" +#include #include #include #include +#include using namespace icinga; using namespace livestatus; @@ -537,14 +539,14 @@ Value HostsTable::FlapDetectionEnabledAccessor(const Value& row) Value HostsTable::CheckFreshnessAccessor(const Value& row) { - /* TODO */ - return Empty; + /* always enabled */ + return 1; } Value HostsTable::ProcessPerformanceDataAccessor(const Value& row) { - /* TODO always enabled */ - return Value(1); + /* always enabled */ + return 1; } Value HostsTable::AcceptPassiveChecksAccessor(const Value& row) @@ -560,8 +562,8 @@ Value HostsTable::AcceptPassiveChecksAccessor(const Value& row) Value HostsTable::EventHandlerEnabledAccessor(const Value& row) { - /* TODO always enabled */ - return Value(1); + /* always enabled */ + return 1; } Value HostsTable::AcknowledgementTypeAccessor(const Value& row) @@ -700,7 +702,7 @@ Value HostsTable::CurrentNotificationNumberAccessor(const Value& row) Value HostsTable::PendingFlexDowntimeAccessor(const Value& row) { - /* TODO Host->Service->GetDowntimes->(loop) type flexible? */ + /* not supported */ return Empty; } @@ -778,8 +780,8 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row) Value HostsTable::CheckFlappingRecoveryNotificationAccessor(const Value& row) { - /* TODO: if we're flapping, state != OK && notified once, set to true */ - return Value(0); + /* not supported */ + return Empty; } Value HostsTable::LastCheckAccessor(const Value& row) @@ -928,14 +930,24 @@ Value HostsTable::FirstNotificationDelayAccessor(const Value& row) Value HostsTable::LowFlapThresholdAccessor(const Value& row) { - /* TODO */ - return Empty; + /* use hostcheck service */ + Service::Ptr hc = static_cast(row)->GetHostCheckService(); + + if (!hc) + return Empty; + + return hc->GetFlappingThreshold(); } Value HostsTable::HighFlapThresholdAccessor(const Value& row) { - /* TODO */ - return Empty; + /* use hostcheck service */ + Service::Ptr hc = static_cast(row)->GetHostCheckService(); + + if (!hc) + return Empty; + + return hc->GetFlappingThreshold(); } Value HostsTable::X3dAccessor(const Value& row) @@ -958,14 +970,38 @@ Value HostsTable::Z3dAccessor(const Value& row) Value HostsTable::X2dAccessor(const Value& row) { - /* TODO */ - return Empty; + Dictionary::Ptr custom = static_cast(row)->GetCustom(); + + if (!custom) + return Empty; + + String coords = custom->Get("2d_coords"); + + std::vector tokens; + boost::algorithm::split(tokens, coords, boost::is_any_of(",")); + + if (tokens.size() != 2) + return Empty; + + return tokens[0]; } Value HostsTable::Y2dAccessor(const Value& row) { - /* TODO */ - return Empty; + Dictionary::Ptr custom = static_cast(row)->GetCustom(); + + if (!custom) + return Empty; + + String coords = custom->Get("2d_coords"); + + std::vector tokens; + boost::algorithm::split(tokens, coords, boost::is_any_of(",")); + + if (tokens.size() != 2) + return Empty; + + return tokens[1]; } Value HostsTable::LatencyAccessor(const Value& row) @@ -1019,7 +1055,8 @@ Value HostsTable::InNotificationPeriodAccessor(const Value& row) return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); } - return 0; + /* none set means always notified */ + return 1; } Value HostsTable::InCheckPeriodAccessor(const Value& row) @@ -1032,8 +1069,9 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row) TimePeriod::Ptr timeperiod = hc->GetCheckPeriod(); + /* none set means always checked */ if (!timeperiod) - return Empty; + return 1; return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); } diff --git a/components/livestatus/servicestable.cpp b/components/livestatus/servicestable.cpp index e99f4ab58..5a499f190 100644 --- a/components/livestatus/servicestable.cpp +++ b/components/livestatus/servicestable.cpp @@ -583,8 +583,8 @@ Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row) Value ServicesTable::EventHandlerEnabledAccessor(const Value& row) { - /* TODO always enabled*/ - return Value(1); + /* always enabled */ + return 1; } Value ServicesTable::NotificationsEnabledAccessor(const Value& row) @@ -594,13 +594,13 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row) Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row) { - /* TODO always enabled */ - return Value(1); + /* always enabled */ + return 1; } Value ServicesTable::IsExecutingAccessor(const Value& row) { - /* TODO does that make sense with Icinga2? */ + /* not supported */ return Empty; } @@ -622,8 +622,8 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row) Value ServicesTable::CheckFreshnessAccessor(const Value& row) { - /* TODO */ - return Empty; + /* always enabled */ + return 1; } Value ServicesTable::ObsessOverServiceAccessor(const Value& row) @@ -685,14 +685,12 @@ Value ServicesTable::FirstNotificationDelayAccessor(const Value& row) Value ServicesTable::LowFlapThresholdAccessor(const Value& row) { - /* TODO */ - return Empty; + return static_cast(row)->GetFlappingThreshold(); } Value ServicesTable::HighFlapThresholdAccessor(const Value& row) { - /* TODO */ - return Empty; + return static_cast(row)->GetFlappingThreshold(); } Value ServicesTable::LatencyAccessor(const Value& row) @@ -714,8 +712,9 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row) { TimePeriod::Ptr timeperiod = static_cast(row)->GetCheckPeriod(); + /* none set means always checked */ if (!timeperiod) - return Empty; + return 1; return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); } @@ -732,7 +731,8 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row) return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); } - return 0; + /* none set means always notified */ + return 1; } Value ServicesTable::ContactsAccessor(const Value& row) diff --git a/components/livestatus/statustable.cpp b/components/livestatus/statustable.cpp index 2b55375e9..3524eda4c 100644 --- a/components/livestatus/statustable.cpp +++ b/components/livestatus/statustable.cpp @@ -122,13 +122,13 @@ Value StatusTable::NebCallbacksRateAccessor(const Value& row) Value StatusTable::RequestsAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::RequestsRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } @@ -146,49 +146,49 @@ Value StatusTable::ConnectionsRateAccessor(const Value& row) Value StatusTable::ServiceChecksAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::ServiceChecksRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::HostChecksAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::HostChecksRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::ForksAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::ForksRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LogMessagesAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LogMessagesRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } @@ -206,25 +206,25 @@ Value StatusTable::ExternalCommandsRateAccessor(const Value& row) Value StatusTable::LivechecksAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LivechecksRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LivecheckOverflowsAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LivecheckOverflowsRateAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } @@ -235,37 +235,37 @@ Value StatusTable::NagiosPidAccessor(const Value& row) Value StatusTable::EnableNotificationsAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::ExecuteServiceChecksAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::AcceptPassiveServiceChecksAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::ExecuteHostChecksAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::AcceptPassiveHostChecksAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::EnableEventHandlersAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } @@ -283,8 +283,8 @@ Value StatusTable::ObsessOverHostsAccessor(const Value& row) Value StatusTable::CheckServiceFreshnessAccessor(const Value& row) { - /* TODO */ - return Empty; + /* enable by default */ + return 1; } Value StatusTable::CheckHostFreshnessAccessor(const Value& row) @@ -295,19 +295,19 @@ Value StatusTable::CheckHostFreshnessAccessor(const Value& row) Value StatusTable::EnableFlapDetectionAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::ProcessPerformanceDataAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } Value StatusTable::CheckExternalCommandsAccessor(const Value& row) { - /* TODO - enabled by default*/ + /* enabled by default*/ return 1; } @@ -318,8 +318,8 @@ Value StatusTable::ProgramStartAccessor(const Value& row) Value StatusTable::LastCommandCheckAccessor(const Value& row) { - /* TODO */ - return Empty; + /* always == now */ + return static_cast(Utility::GetTime()); } Value StatusTable::LastLogRotationAccessor(const Value& row) @@ -351,32 +351,31 @@ Value StatusTable::ProgramVersionAccessor(const Value& row) Value StatusTable::ExternalCommandBufferSlotsAccessor(const Value& row) { - /* TODO */ + /* infinite */ return Empty; } Value StatusTable::ExternalCommandBufferUsageAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::ExternalCommandBufferMaxAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::CachedLogMessagesAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; } Value StatusTable::LivestatusVersionAccessor(const Value& row) { - /* TODO */ - return Empty; + return "2.0"; } Value StatusTable::LivestatusActiveConnectionsAccessor(const Value& row) @@ -387,7 +386,7 @@ Value StatusTable::LivestatusActiveConnectionsAccessor(const Value& row) Value StatusTable::LivestatusQueuedConnectionsAccessor(const Value& row) { - /* TODO */ + /* not supported */ return Empty; }