diff --git a/components/livestatus/servicestable.cpp b/components/livestatus/servicestable.cpp index a057c072d..664729d58 100644 --- a/components/livestatus/servicestable.cpp +++ b/components/livestatus/servicestable.cpp @@ -19,6 +19,7 @@ #include "livestatus/servicestable.h" #include "livestatus/hoststable.h" +#include "livestatus/endpointstable.h" #include "icinga/service.h" #include "icinga/checkcommand.h" #include "icinga/eventcommand.h" @@ -125,6 +126,7 @@ void ServicesTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "custom_variables", Column(&ServicesTable::CustomVariablesAccessor, objectAccessor)); table->AddColumn(prefix + "groups", Column(&ServicesTable::GroupsAccessor, objectAccessor)); table->AddColumn(prefix + "contact_groups", Column(&ServicesTable::ContactGroupsAccessor, objectAccessor)); + table->AddColumn(prefix + "check_source", Column(&ServicesTable::CheckSourceAccessor, objectAccessor)); HostsTable::AddColumns(table, "host_", boost::bind(&ServicesTable::HostAccessor, _1, objectAccessor)); } @@ -1158,4 +1160,19 @@ Value ServicesTable::ContactGroupsAccessor(const Value& row) return contactgroup_names; } +Value ServicesTable::CheckSourceAccessor(const Value& row) +{ + Service::Ptr service = static_cast(row); + + if (!service) + return Empty; + + CheckResult::Ptr cr = service->GetLastCheckResult(); + + if (cr) + return cr->GetCheckSource(); + + return Empty; +} + diff --git a/components/livestatus/servicestable.h b/components/livestatus/servicestable.h index f74ad8944..2ef22f3cc 100644 --- a/components/livestatus/servicestable.h +++ b/components/livestatus/servicestable.h @@ -123,6 +123,7 @@ protected: static Value CustomVariablesAccessor(const Value& row); static Value GroupsAccessor(const Value& row); static Value ContactGroupsAccessor(const Value& row); + static Value CheckSourceAccessor(const Value& row); }; }