Livestatus: Add 'is_reachable' to hosts/services table.

Refs #6094
This commit is contained in:
Michael Friedrich 2014-05-10 20:37:09 +02:00
parent 3976fc2369
commit 97d51c4269
7 changed files with 26 additions and 2 deletions

View File

@ -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 + "is_reachable", Column(&HostsTable::IsReachableAccessor, objectAccessor));
}
String HostsTable::GetName(void) const
@ -1481,3 +1482,13 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row)
return services;
}
Value HostsTable::IsReachableAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
if (!host)
return Empty;
return host->IsReachable();
}

View File

@ -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 IsReachableAccessor(const Value& row);
};
}

View File

@ -127,6 +127,7 @@ void ServicesTable::AddColumns(Table *table, const String& prefix,
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));
table->AddColumn(prefix + "is_reachable", Column(&ServicesTable::IsReachableAccessor, objectAccessor));
HostsTable::AddColumns(table, "host_", boost::bind(&ServicesTable::HostAccessor, _1, objectAccessor));
}
@ -1167,4 +1168,12 @@ Value ServicesTable::CheckSourceAccessor(const Value& row)
return Empty;
}
Value ServicesTable::IsReachableAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
if (!service)
return Empty;
return service->IsReachable();
}

View File

@ -124,6 +124,7 @@ protected:
static Value GroupsAccessor(const Value& row);
static Value ContactGroupsAccessor(const Value& row);
static Value CheckSourceAccessor(const Value& row);
static Value IsReachableAccessor(const Value& row);
};
}

View File

@ -488,6 +488,8 @@ New columns:
Table | Column
----------|--------------
hosts | is_reachable
services | is_reachable
services | check_source
downtimes | triggers
downtimes | trigger_time

View File

@ -1,4 +1,4 @@
GET hosts
Columns: name last_state_change last_hard_state_change last_time_up last_time_down last_time_unreachable staleness
Columns: name last_state_change last_hard_state_change last_time_up last_time_down last_time_unreachable staleness is_reachable
ResponseHeader: fixed16

View File

@ -1,4 +1,4 @@
GET services
Columns: description host_name last_state_change last_hard_state_change last_time_ok last_time_warning last_time_critical last_time_unknown staleness
Columns: description host_name last_state_change last_hard_state_change last_time_ok last_time_warning last_time_critical last_time_unknown staleness is_reachable
ResponseHeader: fixed16