downtimestable.h \
filter.cpp \
filter.h \
+ hostgroupstable.cpp \
+ hostgroupstable.h \
hoststable.cpp \
hoststable.h \
livestatus-type.cpp \
orfilter.h \
query.cpp \
query.h \
+ servicegroupstable.cpp \
+ servicegroupstable.h \
servicestable.cpp \
servicestable.h \
statustable.cpp \
--- /dev/null
+/******************************************************************************
+ * 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;
+}
--- /dev/null
+/******************************************************************************
+ * 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 */
<ClInclude Include="contactstable.h" />
<ClInclude Include="downtimestable.h" />
<ClInclude Include="filter.h" />
+ <ClInclude Include="hostgroupstable.h" />
<ClInclude Include="hoststable.h" />
<ClInclude Include="i2-livestatus.h" />
<ClInclude Include="component.h" />
<ClInclude Include="negatefilter.h" />
<ClInclude Include="orfilter.h" />
<ClInclude Include="query.h" />
+ <ClInclude Include="servicegroupsstable.h" />
<ClInclude Include="servicestable.h" />
<ClInclude Include="statustable.h" />
<ClInclude Include="logtable.h" />
<ClCompile Include="contactstable.cpp" />
<ClCompile Include="downtimestable.cpp" />
<ClCompile Include="filter.cpp" />
+ <ClCompile Include="hostgroupstable.cpp" />
<ClCompile Include="hoststable.cpp" />
<ClCompile Include="livestatus-type.cpp" />
<ClCompile Include="negatefilter.cpp" />
<ClCompile Include="orfilter.cpp" />
<ClCompile Include="query.cpp" />
+ <ClCompile Include="servicegroupstable.cpp" />
<ClCompile Include="servicestable.cpp" />
<ClCompile Include="statustable.cpp" />
<ClCompile Include="logtable.cpp" />
<ClInclude Include="combinerfilter.h">
<Filter>Headerdateien</Filter>
</ClInclude>
+ <ClInclude Include="hostgroupstable.h">
+ <Filter>Headerdateien</Filter>
+ </ClInclude>
<ClInclude Include="hoststable.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="column.h">
<Filter>Headerdateien</Filter>
</ClInclude>
+ <ClInclude Include="servicegroupstable.h">
+ <Filter>Headerdateien</Filter>
+ </ClInclude>
<ClInclude Include="servicestable.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClCompile Include="combinerfilter.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
+ <ClCompile Include="hostgroupstable.cpp">
+ <Filter>Quelldateien</Filter>
+ </ClCompile>
<ClCompile Include="hoststable.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="column.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
+ <ClCompile Include="servicegroupstable.cpp">
+ <Filter>Quelldateien</Filter>
+ </ClCompile>
<ClCompile Include="servicestable.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
--- /dev/null
+/******************************************************************************
+ * 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;
+}
--- /dev/null
+/******************************************************************************
+ * 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 */
return boost::make_shared<ContactGroupsTable>();
else if (name == "contacts")
return boost::make_shared<ContactsTable>();
+ else if (name == "hostgroups")
+ return boost::make_shared<HostsTable>();
else if (name == "hosts")
return boost::make_shared<HostsTable>();
+ else if (name == "servicegroups")
+ return boost::make_shared<ServicesTable>();
else if (name == "services")
return boost::make_shared<ServicesTable>();
else if (name == "commands")