]> granicus.if.org Git - icinga2/commitdiff
Livestatus: Add check_source to services table.
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 20 Mar 2014 18:15:19 +0000 (19:15 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 20 Mar 2014 18:15:19 +0000 (19:15 +0100)
Refs #5636
Refs #5812

components/livestatus/servicestable.cpp
components/livestatus/servicestable.h

index a057c072d566ff53fad748bc2f5d539b0f7b8503..664729d580db27ba222e5c0c0fa8850ee9e0ab3e 100644 (file)
@@ -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<Service::Ptr>(row);
+
+       if (!service)
+               return Empty;
+
+       CheckResult::Ptr cr = service->GetLastCheckResult();
+
+       if (cr)
+               return cr->GetCheckSource();
+
+       return Empty;
+}
+
 
index f74ad894410fefaa50f82e21d63f1ad546bf5a1c..2ef22f3cc4ddebf4e4b9176bc79b9401f27385cd 100644 (file)
@@ -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);
 };
 
 }