livestatus: add more hosttable todos

refs #4372
This commit is contained in:
Michael Friedrich 2013-07-05 19:14:10 +02:00
parent 337b781088
commit 16adc9a0c5
2 changed files with 51 additions and 12 deletions

View File

@ -830,7 +830,30 @@ Value HostsTable::InCheckPeriodAccessor(const Object::Ptr& object)
Value HostsTable::ContactsAccessor(const Object::Ptr& object)
{
/* TODO */
/* TODO - host->service->notifications->users */
/* use hostcheck service */
Service::Ptr hc = static_pointer_cast<Host>(object)->GetHostCheckService();
if (!hc)
return Value();
std::set<User::Ptr> allUsers;
std::set<User::Ptr> users;
BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
ObjectLock olock(notification);
users = notification->GetUsers();
std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin()));
BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetGroups()) {
std::set<User::Ptr> members = ug->GetMembers();
std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
}
}
return Value();
}
@ -901,8 +924,8 @@ Value HostsTable::ChildsAccessor(const Object::Ptr& object)
Value HostsTable::NumServicesAccessor(const Object::Ptr& object)
{
/* TODO */
return Value();
/* duplicate of TotalServices */
return static_pointer_cast<Host>(object)->GetTotalServices();
}
Value HostsTable::WorstServiceStateAccessor(const Object::Ptr& object)
@ -973,37 +996,53 @@ Value HostsTable::NumServicesHardUnknownAccessor(const Object::Ptr& object)
Value HostsTable::HardStateAccessor(const Object::Ptr& object)
{
/* TODO */
return Value();
/* use hostcheck service */
Service::Ptr hc = static_pointer_cast<Host>(object)->GetHostCheckService();
if (!hc)
return Value();
if (hc->GetState() == StateOK)
return StateOK;
if (hc->GetStateType() == StateTypeHard)
return hc->GetState();
return hc->GetLastHardState();
}
Value HostsTable::PnpgraphPresentAccessor(const Object::Ptr& object)
{
/* TODO */
/* wtf. not supported */
return Value();
}
Value HostsTable::StalenessAccessor(const Object::Ptr& object)
{
/* TODO */
/* TODO time since last check normalized on the check_interval */
return Value();
}
Value HostsTable::GroupsAccessor(const Object::Ptr& object)
{
/* TODO */
return Value();
/* TODO create array */
/* use hostcheck service */
Service::Ptr hc = static_pointer_cast<Host>(object)->GetHostCheckService();
if (!hc)
return Value();
return hc->GetGroups();
}
Value HostsTable::ContactGroupsAccessor(const Object::Ptr& object)
{
/* TODO */
/* TODO create array */
return Value();
}
Value HostsTable::ServicesAccessor(const Object::Ptr& object)
{
/* TODO */
/* TODO create array */
return Value();
}

View File

@ -97,7 +97,7 @@ Host::Ptr Host::GetByName(const String& name)
Array::Ptr Host::GetGroups(void) const
{
return m_HostGroups;;
return m_HostGroups;
}
Dictionary::Ptr Host::GetMacros(void) const