mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
6ce71489c8
commit
540489e408
@ -32,6 +32,8 @@ liblivestatus_la_SOURCES = \
|
|||||||
downtimestable.h \
|
downtimestable.h \
|
||||||
filter.cpp \
|
filter.cpp \
|
||||||
filter.h \
|
filter.h \
|
||||||
|
hostgroupstable.cpp \
|
||||||
|
hostgroupstable.h \
|
||||||
hoststable.cpp \
|
hoststable.cpp \
|
||||||
hoststable.h \
|
hoststable.h \
|
||||||
livestatus-type.cpp \
|
livestatus-type.cpp \
|
||||||
@ -43,6 +45,8 @@ liblivestatus_la_SOURCES = \
|
|||||||
orfilter.h \
|
orfilter.h \
|
||||||
query.cpp \
|
query.cpp \
|
||||||
query.h \
|
query.h \
|
||||||
|
servicegroupstable.cpp \
|
||||||
|
servicegroupstable.h \
|
||||||
servicestable.cpp \
|
servicestable.cpp \
|
||||||
servicestable.h \
|
servicestable.h \
|
||||||
statustable.cpp \
|
statustable.cpp \
|
||||||
|
72
components/livestatus/hostgroupstable.cpp
Normal file
72
components/livestatus/hostgroupstable.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012 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 *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "livestatus/hostgroupstable.h"
|
||||||
|
#include "icinga/hostgroup.h"
|
||||||
|
#include "base/dynamictype.h"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
using namespace livestatus;
|
||||||
|
|
||||||
|
HostGroupsTable::HostGroupsTable(void)
|
||||||
|
{
|
||||||
|
AddColumns(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostGroupsTable::AddColumns(Table *table, const String& prefix,
|
||||||
|
const Column::ObjectAccessor& objectAccessor)
|
||||||
|
{
|
||||||
|
table->AddColumn(prefix + "name", Column(&HostGroupsTable::NameAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "alias", Column(&HostGroupsTable::AliasAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "members", Column(&HostGroupsTable::MembersAccessor, objectAccessor));
|
||||||
|
}
|
||||||
|
|
||||||
|
String HostGroupsTable::GetName(void) const
|
||||||
|
{
|
||||||
|
return "hostgroups";
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostGroupsTable::FetchRows(const AddRowFunction& addRowFn)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("HostGroup")) {
|
||||||
|
addRowFn(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value HostGroupsTable::NameAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
return static_pointer_cast<HostGroup>(object)->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Value HostGroupsTable::AliasAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
return static_pointer_cast<HostGroup>(object)->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Value HostGroupsTable::MembersAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
Array::Ptr members = boost::make_shared<Array>();
|
||||||
|
|
||||||
|
BOOST_FOREACH(const Host::Ptr& host, static_pointer_cast<HostGroup>(object)->GetMembers()) {
|
||||||
|
members->Add(host->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return members;
|
||||||
|
}
|
55
components/livestatus/hostgroupstable.h
Normal file
55
components/livestatus/hostgroupstable.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012 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 *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef HOSTGROUPSTABLE_H
|
||||||
|
#define HOSTGROUPSTABLE_H
|
||||||
|
|
||||||
|
#include "livestatus/table.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
namespace livestatus
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup livestatus
|
||||||
|
*/
|
||||||
|
class HostGroupsTable : public Table
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_PTR_TYPEDEFS(HostGroupsTable);
|
||||||
|
|
||||||
|
HostGroupsTable(void);
|
||||||
|
|
||||||
|
static void AddColumns(Table *table, const String& prefix = String(),
|
||||||
|
const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
|
||||||
|
|
||||||
|
virtual String GetName(void) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void FetchRows(const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
|
static Value NameAccessor(const Object::Ptr& object);
|
||||||
|
static Value AliasAccessor(const Object::Ptr& object);
|
||||||
|
static Value MembersAccessor(const Object::Ptr& object);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HOSTGROUPSTABLE_H */
|
@ -29,12 +29,14 @@
|
|||||||
<ClInclude Include="contactstable.h" />
|
<ClInclude Include="contactstable.h" />
|
||||||
<ClInclude Include="downtimestable.h" />
|
<ClInclude Include="downtimestable.h" />
|
||||||
<ClInclude Include="filter.h" />
|
<ClInclude Include="filter.h" />
|
||||||
|
<ClInclude Include="hostgroupstable.h" />
|
||||||
<ClInclude Include="hoststable.h" />
|
<ClInclude Include="hoststable.h" />
|
||||||
<ClInclude Include="i2-livestatus.h" />
|
<ClInclude Include="i2-livestatus.h" />
|
||||||
<ClInclude Include="component.h" />
|
<ClInclude Include="component.h" />
|
||||||
<ClInclude Include="negatefilter.h" />
|
<ClInclude Include="negatefilter.h" />
|
||||||
<ClInclude Include="orfilter.h" />
|
<ClInclude Include="orfilter.h" />
|
||||||
<ClInclude Include="query.h" />
|
<ClInclude Include="query.h" />
|
||||||
|
<ClInclude Include="servicegroupsstable.h" />
|
||||||
<ClInclude Include="servicestable.h" />
|
<ClInclude Include="servicestable.h" />
|
||||||
<ClInclude Include="statustable.h" />
|
<ClInclude Include="statustable.h" />
|
||||||
<ClInclude Include="logtable.h" />
|
<ClInclude Include="logtable.h" />
|
||||||
@ -52,11 +54,13 @@
|
|||||||
<ClCompile Include="contactstable.cpp" />
|
<ClCompile Include="contactstable.cpp" />
|
||||||
<ClCompile Include="downtimestable.cpp" />
|
<ClCompile Include="downtimestable.cpp" />
|
||||||
<ClCompile Include="filter.cpp" />
|
<ClCompile Include="filter.cpp" />
|
||||||
|
<ClCompile Include="hostgroupstable.cpp" />
|
||||||
<ClCompile Include="hoststable.cpp" />
|
<ClCompile Include="hoststable.cpp" />
|
||||||
<ClCompile Include="livestatus-type.cpp" />
|
<ClCompile Include="livestatus-type.cpp" />
|
||||||
<ClCompile Include="negatefilter.cpp" />
|
<ClCompile Include="negatefilter.cpp" />
|
||||||
<ClCompile Include="orfilter.cpp" />
|
<ClCompile Include="orfilter.cpp" />
|
||||||
<ClCompile Include="query.cpp" />
|
<ClCompile Include="query.cpp" />
|
||||||
|
<ClCompile Include="servicegroupstable.cpp" />
|
||||||
<ClCompile Include="servicestable.cpp" />
|
<ClCompile Include="servicestable.cpp" />
|
||||||
<ClCompile Include="statustable.cpp" />
|
<ClCompile Include="statustable.cpp" />
|
||||||
<ClCompile Include="logtable.cpp" />
|
<ClCompile Include="logtable.cpp" />
|
||||||
|
@ -51,12 +51,18 @@
|
|||||||
<ClInclude Include="combinerfilter.h">
|
<ClInclude Include="combinerfilter.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="hostgroupstable.h">
|
||||||
|
<Filter>Headerdateien</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="hoststable.h">
|
<ClInclude Include="hoststable.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="column.h">
|
<ClInclude Include="column.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="servicegroupstable.h">
|
||||||
|
<Filter>Headerdateien</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="servicestable.h">
|
<ClInclude Include="servicestable.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -110,12 +116,18 @@
|
|||||||
<ClCompile Include="combinerfilter.cpp">
|
<ClCompile Include="combinerfilter.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="hostgroupstable.cpp">
|
||||||
|
<Filter>Quelldateien</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="hoststable.cpp">
|
<ClCompile Include="hoststable.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="column.cpp">
|
<ClCompile Include="column.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="servicegroupstable.cpp">
|
||||||
|
<Filter>Quelldateien</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="servicestable.cpp">
|
<ClCompile Include="servicestable.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
72
components/livestatus/servicegroupstable.cpp
Normal file
72
components/livestatus/servicegroupstable.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012 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 *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "livestatus/servicegroupstable.h"
|
||||||
|
#include "icinga/servicegroup.h"
|
||||||
|
#include "base/dynamictype.h"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
using namespace livestatus;
|
||||||
|
|
||||||
|
ServiceGroupsTable::ServiceGroupsTable(void)
|
||||||
|
{
|
||||||
|
AddColumns(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceGroupsTable::AddColumns(Table *table, const String& prefix,
|
||||||
|
const Column::ObjectAccessor& objectAccessor)
|
||||||
|
{
|
||||||
|
table->AddColumn(prefix + "name", Column(&ServiceGroupsTable::NameAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "alias", Column(&ServiceGroupsTable::AliasAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "members", Column(&ServiceGroupsTable::MembersAccessor, objectAccessor));
|
||||||
|
}
|
||||||
|
|
||||||
|
String ServiceGroupsTable::GetName(void) const
|
||||||
|
{
|
||||||
|
return "servicegroups";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceGroupsTable::FetchRows(const AddRowFunction& addRowFn)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("UserGroup")) {
|
||||||
|
addRowFn(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value ServiceGroupsTable::NameAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
return static_pointer_cast<ServiceGroup>(object)->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Value ServiceGroupsTable::AliasAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
return static_pointer_cast<ServiceGroup>(object)->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Value ServiceGroupsTable::MembersAccessor(const Object::Ptr& object)
|
||||||
|
{
|
||||||
|
Array::Ptr members = boost::make_shared<Array>();
|
||||||
|
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, static_pointer_cast<ServiceGroup>(object)->GetMembers()) {
|
||||||
|
members->Add(service->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return members;
|
||||||
|
}
|
55
components/livestatus/servicegroupstable.h
Normal file
55
components/livestatus/servicegroupstable.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012 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 *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SERVICEGROUPSTABLE_H
|
||||||
|
#define SERVICEGROUPSTABLE_H
|
||||||
|
|
||||||
|
#include "livestatus/table.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
namespace livestatus
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup livestatus
|
||||||
|
*/
|
||||||
|
class ServiceGroupsTable : public Table
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_PTR_TYPEDEFS(ServiceGroupsTable);
|
||||||
|
|
||||||
|
ServiceGroupsTable(void);
|
||||||
|
|
||||||
|
static void AddColumns(Table *table, const String& prefix = String(),
|
||||||
|
const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
|
||||||
|
|
||||||
|
virtual String GetName(void) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void FetchRows(const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
|
static Value NameAccessor(const Object::Ptr& object);
|
||||||
|
static Value AliasAccessor(const Object::Ptr& object);
|
||||||
|
static Value MembersAccessor(const Object::Ptr& object);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* SERVICEGROUPSTABLE_H */
|
@ -49,8 +49,12 @@ Table::Ptr Table::GetByName(const String& name)
|
|||||||
return boost::make_shared<ContactGroupsTable>();
|
return boost::make_shared<ContactGroupsTable>();
|
||||||
else if (name == "contacts")
|
else if (name == "contacts")
|
||||||
return boost::make_shared<ContactsTable>();
|
return boost::make_shared<ContactsTable>();
|
||||||
|
else if (name == "hostgroups")
|
||||||
|
return boost::make_shared<HostsTable>();
|
||||||
else if (name == "hosts")
|
else if (name == "hosts")
|
||||||
return boost::make_shared<HostsTable>();
|
return boost::make_shared<HostsTable>();
|
||||||
|
else if (name == "servicegroups")
|
||||||
|
return boost::make_shared<ServicesTable>();
|
||||||
else if (name == "services")
|
else if (name == "services")
|
||||||
return boost::make_shared<ServicesTable>();
|
return boost::make_shared<ServicesTable>();
|
||||||
else if (name == "commands")
|
else if (name == "commands")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user