livestatus: more attributes

refs #4372
This commit is contained in:
Michael Friedrich 2013-07-19 13:59:39 +02:00
parent 511b052105
commit 734b08d858
3 changed files with 103 additions and 66 deletions

View File

@ -28,9 +28,11 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/convert.h" #include "base/convert.h"
#include <boost/algorithm/string/classification.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/algorithm/string/split.hpp>
using namespace icinga; using namespace icinga;
using namespace livestatus; using namespace livestatus;
@ -537,14 +539,14 @@ Value HostsTable::FlapDetectionEnabledAccessor(const Value& row)
Value HostsTable::CheckFreshnessAccessor(const Value& row) Value HostsTable::CheckFreshnessAccessor(const Value& row)
{ {
/* TODO */ /* always enabled */
return Empty; return 1;
} }
Value HostsTable::ProcessPerformanceDataAccessor(const Value& row) Value HostsTable::ProcessPerformanceDataAccessor(const Value& row)
{ {
/* TODO always enabled */ /* always enabled */
return Value(1); return 1;
} }
Value HostsTable::AcceptPassiveChecksAccessor(const Value& row) Value HostsTable::AcceptPassiveChecksAccessor(const Value& row)
@ -560,8 +562,8 @@ Value HostsTable::AcceptPassiveChecksAccessor(const Value& row)
Value HostsTable::EventHandlerEnabledAccessor(const Value& row) Value HostsTable::EventHandlerEnabledAccessor(const Value& row)
{ {
/* TODO always enabled */ /* always enabled */
return Value(1); return 1;
} }
Value HostsTable::AcknowledgementTypeAccessor(const Value& row) Value HostsTable::AcknowledgementTypeAccessor(const Value& row)
@ -700,7 +702,7 @@ Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
Value HostsTable::PendingFlexDowntimeAccessor(const Value& row) Value HostsTable::PendingFlexDowntimeAccessor(const Value& row)
{ {
/* TODO Host->Service->GetDowntimes->(loop) type flexible? */ /* not supported */
return Empty; return Empty;
} }
@ -778,8 +780,8 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
Value HostsTable::CheckFlappingRecoveryNotificationAccessor(const Value& row) Value HostsTable::CheckFlappingRecoveryNotificationAccessor(const Value& row)
{ {
/* TODO: if we're flapping, state != OK && notified once, set to true */ /* not supported */
return Value(0); return Empty;
} }
Value HostsTable::LastCheckAccessor(const Value& row) Value HostsTable::LastCheckAccessor(const Value& row)
@ -928,14 +930,24 @@ Value HostsTable::FirstNotificationDelayAccessor(const Value& row)
Value HostsTable::LowFlapThresholdAccessor(const Value& row) Value HostsTable::LowFlapThresholdAccessor(const Value& row)
{ {
/* TODO */ /* use hostcheck service */
return Empty; Service::Ptr hc = static_cast<Host::Ptr>(row)->GetHostCheckService();
if (!hc)
return Empty;
return hc->GetFlappingThreshold();
} }
Value HostsTable::HighFlapThresholdAccessor(const Value& row) Value HostsTable::HighFlapThresholdAccessor(const Value& row)
{ {
/* TODO */ /* use hostcheck service */
return Empty; Service::Ptr hc = static_cast<Host::Ptr>(row)->GetHostCheckService();
if (!hc)
return Empty;
return hc->GetFlappingThreshold();
} }
Value HostsTable::X3dAccessor(const Value& row) Value HostsTable::X3dAccessor(const Value& row)
@ -958,14 +970,38 @@ Value HostsTable::Z3dAccessor(const Value& row)
Value HostsTable::X2dAccessor(const Value& row) Value HostsTable::X2dAccessor(const Value& row)
{ {
/* TODO */ Dictionary::Ptr custom = static_cast<Host::Ptr>(row)->GetCustom();
return Empty;
if (!custom)
return Empty;
String coords = custom->Get("2d_coords");
std::vector<String> 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) Value HostsTable::Y2dAccessor(const Value& row)
{ {
/* TODO */ Dictionary::Ptr custom = static_cast<Host::Ptr>(row)->GetCustom();
return Empty;
if (!custom)
return Empty;
String coords = custom->Get("2d_coords");
std::vector<String> 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) Value HostsTable::LatencyAccessor(const Value& row)
@ -1019,7 +1055,8 @@ Value HostsTable::InNotificationPeriodAccessor(const Value& row)
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
} }
return 0; /* none set means always notified */
return 1;
} }
Value HostsTable::InCheckPeriodAccessor(const Value& row) Value HostsTable::InCheckPeriodAccessor(const Value& row)
@ -1032,8 +1069,9 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row)
TimePeriod::Ptr timeperiod = hc->GetCheckPeriod(); TimePeriod::Ptr timeperiod = hc->GetCheckPeriod();
/* none set means always checked */
if (!timeperiod) if (!timeperiod)
return Empty; return 1;
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
} }

View File

@ -583,8 +583,8 @@ Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row) Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
{ {
/* TODO always enabled*/ /* always enabled */
return Value(1); return 1;
} }
Value ServicesTable::NotificationsEnabledAccessor(const Value& row) Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
@ -594,13 +594,13 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row) Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
{ {
/* TODO always enabled */ /* always enabled */
return Value(1); return 1;
} }
Value ServicesTable::IsExecutingAccessor(const Value& row) Value ServicesTable::IsExecutingAccessor(const Value& row)
{ {
/* TODO does that make sense with Icinga2? */ /* not supported */
return Empty; return Empty;
} }
@ -622,8 +622,8 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
Value ServicesTable::CheckFreshnessAccessor(const Value& row) Value ServicesTable::CheckFreshnessAccessor(const Value& row)
{ {
/* TODO */ /* always enabled */
return Empty; return 1;
} }
Value ServicesTable::ObsessOverServiceAccessor(const Value& row) Value ServicesTable::ObsessOverServiceAccessor(const Value& row)
@ -685,14 +685,12 @@ Value ServicesTable::FirstNotificationDelayAccessor(const Value& row)
Value ServicesTable::LowFlapThresholdAccessor(const Value& row) Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
{ {
/* TODO */ return static_cast<Service::Ptr>(row)->GetFlappingThreshold();
return Empty;
} }
Value ServicesTable::HighFlapThresholdAccessor(const Value& row) Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
{ {
/* TODO */ return static_cast<Service::Ptr>(row)->GetFlappingThreshold();
return Empty;
} }
Value ServicesTable::LatencyAccessor(const Value& row) Value ServicesTable::LatencyAccessor(const Value& row)
@ -714,8 +712,9 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
{ {
TimePeriod::Ptr timeperiod = static_cast<Service::Ptr>(row)->GetCheckPeriod(); TimePeriod::Ptr timeperiod = static_cast<Service::Ptr>(row)->GetCheckPeriod();
/* none set means always checked */
if (!timeperiod) if (!timeperiod)
return Empty; return 1;
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0); 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 (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
} }
return 0; /* none set means always notified */
return 1;
} }
Value ServicesTable::ContactsAccessor(const Value& row) Value ServicesTable::ContactsAccessor(const Value& row)

View File

@ -122,13 +122,13 @@ Value StatusTable::NebCallbacksRateAccessor(const Value& row)
Value StatusTable::RequestsAccessor(const Value& row) Value StatusTable::RequestsAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::RequestsRateAccessor(const Value& row) Value StatusTable::RequestsRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
@ -146,49 +146,49 @@ Value StatusTable::ConnectionsRateAccessor(const Value& row)
Value StatusTable::ServiceChecksAccessor(const Value& row) Value StatusTable::ServiceChecksAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::ServiceChecksRateAccessor(const Value& row) Value StatusTable::ServiceChecksRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::HostChecksAccessor(const Value& row) Value StatusTable::HostChecksAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::HostChecksRateAccessor(const Value& row) Value StatusTable::HostChecksRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::ForksAccessor(const Value& row) Value StatusTable::ForksAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::ForksRateAccessor(const Value& row) Value StatusTable::ForksRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LogMessagesAccessor(const Value& row) Value StatusTable::LogMessagesAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LogMessagesRateAccessor(const Value& row) Value StatusTable::LogMessagesRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
@ -206,25 +206,25 @@ Value StatusTable::ExternalCommandsRateAccessor(const Value& row)
Value StatusTable::LivechecksAccessor(const Value& row) Value StatusTable::LivechecksAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LivechecksRateAccessor(const Value& row) Value StatusTable::LivechecksRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LivecheckOverflowsAccessor(const Value& row) Value StatusTable::LivecheckOverflowsAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LivecheckOverflowsRateAccessor(const Value& row) Value StatusTable::LivecheckOverflowsRateAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
@ -235,37 +235,37 @@ Value StatusTable::NagiosPidAccessor(const Value& row)
Value StatusTable::EnableNotificationsAccessor(const Value& row) Value StatusTable::EnableNotificationsAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::ExecuteServiceChecksAccessor(const Value& row) Value StatusTable::ExecuteServiceChecksAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::AcceptPassiveServiceChecksAccessor(const Value& row) Value StatusTable::AcceptPassiveServiceChecksAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::ExecuteHostChecksAccessor(const Value& row) Value StatusTable::ExecuteHostChecksAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::AcceptPassiveHostChecksAccessor(const Value& row) Value StatusTable::AcceptPassiveHostChecksAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::EnableEventHandlersAccessor(const Value& row) Value StatusTable::EnableEventHandlersAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
@ -283,8 +283,8 @@ Value StatusTable::ObsessOverHostsAccessor(const Value& row)
Value StatusTable::CheckServiceFreshnessAccessor(const Value& row) Value StatusTable::CheckServiceFreshnessAccessor(const Value& row)
{ {
/* TODO */ /* enable by default */
return Empty; return 1;
} }
Value StatusTable::CheckHostFreshnessAccessor(const Value& row) Value StatusTable::CheckHostFreshnessAccessor(const Value& row)
@ -295,19 +295,19 @@ Value StatusTable::CheckHostFreshnessAccessor(const Value& row)
Value StatusTable::EnableFlapDetectionAccessor(const Value& row) Value StatusTable::EnableFlapDetectionAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::ProcessPerformanceDataAccessor(const Value& row) Value StatusTable::ProcessPerformanceDataAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
Value StatusTable::CheckExternalCommandsAccessor(const Value& row) Value StatusTable::CheckExternalCommandsAccessor(const Value& row)
{ {
/* TODO - enabled by default*/ /* enabled by default*/
return 1; return 1;
} }
@ -318,8 +318,8 @@ Value StatusTable::ProgramStartAccessor(const Value& row)
Value StatusTable::LastCommandCheckAccessor(const Value& row) Value StatusTable::LastCommandCheckAccessor(const Value& row)
{ {
/* TODO */ /* always == now */
return Empty; return static_cast<int>(Utility::GetTime());
} }
Value StatusTable::LastLogRotationAccessor(const Value& row) Value StatusTable::LastLogRotationAccessor(const Value& row)
@ -351,32 +351,31 @@ Value StatusTable::ProgramVersionAccessor(const Value& row)
Value StatusTable::ExternalCommandBufferSlotsAccessor(const Value& row) Value StatusTable::ExternalCommandBufferSlotsAccessor(const Value& row)
{ {
/* TODO */ /* infinite */
return Empty; return Empty;
} }
Value StatusTable::ExternalCommandBufferUsageAccessor(const Value& row) Value StatusTable::ExternalCommandBufferUsageAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::ExternalCommandBufferMaxAccessor(const Value& row) Value StatusTable::ExternalCommandBufferMaxAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::CachedLogMessagesAccessor(const Value& row) Value StatusTable::CachedLogMessagesAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }
Value StatusTable::LivestatusVersionAccessor(const Value& row) Value StatusTable::LivestatusVersionAccessor(const Value& row)
{ {
/* TODO */ return "2.0";
return Empty;
} }
Value StatusTable::LivestatusActiveConnectionsAccessor(const Value& row) Value StatusTable::LivestatusActiveConnectionsAccessor(const Value& row)
@ -387,7 +386,7 @@ Value StatusTable::LivestatusActiveConnectionsAccessor(const Value& row)
Value StatusTable::LivestatusQueuedConnectionsAccessor(const Value& row) Value StatusTable::LivestatusQueuedConnectionsAccessor(const Value& row)
{ {
/* TODO */ /* not supported */
return Empty; return Empty;
} }