mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
36e9e9adbd
commit
6dc88e770b
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "livestatus/hostgroupstable.h"
|
#include "livestatus/hostgroupstable.h"
|
||||||
#include "icinga/hostgroup.h"
|
#include "icinga/hostgroup.h"
|
||||||
|
#include "icinga/host.h"
|
||||||
|
#include "icinga/service.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
@ -79,25 +81,37 @@ Value HostGroupsTable::NameAccessor(const Value& row)
|
|||||||
|
|
||||||
Value HostGroupsTable::AliasAccessor(const Value& row)
|
Value HostGroupsTable::AliasAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
return static_cast<HostGroup::Ptr>(row)->GetName();
|
return static_cast<HostGroup::Ptr>(row)->GetDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NotesAccessor(const Value& row)
|
Value HostGroupsTable::NotesAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
|
||||||
return Value();
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return custom->Get("notes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NotesUrlAccessor(const Value& row)
|
Value HostGroupsTable::NotesUrlAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
|
||||||
return Value();
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return custom->Get("notes_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::ActionUrlAccessor(const Value& row)
|
Value HostGroupsTable::ActionUrlAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
|
||||||
return Value();
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return custom->Get("action_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::MembersAccessor(const Value& row)
|
Value HostGroupsTable::MembersAccessor(const Value& row)
|
||||||
@ -114,113 +128,246 @@ Value HostGroupsTable::MembersAccessor(const Value& row)
|
|||||||
Value HostGroupsTable::MembersWithStateAccessor(const Value& row)
|
Value HostGroupsTable::MembersWithStateAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return Value();
|
return Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::WorstHostStateAccessor(const Value& row)
|
Value HostGroupsTable::WorstHostStateAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int worst_host = HostUp;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
if (host->GetState() > worst_host)
|
||||||
|
worst_host = host->GetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
return worst_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumHostsAccessor(const Value& row)
|
Value HostGroupsTable::NumHostsAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
return static_cast<HostGroup::Ptr>(row)->GetMembers().size();
|
||||||
return Value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumHostsPendingAccessor(const Value& row)
|
Value HostGroupsTable::NumHostsPendingAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_hosts = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
Service::Ptr hc = host->GetHostCheckService();
|
||||||
|
|
||||||
|
/* no hostcheck service or no checkresult */
|
||||||
|
if (!hc || !hc->GetLastCheckResult())
|
||||||
|
num_hosts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumHostsUpAccessor(const Value& row)
|
Value HostGroupsTable::NumHostsUpAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_hosts = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
if (host->GetState() == HostUp)
|
||||||
|
num_hosts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumHostsDownAccessor(const Value& row)
|
Value HostGroupsTable::NumHostsDownAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_hosts = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
if (host->GetState() == HostDown)
|
||||||
|
num_hosts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumHostsUnreachAccessor(const Value& row)
|
Value HostGroupsTable::NumHostsUnreachAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_hosts = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
if (host->GetState() == HostUnreachable)
|
||||||
|
num_hosts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
HostGroup::Ptr hg = static_cast<HostGroup::Ptr>(row);
|
||||||
|
|
||||||
|
if (hg->GetMembers().size() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::WorstServicesStateAccessor(const Value& row)
|
Value HostGroupsTable::WorstServicesStateAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Value worst_service = StateOK;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetState() > worst_service)
|
||||||
|
worst_service = service->GetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worst_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesPendingAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesPendingAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (!service->GetLastCheckResult())
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesOkAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesOkAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetState() == StateOK)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesWarnAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesWarnAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetState() == StateWarning)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesCritAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesCritAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetState() == StateCritical)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesUnknownAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesUnknownAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetState() == StateUnknown)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::WorstServiceHardStateAccessor(const Value& row)
|
Value HostGroupsTable::WorstServiceHardStateAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Value worst_service = StateOK;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetStateType() == StateTypeHard) {
|
||||||
|
if (service->GetState() > worst_service)
|
||||||
|
worst_service = service->GetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worst_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesHardOkAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesHardOkAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetStateType() == StateTypeHard && service->GetState() == StateOK)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesHardWarnAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesHardWarnAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetStateType() == StateTypeHard && service->GetState() == StateWarning)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesHardCritAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesHardCritAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetStateType() == StateTypeHard && service->GetState() == StateCritical)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostGroupsTable::NumServicesHardUnknownAccessor(const Value& row)
|
Value HostGroupsTable::NumServicesHardUnknownAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
int num_services = 0;
|
||||||
return Value();
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||||
|
if (service->GetStateType() == StateTypeHard && service->GetState() == StateUnknown)
|
||||||
|
num_services++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_services;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user