diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index 679cb0bfc..deb1c9efe 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -157,6 +157,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "services", Column(&HostsTable::ServicesAccessor, objectAccessor)); table->AddColumn(prefix + "services_with_state", Column(&HostsTable::ServicesWithStateAccessor, objectAccessor)); table->AddColumn(prefix + "services_with_info", Column(&HostsTable::ServicesWithInfoAccessor, objectAccessor)); + table->AddColumn(prefix + "check_source", Column(&HostsTable::CheckSourceAccessor, objectAccessor)); table->AddColumn(prefix + "is_reachable", Column(&HostsTable::IsReachableAccessor, objectAccessor)); } @@ -1483,6 +1484,21 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row) return services; } +Value HostsTable::CheckSourceAccessor(const Value& row) +{ + Host::Ptr host = static_cast(row); + + if (!host) + return Empty; + + CheckResult::Ptr cr = host->GetLastCheckResult(); + + if (cr) + return cr->GetCheckSource(); + + return Empty; +} + Value HostsTable::IsReachableAccessor(const Value& row) { Host::Ptr host = static_cast(row); diff --git a/components/livestatus/hoststable.h b/components/livestatus/hoststable.h index 047e05476..dc5bddede 100644 --- a/components/livestatus/hoststable.h +++ b/components/livestatus/hoststable.h @@ -140,6 +140,7 @@ protected: static Value ServicesAccessor(const Value& row); static Value ServicesWithStateAccessor(const Value& row); static Value ServicesWithInfoAccessor(const Value& row); + static Value CheckSourceAccessor(const Value& row); static Value IsReachableAccessor(const Value& row); }; diff --git a/doc/9-appendix.md b/doc/9-appendix.md index 9c81c02c9..22582f089 100644 --- a/doc/9-appendix.md +++ b/doc/9-appendix.md @@ -505,6 +505,7 @@ New columns: ----------|-------------- hosts | is_reachable services | is_reachable + hosts | check_source services | check_source downtimes | triggers downtimes | trigger_time diff --git a/test/livestatus/queries/host/check b/test/livestatus/queries/host/check new file mode 100644 index 000000000..bf4c216e6 --- /dev/null +++ b/test/livestatus/queries/host/check @@ -0,0 +1,4 @@ +GET hosts +Columns: name plugin_output check_source +ResponseHeader: fixed16 +