#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/convert.h"
+#include <boost/algorithm/string/classification.hpp>
#include <boost/foreach.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/tuple/tuple.hpp>
+#include <boost/algorithm/string/split.hpp>
using namespace icinga;
using namespace livestatus;
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)
Value HostsTable::EventHandlerEnabledAccessor(const Value& row)
{
- /* TODO always enabled */
- return Value(1);
+ /* always enabled */
+ return 1;
}
Value HostsTable::AcknowledgementTypeAccessor(const Value& row)
Value HostsTable::PendingFlexDowntimeAccessor(const Value& row)
{
- /* TODO Host->Service->GetDowntimes->(loop) type flexible? */
+ /* not supported */
return Empty;
}
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)
Value HostsTable::LowFlapThresholdAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ /* use hostcheck service */
+ Service::Ptr hc = static_cast<Host::Ptr>(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<Host::Ptr>(row)->GetHostCheckService();
+
+ if (!hc)
+ return Empty;
+
+ return hc->GetFlappingThreshold();
}
Value HostsTable::X3dAccessor(const Value& row)
Value HostsTable::X2dAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ Dictionary::Ptr custom = static_cast<Host::Ptr>(row)->GetCustom();
+
+ 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)
{
- /* TODO */
- return Empty;
+ Dictionary::Ptr custom = static_cast<Host::Ptr>(row)->GetCustom();
+
+ 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)
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
}
- return 0;
+ /* none set means always notified */
+ return 1;
}
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);
}
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
{
- /* TODO always enabled*/
- return Value(1);
+ /* always enabled */
+ return 1;
}
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;
}
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ /* always enabled */
+ return 1;
}
Value ServicesTable::ObsessOverServiceAccessor(const Value& row)
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ return static_cast<Service::Ptr>(row)->GetFlappingThreshold();
}
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ return static_cast<Service::Ptr>(row)->GetFlappingThreshold();
}
Value ServicesTable::LatencyAccessor(const Value& row)
{
TimePeriod::Ptr timeperiod = static_cast<Service::Ptr>(row)->GetCheckPeriod();
+ /* none set means always checked */
if (!timeperiod)
- return Empty;
+ return 1;
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 StatusTable::RequestsAccessor(const Value& row)
{
- /* TODO */
+ /* not supported */
return Empty;
}
Value StatusTable::RequestsRateAccessor(const Value& row)
{
- /* TODO */
+ /* not supported */
return Empty;
}
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;
}
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;
}
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;
}
Value StatusTable::CheckServiceFreshnessAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ /* enable by default */
+ return 1;
}
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;
}
Value StatusTable::LastCommandCheckAccessor(const Value& row)
{
- /* TODO */
- return Empty;
+ /* always == now */
+ return static_cast<int>(Utility::GetTime());
}
Value StatusTable::LastLogRotationAccessor(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)
Value StatusTable::LivestatusQueuedConnectionsAccessor(const Value& row)
{
- /* TODO */
+ /* not supported */
return Empty;
}