2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-07-09 18:33:27 +02:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "livestatus/hostgroupstable.hpp"
|
|
|
|
#include "icinga/hostgroup.hpp"
|
|
|
|
#include "icinga/host.hpp"
|
|
|
|
#include "icinga/service.hpp"
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configtype.hpp"
|
2013-07-09 18:33:27 +02:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
HostGroupsTable::HostGroupsTable()
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
|
|
|
AddColumns(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HostGroupsTable::AddColumns(Table *table, const String& prefix,
|
2017-12-19 15:50:05 +01:00
|
|
|
const Column::ObjectAccessor& objectAccessor)
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
|
|
|
table->AddColumn(prefix + "name", Column(&HostGroupsTable::NameAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "alias", Column(&HostGroupsTable::AliasAccessor, objectAccessor));
|
2013-07-11 12:43:27 +02:00
|
|
|
table->AddColumn(prefix + "notes", Column(&HostGroupsTable::NotesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_url", Column(&HostGroupsTable::NotesUrlAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "action_url", Column(&HostGroupsTable::ActionUrlAccessor, objectAccessor));
|
2013-07-09 18:33:27 +02:00
|
|
|
table->AddColumn(prefix + "members", Column(&HostGroupsTable::MembersAccessor, objectAccessor));
|
2013-07-11 12:43:27 +02:00
|
|
|
table->AddColumn(prefix + "members_with_state", Column(&HostGroupsTable::MembersWithStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "worst_host_state", Column(&HostGroupsTable::WorstHostStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_hosts", Column(&HostGroupsTable::NumHostsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_hosts_pending", Column(&HostGroupsTable::NumHostsPendingAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_hosts_up", Column(&HostGroupsTable::NumHostsUpAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_hosts_down", Column(&HostGroupsTable::NumHostsDownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_hosts_unreach", Column(&HostGroupsTable::NumHostsUnreachAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services", Column(&HostGroupsTable::NumServicesAccessor, objectAccessor));
|
2017-02-08 13:00:51 +01:00
|
|
|
table->AddColumn(prefix + "worst_service_state", Column(&HostGroupsTable::WorstServiceStateAccessor, objectAccessor));
|
2013-07-11 12:43:27 +02:00
|
|
|
table->AddColumn(prefix + "num_services_pending", Column(&HostGroupsTable::NumServicesPendingAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_ok", Column(&HostGroupsTable::NumServicesOkAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_warn", Column(&HostGroupsTable::NumServicesWarnAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_crit", Column(&HostGroupsTable::NumServicesCritAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_unknown", Column(&HostGroupsTable::NumServicesUnknownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "worst_service_hard_state", Column(&HostGroupsTable::WorstServiceHardStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_ok", Column(&HostGroupsTable::NumServicesHardOkAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_warn", Column(&HostGroupsTable::NumServicesHardWarnAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_crit", Column(&HostGroupsTable::NumServicesHardCritAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_unknown", Column(&HostGroupsTable::NumServicesHardUnknownAccessor, objectAccessor));
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
String HostGroupsTable::GetName() const
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
|
|
|
return "hostgroups";
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
String HostGroupsTable::GetPrefix() const
|
2014-06-25 11:30:27 +02:00
|
|
|
{
|
|
|
|
return "hostgroup";
|
|
|
|
}
|
|
|
|
|
2013-07-09 18:33:27 +02:00
|
|
|
void HostGroupsTable::FetchRows(const AddRowFunction& addRowFn)
|
|
|
|
{
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const HostGroup::Ptr& hg : ConfigType::GetObjectsByType<HostGroup>()) {
|
2015-03-04 12:03:35 +01:00
|
|
|
if (!addRowFn(hg, LivestatusGroupByNone, Empty))
|
|
|
|
return;
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostGroupsTable::NameAccessor(const Value& row)
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetName();
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostGroupsTable::AliasAccessor(const Value& row)
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetDisplayName();
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
|
|
|
|
2013-07-11 12:43:27 +02:00
|
|
|
Value HostGroupsTable::NotesAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetNotes();
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NotesUrlAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetNotesUrl();
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::ActionUrlAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetActionUrl();
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostGroupsTable::MembersAccessor(const Value& row)
|
2013-07-09 18:33:27 +02:00
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2018-01-11 11:17:38 +01:00
|
|
|
ArrayData members;
|
2013-07-09 18:33:27 +02:00
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2018-01-11 11:17:38 +01:00
|
|
|
members.push_back(host->GetName());
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
|
|
|
|
2018-01-11 11:17:38 +01:00
|
|
|
return new Array(std::move(members));
|
2013-07-09 18:33:27 +02:00
|
|
|
}
|
2013-07-11 12:43:27 +02:00
|
|
|
|
|
|
|
Value HostGroupsTable::MembersWithStateAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2018-01-11 11:17:38 +01:00
|
|
|
ArrayData members;
|
2013-07-16 13:26:16 +02:00
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2018-01-11 11:17:38 +01:00
|
|
|
members.push_back(new Array({
|
|
|
|
host->GetName(),
|
|
|
|
host->GetState()
|
|
|
|
}));
|
2013-07-16 13:26:16 +02:00
|
|
|
}
|
|
|
|
|
2018-01-11 11:17:38 +01:00
|
|
|
return new Array(std::move(members));
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::WorstHostStateAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int worst_host = HostUp;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (host->GetState() > worst_host)
|
|
|
|
worst_host = host->GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
return worst_host;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumHostsAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return hg->GetMembers().size();
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumHostsPendingAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_hosts = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2014-04-03 15:36:13 +02:00
|
|
|
/* no checkresult */
|
|
|
|
if (!host->GetLastCheckResult())
|
2013-07-12 15:17:01 +02:00
|
|
|
num_hosts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_hosts;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumHostsUpAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_hosts = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (host->GetState() == HostUp)
|
|
|
|
num_hosts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_hosts;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumHostsDownAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_hosts = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (host->GetState() == HostDown)
|
|
|
|
num_hosts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_hosts;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumHostsUnreachAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_hosts = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2014-04-08 08:54:49 +02:00
|
|
|
if (!host->IsReachable())
|
2013-07-12 15:17:01 +02:00
|
|
|
num_hosts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_hosts;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesAccessor(const Value& row)
|
|
|
|
{
|
2013-07-12 15:17:01 +02:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
2015-02-15 16:48:09 +01:00
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
int num_services = 0;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
if (hg->GetMembers().size() == 0)
|
|
|
|
return 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
2013-10-03 18:58:48 +02:00
|
|
|
num_services += host->GetServices().size();
|
2013-07-12 15:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
2017-02-08 13:00:51 +01:00
|
|
|
Value HostGroupsTable::WorstServiceStateAccessor(const Value& row)
|
2013-07-11 12:43:27 +02:00
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 09:11:54 +02:00
|
|
|
Value worst_service = ServiceOK;
|
2013-07-12 15:17:01 +02:00
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (service->GetState() > worst_service)
|
|
|
|
worst_service = service->GetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return worst_service;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesPendingAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (!service->GetLastCheckResult())
|
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesOkAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceOK)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesWarnAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceWarning)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesCritAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceCritical)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesUnknownAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceUnknown)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::WorstServiceHardStateAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 09:11:54 +02:00
|
|
|
Value worst_service = ServiceOK;
|
2013-07-12 15:17:01 +02:00
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2013-07-12 15:17:01 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard) {
|
|
|
|
if (service->GetState() > worst_service)
|
|
|
|
worst_service = service->GetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return worst_service;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesHardOkAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceOK)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesHardWarnAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceWarning)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesHardCritAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceCritical)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value HostGroupsTable::NumServicesHardUnknownAccessor(const Value& row)
|
|
|
|
{
|
2015-02-15 16:48:09 +01:00
|
|
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
|
|
|
|
|
|
|
if (!hg)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-12 15:17:01 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Host::Ptr& host : hg->GetMembers()) {
|
|
|
|
for (const Service::Ptr& service : host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown)
|
2013-07-12 15:17:01 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-11 12:43:27 +02:00
|
|
|
}
|