/******************************************************************************
* Icinga 2 *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
+ * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
#include <boost/foreach.hpp>
using namespace icinga;
-using namespace livestatus;
HostGroupsTable::HostGroupsTable(void)
{
Value HostGroupsTable::NotesAccessor(const Value& row)
{
- Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+ Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
- if (!custom)
+ if (!vars)
return Empty;
- return custom->Get("notes");
+ return vars->Get("notes");
}
Value HostGroupsTable::NotesUrlAccessor(const Value& row)
{
- Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+ Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
- if (!custom)
+ if (!vars)
return Empty;
- return custom->Get("notes_url");
+ return vars->Get("notes_url");
}
Value HostGroupsTable::ActionUrlAccessor(const Value& row)
{
- Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+ Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
- if (!custom)
+ if (!vars)
return Empty;
- return custom->Get("action_url");
+ return vars->Get("action_url");
}
Value HostGroupsTable::MembersAccessor(const Value& row)
{
- Array::Ptr members = boost::make_shared<Array>();
+ Array::Ptr members = make_shared<Array>();
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
members->Add(host->GetName());
Value HostGroupsTable::MembersWithStateAccessor(const Value& row)
{
- Array::Ptr members = boost::make_shared<Array>();
+ Array::Ptr members = make_shared<Array>();
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
- Array::Ptr member_state = boost::make_shared<Array>();
+ Array::Ptr member_state = make_shared<Array>();
member_state->Add(host->GetName());
member_state->Add(host->GetState());
members->Add(member_state);
int num_hosts = 0;
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())
+ /* no checkresult */
+ if (!host->GetLastCheckResult())
num_hosts++;
}
int num_hosts = 0;
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
- if (host->GetState() == HostUnreachable)
+ if (!host->IsReachable())
num_hosts++;
}
return 0;
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
- BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
- num_services++;
- }
+ num_services += host->GetServices().size();
}
return num_services;