mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
parent
3184fee145
commit
4731faea89
@ -51,6 +51,8 @@ liblivestatus_la_SOURCES = \
|
|||||||
servicestable.h \
|
servicestable.h \
|
||||||
statustable.cpp \
|
statustable.cpp \
|
||||||
statustable.h \
|
statustable.h \
|
||||||
|
timeperiodstable.cpp \
|
||||||
|
timeperiodstable.h \
|
||||||
table.cpp \
|
table.cpp \
|
||||||
table.h
|
table.h
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
<ClInclude Include="servicegroupsstable.h" />
|
<ClInclude Include="servicegroupsstable.h" />
|
||||||
<ClInclude Include="servicestable.h" />
|
<ClInclude Include="servicestable.h" />
|
||||||
<ClInclude Include="statustable.h" />
|
<ClInclude Include="statustable.h" />
|
||||||
|
<ClInclude Include="timeperiodstable.h" />
|
||||||
<ClInclude Include="logtable.h" />
|
<ClInclude Include="logtable.h" />
|
||||||
<ClInclude Include="table.h" />
|
<ClInclude Include="table.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -63,6 +64,7 @@
|
|||||||
<ClCompile Include="servicegroupstable.cpp" />
|
<ClCompile Include="servicegroupstable.cpp" />
|
||||||
<ClCompile Include="servicestable.cpp" />
|
<ClCompile Include="servicestable.cpp" />
|
||||||
<ClCompile Include="statustable.cpp" />
|
<ClCompile Include="statustable.cpp" />
|
||||||
|
<ClCompile Include="timeperiodstable.cpp" />
|
||||||
<ClCompile Include="logtable.cpp" />
|
<ClCompile Include="logtable.cpp" />
|
||||||
<ClCompile Include="table.cpp" />
|
<ClCompile Include="table.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
<ClInclude Include="statustable.h">
|
<ClInclude Include="statustable.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="timeperiodstable.h">
|
||||||
|
<Filter>Headerdateien</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="logtable.h">
|
<ClInclude Include="logtable.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -89,6 +92,9 @@
|
|||||||
<ClCompile Include="statustable.cpp">
|
<ClCompile Include="statustable.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="timeperiodstable.cpp">
|
||||||
|
<Filter>Quelldateien</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="logtable.cpp">
|
<ClCompile Include="logtable.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "livestatus/commandstable.h"
|
#include "livestatus/commandstable.h"
|
||||||
#include "livestatus/commentstable.h"
|
#include "livestatus/commentstable.h"
|
||||||
#include "livestatus/downtimestable.h"
|
#include "livestatus/downtimestable.h"
|
||||||
|
#include "livestatus/timeperiodstable.h"
|
||||||
#include "livestatus/logtable.h"
|
#include "livestatus/logtable.h"
|
||||||
#include "livestatus/filter.h"
|
#include "livestatus/filter.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
@ -65,6 +66,8 @@ Table::Ptr Table::GetByName(const String& name)
|
|||||||
return boost::make_shared<CommentsTable>();
|
return boost::make_shared<CommentsTable>();
|
||||||
else if (name == "downtimes")
|
else if (name == "downtimes")
|
||||||
return boost::make_shared<DowntimesTable>();
|
return boost::make_shared<DowntimesTable>();
|
||||||
|
else if (name == "timeperiods")
|
||||||
|
return boost::make_shared<TimePeriodsTable>();
|
||||||
else if (name == "log")
|
else if (name == "log")
|
||||||
return boost::make_shared<LogTable>();
|
return boost::make_shared<LogTable>();
|
||||||
|
|
||||||
|
66
components/livestatus/timeperiodstable.cpp
Normal file
66
components/livestatus/timeperiodstable.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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/timeperiodstable.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
|
#include "icinga/timeperiod.h"
|
||||||
|
#include "base/dynamictype.h"
|
||||||
|
#include "base/objectlock.h"
|
||||||
|
#include "base/convert.h"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
using namespace livestatus;
|
||||||
|
|
||||||
|
TimePeriodsTable::TimePeriodsTable(void)
|
||||||
|
{
|
||||||
|
AddColumns(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimePeriodsTable::AddColumns(Table *table, const String& prefix,
|
||||||
|
const Column::ObjectAccessor& objectAccessor)
|
||||||
|
{
|
||||||
|
table->AddColumn(prefix + "name", Column(&TimePeriodsTable::NameAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "alias", Column(&TimePeriodsTable::AliasAccessor, objectAccessor));
|
||||||
|
}
|
||||||
|
|
||||||
|
String TimePeriodsTable::GetName(void) const
|
||||||
|
{
|
||||||
|
return "timeperiod";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimePeriodsTable::FetchRows(const AddRowFunction& addRowFn)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("TimePeriod")) {
|
||||||
|
addRowFn(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value TimePeriodsTable::NameAccessor(const Value& row)
|
||||||
|
{
|
||||||
|
return static_cast<TimePeriod::Ptr>(row)->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Value TimePeriodsTable::AliasAccessor(const Value& row)
|
||||||
|
{
|
||||||
|
/* TODO GetDisplayName() ? */
|
||||||
|
return static_cast<TimePeriod::Ptr>(row)->GetName();
|
||||||
|
}
|
||||||
|
|
54
components/livestatus/timeperiodstable.h
Normal file
54
components/livestatus/timeperiodstable.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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 TIMEPERIODSTABLE_H
|
||||||
|
#define TIMEPERIODSTABLE_H
|
||||||
|
|
||||||
|
#include "livestatus/table.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
namespace livestatus
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup livestatus
|
||||||
|
*/
|
||||||
|
class TimePeriodsTable : public Table
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_PTR_TYPEDEFS(TimePeriodsTable);
|
||||||
|
|
||||||
|
TimePeriodsTable(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 Value& row);
|
||||||
|
static Value AliasAccessor(const Value& row);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TIMEPERIODSTABLE_H */
|
Loading…
x
Reference in New Issue
Block a user