mirror of https://github.com/Icinga/icinga2.git
parent
91c82263a5
commit
3c363499bb
|
@ -5,6 +5,7 @@ include aminclude.am
|
|||
|
||||
SUBDIRS = \
|
||||
third-party \
|
||||
tools \
|
||||
lib \
|
||||
components \
|
||||
icinga-app \
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
checker-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
checker.la
|
||||
libchecker.la
|
||||
|
||||
checker_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
checker-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libchecker_la_SOURCES = \
|
||||
checkercomponent.cpp \
|
||||
checkercomponent.h \
|
||||
checker-type.cpp \
|
||||
i2-checker.h
|
||||
|
||||
checker_la_CPPFLAGS = \
|
||||
libchecker_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
checker_la_LDFLAGS = \
|
||||
libchecker_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
checker_la_LIBADD = \
|
||||
libchecker_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type CheckerComponent {
|
||||
}
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("checker", CheckerComponent);
|
||||
REGISTER_TYPE(CheckerComponent);
|
||||
|
||||
CheckerComponent::CheckerComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{ }
|
||||
|
||||
void CheckerComponent::Start(void)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ struct ServiceNextCheckExtractor
|
|||
/**
|
||||
* @ingroup checker
|
||||
*/
|
||||
class CheckerComponent : public IComponent
|
||||
class CheckerComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<CheckerComponent> Ptr;
|
||||
|
@ -63,6 +63,8 @@ public:
|
|||
>
|
||||
> ServiceSet;
|
||||
|
||||
CheckerComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
compat-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
compat.la
|
||||
libcompat.la
|
||||
|
||||
compat_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
compat-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libcompat_la_SOURCES = \
|
||||
compatcomponent.cpp \
|
||||
compatcomponent.h \
|
||||
compat-type.cpp \
|
||||
i2-compat.h
|
||||
|
||||
compat_la_CPPFLAGS = \
|
||||
libcompat_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
compat_la_LDFLAGS = \
|
||||
libcompat_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
compat_la_LIBADD = \
|
||||
libcompat_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type CompatComponent {
|
||||
%attribute string "status_path",
|
||||
%attribute string "objects_path",
|
||||
%attribute string "log_path",
|
||||
%attribute string "command_path"
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("compat", CompatComponent);
|
||||
REGISTER_TYPE(CompatComponent);
|
||||
|
||||
/**
|
||||
* Hint: The reason why we're using "\n" rather than std::endl is because
|
||||
|
@ -29,70 +29,6 @@ REGISTER_COMPONENT("compat", CompatComponent);
|
|||
* performance (see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves the status.dat path.
|
||||
*
|
||||
* @returns statuspath from config, or static default
|
||||
*/
|
||||
String CompatComponent::GetStatusPath(void) const
|
||||
{
|
||||
DynamicObject::Ptr config = GetConfig();
|
||||
|
||||
Value statusPath = config->Get("status_path");
|
||||
if (statusPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/status.dat";
|
||||
else
|
||||
return statusPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the objects.cache path.
|
||||
*
|
||||
* @returns objectspath from config, or static default
|
||||
*/
|
||||
String CompatComponent::GetObjectsPath(void) const
|
||||
{
|
||||
DynamicObject::Ptr config = GetConfig();
|
||||
|
||||
Value objectsPath = config->Get("objects_path");
|
||||
if (objectsPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache";
|
||||
else
|
||||
return objectsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the log path.
|
||||
*
|
||||
* @returns log path
|
||||
*/
|
||||
String CompatComponent::GetLogPath(void) const
|
||||
{
|
||||
DynamicObject::Ptr config = GetConfig();
|
||||
|
||||
Value logPath = config->Get("log_path");
|
||||
if (logPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/log/icinga2/compat";
|
||||
else
|
||||
return logPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the icinga.cmd path.
|
||||
*
|
||||
* @returns icinga.cmd path
|
||||
*/
|
||||
String CompatComponent::GetCommandPath(void) const
|
||||
{
|
||||
DynamicObject::Ptr config = GetConfig();
|
||||
|
||||
Value commandPath = config->Get("command_path");
|
||||
if (commandPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/run/icinga2/icinga2.cmd";
|
||||
else
|
||||
return commandPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
*/
|
||||
|
@ -111,10 +47,68 @@ void CompatComponent::Start(void)
|
|||
}
|
||||
|
||||
/**
|
||||
* Stops the component.
|
||||
* Retrieves the status.dat path.
|
||||
*
|
||||
* @returns statuspath from config, or static default
|
||||
*/
|
||||
void CompatComponent::Stop(void)
|
||||
String CompatComponent::GetStatusPath(void) const
|
||||
{
|
||||
Value statusPath = m_StatusPath;
|
||||
if (statusPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/status.dat";
|
||||
else
|
||||
return statusPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the objects.cache path.
|
||||
*
|
||||
* @returns objectspath from config, or static default
|
||||
*/
|
||||
String CompatComponent::GetObjectsPath(void) const
|
||||
{
|
||||
Value objectsPath = m_ObjectsPath;
|
||||
if (objectsPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache";
|
||||
else
|
||||
return objectsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the log path.
|
||||
*
|
||||
* @returns log path
|
||||
*/
|
||||
String CompatComponent::GetLogPath(void) const
|
||||
{
|
||||
Value logPath = m_LogPath;
|
||||
if (logPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/log/icinga2/compat";
|
||||
else
|
||||
return logPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the icinga.cmd path.
|
||||
*
|
||||
* @returns icinga.cmd path
|
||||
*/
|
||||
String CompatComponent::GetCommandPath(void) const
|
||||
{
|
||||
Value commandPath = m_CommandPath;
|
||||
if (commandPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/run/icinga2/icinga2.cmd";
|
||||
else
|
||||
return commandPath;
|
||||
}
|
||||
|
||||
CompatComponent::CompatComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{
|
||||
RegisterAttribute("status_path", Attribute_Config, &m_StatusPath);
|
||||
RegisterAttribute("objects_path", Attribute_Config, &m_ObjectsPath);
|
||||
RegisterAttribute("log_path", Attribute_Config, &m_LogPath);
|
||||
RegisterAttribute("command_path", Attribute_Config, &m_CommandPath);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
|
@ -32,13 +32,19 @@ enum CompatObjectType
|
|||
/**
|
||||
* @ingroup compat
|
||||
*/
|
||||
class CompatComponent : public IComponent
|
||||
class CompatComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
CompatComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
private:
|
||||
Attribute<String> m_StatusPath;
|
||||
Attribute<String> m_ObjectsPath;
|
||||
Attribute<String> m_LogPath;
|
||||
Attribute<String> m_CommandPath;
|
||||
|
||||
#ifndef _WIN32
|
||||
thread m_CommandThread;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
delegation-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
delegation.la
|
||||
libdelegation.la
|
||||
|
||||
delegation_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
delegation-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libdelegation_la_SOURCES = \
|
||||
delegationcomponent.cpp \
|
||||
delegationcomponent.h \
|
||||
delegation-type.cpp \
|
||||
i2-delegation.h
|
||||
|
||||
delegation_la_CPPFLAGS = \
|
||||
libdelegation_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
delegation_la_LDFLAGS = \
|
||||
libdelegation_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
delegation_la_LIBADD = \
|
||||
libdelegation_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type DelegationComponent {
|
||||
}
|
|
@ -22,13 +22,16 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("delegation", DelegationComponent);
|
||||
REGISTER_TYPE(DelegationComponent);
|
||||
|
||||
DelegationComponent::DelegationComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{ }
|
||||
|
||||
void DelegationComponent::Start(void)
|
||||
{
|
||||
m_DelegationTimer = boost::make_shared<Timer>();
|
||||
|
||||
// TODO: implement a handler for config changes for the delegation_interval variable
|
||||
m_DelegationTimer->SetInterval(30);
|
||||
m_DelegationTimer->OnTimerExpired.connect(boost::bind(&DelegationComponent::DelegationTimerHandler, this));
|
||||
m_DelegationTimer->Start();
|
||||
|
|
|
@ -26,9 +26,11 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup delegation
|
||||
*/
|
||||
class DelegationComponent : public IComponent
|
||||
class DelegationComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
DelegationComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
|
||||
private:
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
demo-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
demo.la
|
||||
libdemo.la
|
||||
|
||||
demo_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
demo-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libdemo_la_SOURCES = \
|
||||
democomponent.cpp \
|
||||
democomponent.h \
|
||||
demo-type.cpp \
|
||||
i2-demo.h
|
||||
|
||||
demo_la_CPPFLAGS = \
|
||||
libdemo_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
demo_la_LDFLAGS = \
|
||||
libdemo_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
demo_la_LIBADD = \
|
||||
libdemo_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type DemoComponent {
|
||||
}
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("demo", DemoComponent);
|
||||
REGISTER_TYPE(DemoComponent);
|
||||
|
||||
DemoComponent::DemoComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
|
|
|
@ -26,9 +26,11 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup demo
|
||||
*/
|
||||
class DemoComponent : public IComponent
|
||||
class DemoComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
DemoComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
livestatus-type.cpp
|
|
@ -1,9 +1,15 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
livestatus.la
|
||||
liblivestatus.la
|
||||
|
||||
livestatus_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
livestatus-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
liblivestatus_la_SOURCES = \
|
||||
attributefilter.cpp \
|
||||
attributefilter.h \
|
||||
andfilter.cpp \
|
||||
|
@ -28,6 +34,7 @@ livestatus_la_SOURCES = \
|
|||
filter.h \
|
||||
hoststable.cpp \
|
||||
hoststable.h \
|
||||
livestatus-type.cpp \
|
||||
negatefilter.cpp \
|
||||
negatefilter.h \
|
||||
orfilter.cpp \
|
||||
|
@ -42,21 +49,21 @@ livestatus_la_SOURCES = \
|
|||
table.h \
|
||||
i2-livestatus.h
|
||||
|
||||
livestatus_la_CPPFLAGS = \
|
||||
liblivestatus_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
livestatus_la_LDFLAGS = \
|
||||
liblivestatus_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
livestatus_la_LIBADD = \
|
||||
liblivestatus_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -22,7 +22,13 @@
|
|||
using namespace icinga;
|
||||
using namespace livestatus;
|
||||
|
||||
REGISTER_COMPONENT("livestatus", LivestatusComponent);
|
||||
REGISTER_TYPE(LivestatusComponent);
|
||||
|
||||
LivestatusComponent::LivestatusComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{
|
||||
RegisterAttribute("socket_path", Attribute_Config, &m_SocketPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
|
@ -43,18 +49,9 @@ void LivestatusComponent::Start(void)
|
|||
m_Listener = socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the component.
|
||||
*/
|
||||
void LivestatusComponent::Stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
String LivestatusComponent::GetSocketPath(void) const
|
||||
{
|
||||
DynamicObject::Ptr config = GetConfig();
|
||||
|
||||
Value socketPath = config->Get("socket_path");
|
||||
Value socketPath = m_SocketPath;
|
||||
if (socketPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/run/icinga2/livestatus";
|
||||
else
|
||||
|
|
|
@ -26,15 +26,18 @@ namespace livestatus
|
|||
/**
|
||||
* @ingroup livestatus
|
||||
*/
|
||||
class LivestatusComponent : public IComponent
|
||||
class LivestatusComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
LivestatusComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
String GetSocketPath(void) const;
|
||||
|
||||
private:
|
||||
Attribute<String> m_SocketPath;
|
||||
|
||||
Socket::Ptr m_Listener;
|
||||
set<LivestatusConnection::Ptr> m_Connections;
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type LivestatusComponent {
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
notification-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
notification.la
|
||||
libnotification.la
|
||||
|
||||
notification_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
notification-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libnotification_la_SOURCES = \
|
||||
notificationcomponent.cpp \
|
||||
notificationcomponent.h \
|
||||
notification-type.cpp \
|
||||
i2-notification.h
|
||||
|
||||
notification_la_CPPFLAGS = \
|
||||
libnotification_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
notification_la_LDFLAGS = \
|
||||
libnotification_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
notification_la_LIBADD = \
|
||||
libnotification_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type NotificationComponent {
|
||||
}
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("notification", NotificationComponent);
|
||||
REGISTER_TYPE(NotificationComponent);
|
||||
|
||||
NotificationComponent::NotificationComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
|
|
|
@ -26,9 +26,11 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup notification
|
||||
*/
|
||||
class NotificationComponent : public IComponent
|
||||
class NotificationComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
NotificationComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
replication-type.cpp
|
|
@ -1,28 +1,35 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pkglib_LTLIBRARIES = \
|
||||
replication.la
|
||||
libreplication.la
|
||||
|
||||
replication_la_SOURCES = \
|
||||
EXTRA_DIST = \
|
||||
replication-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libreplication_la_SOURCES = \
|
||||
replicationcomponent.cpp \
|
||||
replicationcomponent.h \
|
||||
replication-type.cpp \
|
||||
i2-replication.h
|
||||
|
||||
replication_la_CPPFLAGS = \
|
||||
libreplication_la_CPPFLAGS = \
|
||||
$(BOOST_CPPFLAGS) \
|
||||
-I${top_srcdir}/lib/base \
|
||||
-I${top_srcdir}/lib/config \
|
||||
-I${top_srcdir}/lib/remoting \
|
||||
-I${top_srcdir}/lib/icinga
|
||||
|
||||
replication_la_LDFLAGS = \
|
||||
libreplication_la_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
-module \
|
||||
-no-undefined \
|
||||
@RELEASE_INFO@ \
|
||||
@VERSION_INFO@
|
||||
|
||||
replication_la_LIBADD = \
|
||||
libreplication_la_LIBADD = \
|
||||
$(BOOST_SIGNALS_LIB) \
|
||||
$(BOOST_THREAD_LIB) \
|
||||
${top_builddir}/lib/base/libbase.la \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type ReplicationComponent {
|
||||
}
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_COMPONENT("replication", ReplicationComponent);
|
||||
REGISTER_TYPE(ReplicationComponent);
|
||||
|
||||
ReplicationComponent::ReplicationComponent(const Dictionary::Ptr& serializedUpdate)
|
||||
: DynamicObject(serializedUpdate)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
|
|
|
@ -26,9 +26,11 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup replication
|
||||
*/
|
||||
class ReplicationComponent : public IComponent
|
||||
class ReplicationComponent : public DynamicObject
|
||||
{
|
||||
public:
|
||||
ReplicationComponent(const Dictionary::Ptr& serializedUpdate);
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ third-party/cJSON/Makefile
|
|||
third-party/execvpe/Makefile
|
||||
third-party/mmatch/Makefile
|
||||
third-party/popen-noshell/Makefile
|
||||
tools/Makefile
|
||||
])
|
||||
AC_OUTPUT([
|
||||
etc/init.d/icinga2
|
||||
|
|
|
@ -29,12 +29,12 @@ icinga2_LDADD = \
|
|||
${top_builddir}/lib/base/libbase.la \
|
||||
${top_builddir}/lib/config/libconfig.la \
|
||||
-dlopen ${top_builddir}/lib/icinga/libicinga.la \
|
||||
-dlopen ${top_builddir}/components/checker/checker.la \
|
||||
-dlopen ${top_builddir}/components/replication/replication.la \
|
||||
-dlopen ${top_builddir}/components/compat/compat.la \
|
||||
-dlopen ${top_builddir}/components/delegation/delegation.la \
|
||||
-dlopen ${top_builddir}/components/demo/demo.la \
|
||||
-dlopen ${top_builddir}/components/notification/notification.la
|
||||
-dlopen ${top_builddir}/components/checker/libchecker.la \
|
||||
-dlopen ${top_builddir}/components/replication/libreplication.la \
|
||||
-dlopen ${top_builddir}/components/compat/libcompat.la \
|
||||
-dlopen ${top_builddir}/components/delegation/libdelegation.la \
|
||||
-dlopen ${top_builddir}/components/demo/libdemo.la \
|
||||
-dlopen ${top_builddir}/components/notification/libnotification.la
|
||||
|
||||
if PYTHON_USE
|
||||
icinga2_LDADD += \
|
||||
|
|
|
@ -48,6 +48,11 @@ static bool LoadConfigFiles(bool validateOnly)
|
|||
ConfigCompiler::CompileFile(configPath);
|
||||
}
|
||||
|
||||
String name, fragment;
|
||||
BOOST_FOREACH(tie(name, fragment), ConfigCompiler::GetConfigFragments()) {
|
||||
ConfigCompiler::CompileText(name, fragment);
|
||||
}
|
||||
|
||||
ConfigCompilerContext::SetContext(NULL);
|
||||
|
||||
context.Validate();
|
||||
|
@ -207,13 +212,20 @@ int main(int argc, char **argv)
|
|||
#endif /* _WIN32 */
|
||||
);
|
||||
|
||||
Component::AddSearchDir(Application::GetPkgLibDir());
|
||||
String searchDir = Application::GetPkgLibDir();
|
||||
Logger::Write(LogInformation, "base", "Adding library search dir: " + searchDir);
|
||||
|
||||
(void) Utility::LoadIcingaLibrary("icinga", false);
|
||||
#ifdef _WIN32
|
||||
SetDllDirectory(searchDir.CStr());
|
||||
#else /* _WIN32 */
|
||||
lt_dladdsearchdir(searchDir.CStr());
|
||||
#endif /* _WIN32 */
|
||||
|
||||
(void) Utility::LoadExtensionLibrary("icinga");
|
||||
|
||||
if (g_AppParams.count("library")) {
|
||||
BOOST_FOREACH(const String& libraryName, g_AppParams["library"].as<vector<String> >()) {
|
||||
Utility::LoadIcingaLibrary(libraryName, false);
|
||||
(void) Utility::LoadExtensionLibrary(libraryName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,5 +5,4 @@ icinga2itl_DATA = \
|
|||
notification.conf \
|
||||
service.conf \
|
||||
service-common.conf \
|
||||
standalone.conf \
|
||||
types.conf
|
||||
standalone.conf
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
* configuration templates.
|
||||
*/
|
||||
|
||||
#include "types.conf"
|
||||
|
||||
#include "host.conf"
|
||||
#include "service.conf"
|
||||
#include "service-common.conf"
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
local object Component "checker" {}
|
||||
|
||||
local object Component "delegation" {}
|
||||
#library "checker"
|
||||
local object CheckerComponent "checker" {}
|
||||
|
||||
local object Component "notification" {}
|
||||
#library "delegation"
|
||||
local object DelegationComponent "delegation" {}
|
||||
|
||||
#library "notification"
|
||||
local object NotificationComponent "notification" {}
|
||||
|
|
|
@ -12,8 +12,6 @@ libbase_la_SOURCES = \
|
|||
asynctask.h \
|
||||
attribute.cpp \
|
||||
attribute.h \
|
||||
component.cpp \
|
||||
component.h \
|
||||
connection.cpp \
|
||||
connection.h \
|
||||
convert.cpp \
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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 "i2-base.h"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_TYPE(Component);
|
||||
|
||||
boost::mutex Component::m_Mutex;
|
||||
map<String, Component::Factory> Component::m_Factories;
|
||||
|
||||
/**
|
||||
* Constructor for the component class.
|
||||
*/
|
||||
Component::Component(const Dictionary::Ptr& properties)
|
||||
: DynamicObject(properties)
|
||||
{
|
||||
if (!IsLocal())
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Component objects must be local."));
|
||||
|
||||
Logger::Write(LogInformation, "base", "Loading component '" + GetName() + "'");
|
||||
|
||||
(void) Utility::LoadIcingaLibrary(GetName(), true);
|
||||
|
||||
Component::Factory factory;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
map<String, Factory>::iterator it;
|
||||
it = m_Factories.find(GetName());
|
||||
|
||||
if (it == m_Factories.end())
|
||||
BOOST_THROW_EXCEPTION(invalid_argument("Unknown component: " + GetName()));
|
||||
|
||||
factory = it->second;
|
||||
}
|
||||
|
||||
m_Impl = factory();
|
||||
|
||||
if (!m_Impl)
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Component factory returned NULL."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for the Component class.
|
||||
*/
|
||||
Component::~Component(void)
|
||||
{
|
||||
if (m_Impl)
|
||||
m_Impl->Stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the component. Called when the DynamicObject is fully
|
||||
* constructed/registered.
|
||||
*/
|
||||
void Component::Start(void)
|
||||
{
|
||||
m_Impl->SetConfig(GetSelf());
|
||||
m_Impl->Start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a directory to the component search path.
|
||||
*
|
||||
* @param componentDirectory The directory.
|
||||
*/
|
||||
void Component::AddSearchDir(const String& componentDirectory)
|
||||
{
|
||||
Logger::Write(LogInformation, "base", "Adding library search dir: " +
|
||||
componentDirectory);
|
||||
|
||||
#ifdef _WIN32
|
||||
SetDllDirectory(componentDirectory.CStr());
|
||||
#else /* _WIN32 */
|
||||
lt_dladdsearchdir(componentDirectory.CStr());
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the configuration for this component.
|
||||
*
|
||||
* @returns The configuration.
|
||||
*/
|
||||
DynamicObject::Ptr IComponent::GetConfig(void) const
|
||||
{
|
||||
return m_Config.lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration for this component.
|
||||
*/
|
||||
void IComponent::SetConfig(const DynamicObject::Ptr& config)
|
||||
{
|
||||
m_Config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the component.
|
||||
*/
|
||||
void IComponent::Start(void)
|
||||
{
|
||||
/* Nothing to do in the default implementation. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the component.
|
||||
*/
|
||||
void IComponent::Stop(void)
|
||||
{
|
||||
/* Nothing to do in the default implementation. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a component factory.
|
||||
*/
|
||||
void Component::Register(const String& name, const Component::Factory& factory)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
m_Factories[name] = factory;
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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 COMPONENT_H
|
||||
#define COMPONENT_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Interface for application extensions.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API IComponent : public Object
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<IComponent> Ptr;
|
||||
typedef weak_ptr<IComponent> WeakPtr;
|
||||
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
protected:
|
||||
DynamicObject::Ptr GetConfig(void) const;
|
||||
|
||||
private:
|
||||
DynamicObject::WeakPtr m_Config; /**< The configuration object for this
|
||||
component. */
|
||||
|
||||
void SetConfig(const DynamicObject::Ptr& config);
|
||||
|
||||
friend class Component;
|
||||
};
|
||||
|
||||
/**
|
||||
* An application extension that can be dynamically loaded
|
||||
* at run-time.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API Component : public DynamicObject
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<Component> Ptr;
|
||||
typedef weak_ptr<Component> WeakPtr;
|
||||
|
||||
typedef function<IComponent::Ptr (void)> Factory;
|
||||
|
||||
Component(const Dictionary::Ptr& properties);
|
||||
~Component(void);
|
||||
|
||||
virtual void Start(void);
|
||||
|
||||
static void AddSearchDir(const String& componentDirectory);
|
||||
|
||||
static void Register(const String& name, const Factory& factory);
|
||||
|
||||
private:
|
||||
IComponent::Ptr m_Impl; /**< The implementation object for this
|
||||
component. */
|
||||
|
||||
static boost::mutex m_Mutex;
|
||||
static map<String, Factory> m_Factories;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class for registering Component implementation classes.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class RegisterComponentHelper
|
||||
{
|
||||
public:
|
||||
RegisterComponentHelper(const String& name, const Component::Factory& factory)
|
||||
{
|
||||
Component::Register(name, factory);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Factory function for IComponent-based classes.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
template<typename T>
|
||||
IComponent::Ptr ComponentFactory(void)
|
||||
{
|
||||
return boost::make_shared<T>();
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_COMPONENT(name, klass) \
|
||||
static RegisterComponentHelper g_RegisterSF_ ## type(name, ComponentFactory<klass>)
|
||||
|
||||
}
|
||||
|
||||
#endif /* COMPONENT_H */
|
|
@ -95,7 +95,7 @@ shared_ptr<T> DynamicObjectFactory(const Dictionary::Ptr& serializedUpdate)
|
|||
}
|
||||
|
||||
#define REGISTER_TYPE_ALIAS(type, alias) \
|
||||
static RegisterTypeHelper g_RegisterDT_ ## type(alias, DynamicObjectFactory<type>)
|
||||
static icinga::RegisterTypeHelper g_RegisterDT_ ## type(alias, DynamicObjectFactory<type>)
|
||||
|
||||
#define REGISTER_TYPE(type) \
|
||||
REGISTER_TYPE_ALIAS(type, #type)
|
||||
|
|
|
@ -233,7 +233,6 @@ namespace signals2 = boost::signals2;
|
|||
#include "scriptlanguage.h"
|
||||
#include "logger.h"
|
||||
#include "application.h"
|
||||
#include "component.h"
|
||||
#include "streamlogger.h"
|
||||
#include "sysloglogger.h"
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
};
|
||||
|
||||
#define REGISTER_SCRIPTFUNCTION(name, callback) \
|
||||
static RegisterFunctionHelper g_RegisterSF_ ## type(name, callback)
|
||||
static icinga::RegisterFunctionHelper g_RegisterSF_ ## type(name, callback)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -346,25 +346,22 @@ void Utility::Sleep(double timeout)
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads the specified library and invokes an Icinga-specific init
|
||||
* function if available.
|
||||
* Loads the specified library.
|
||||
*
|
||||
* @param library The name of the library.
|
||||
* @param module Whether the library is a module (non-module libraries have a
|
||||
* "lib" prefix on *NIX).
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
HMODULE
|
||||
#else /* _WIN32 */
|
||||
lt_dlhandle
|
||||
#endif /* _WIN32 */
|
||||
Utility::LoadIcingaLibrary(const String& library, bool module)
|
||||
Utility::LoadExtensionLibrary(const String& library)
|
||||
{
|
||||
String path;
|
||||
#ifdef _WIN32
|
||||
path = library + ".dll";
|
||||
#else /* _WIN32 */
|
||||
path = (module ? "" : "lib") + library + ".la";
|
||||
path = "lib" + library + ".la";
|
||||
#endif /* _WIN32 */
|
||||
|
||||
Logger::Write(LogInformation, "base", "Loading library '" + path + "'");
|
||||
|
@ -547,4 +544,3 @@ String Utility::FormatDateTime(const char *format, double ts)
|
|||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
#else /* _WIN32 */
|
||||
lt_dlhandle
|
||||
#endif /* _WIN32 */
|
||||
LoadIcingaLibrary(const String& library, bool module);
|
||||
LoadExtensionLibrary(const String& library);
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SetNonBlocking(int fd);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
base-type.cpp
|
|
@ -8,7 +8,14 @@ BUILT_SOURCES = config_parser.h
|
|||
|
||||
AM_YFLAGS = -d
|
||||
|
||||
EXTRA_DIST = \
|
||||
base-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libconfig_la_SOURCES = \
|
||||
base-type.cpp \
|
||||
configcompiler.cpp \
|
||||
configcompiler.h \
|
||||
configcompilercontext.cpp \
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type DynamicObject {
|
||||
%require "__local",
|
||||
%attribute number "__local",
|
||||
|
||||
%require "__name",
|
||||
%attribute string "__name",
|
||||
|
||||
%require "__type",
|
||||
%attribute string "__type",
|
||||
|
||||
%attribute dictionary "methods" {
|
||||
},
|
||||
|
||||
%attribute any "custom::*"
|
||||
}
|
||||
|
||||
type Logger {
|
||||
%attribute string "type",
|
||||
%attribute string "path",
|
||||
%attribute string "severity"
|
||||
}
|
||||
|
||||
type Script {
|
||||
%require "language",
|
||||
%attribute string "language",
|
||||
|
||||
%require "code",
|
||||
%attribute string "code"
|
||||
}
|
|
@ -108,7 +108,7 @@ void ConfigCompiler::HandleInclude(const String& include, bool search, const Deb
|
|||
*/
|
||||
void ConfigCompiler::HandleLibrary(const String& library)
|
||||
{
|
||||
Utility::LoadIcingaLibrary(library, false);
|
||||
(void) Utility::LoadExtensionLibrary(library);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,3 +211,13 @@ void ConfigCompiler::AddIncludeSearchDir(const String& dir)
|
|||
m_IncludeSearchDirs.push_back(dir);
|
||||
}
|
||||
|
||||
void ConfigCompiler::RegisterConfigFragment(const String& name, const String& fragment)
|
||||
{
|
||||
GetConfigFragments()[name] = fragment;
|
||||
}
|
||||
|
||||
map<String, String>& ConfigCompiler::GetConfigFragments(void)
|
||||
{
|
||||
static map<String, String> fragments;
|
||||
return fragments;
|
||||
}
|
||||
|
|
|
@ -50,14 +50,17 @@ public:
|
|||
|
||||
static void HandleFileInclude(const String& include, bool search,
|
||||
const DebugInfo& debuginfo);
|
||||
|
||||
|
||||
/* internally used methods */
|
||||
void HandleInclude(const String& include, bool search, const DebugInfo& debuginfo);
|
||||
void HandleLibrary(const String& library);
|
||||
|
||||
|
||||
size_t ReadInput(char *buffer, size_t max_bytes);
|
||||
void *GetScanner(void) const;
|
||||
|
||||
static void RegisterConfigFragment(const String& name, const String& fragment);
|
||||
static map<String, String>& GetConfigFragments(void);
|
||||
|
||||
private:
|
||||
String m_Path;
|
||||
istream *m_Input;
|
||||
|
@ -72,6 +75,23 @@ private:
|
|||
void DestroyScanner(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class for registering config fragments.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class RegisterConfigFragmentHelper
|
||||
{
|
||||
public:
|
||||
RegisterConfigFragmentHelper(const String& name, const String& fragment)
|
||||
{
|
||||
ConfigCompiler::RegisterConfigFragment(name, fragment);
|
||||
}
|
||||
};
|
||||
|
||||
#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
|
||||
static icinga::RegisterConfigFragmentHelper g_RegisterCF_ ## type(name, fragment)
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIGCOMPILER_H */
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
icinga-type.cpp
|
|
@ -4,6 +4,12 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libicinga.la
|
||||
|
||||
EXTRA_DIST = \
|
||||
icinga-type.conf
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libicinga_la_SOURCES = \
|
||||
api.cpp \
|
||||
api.h \
|
||||
|
@ -19,6 +25,7 @@ libicinga_la_SOURCES = \
|
|||
host.h \
|
||||
i2-icinga.cpp \
|
||||
i2-icinga.h \
|
||||
icinga-type.cpp \
|
||||
icingaapplication.cpp \
|
||||
icingaapplication.h \
|
||||
macroprocessor.cpp \
|
||||
|
|
|
@ -17,31 +17,6 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
type DynamicObject {
|
||||
%require "__local",
|
||||
%attribute number "__local",
|
||||
|
||||
%require "__name",
|
||||
%attribute string "__name",
|
||||
|
||||
%require "__type",
|
||||
%attribute string "__type",
|
||||
|
||||
%attribute dictionary "methods" {
|
||||
},
|
||||
|
||||
%attribute any "custom::*"
|
||||
}
|
||||
|
||||
type Component {
|
||||
}
|
||||
|
||||
type Logger {
|
||||
%attribute string "type",
|
||||
%attribute string "path",
|
||||
%attribute string "severity"
|
||||
}
|
||||
|
||||
type Host {
|
||||
%attribute string "alias",
|
||||
%attribute string "hostcheck",
|
||||
|
@ -227,15 +202,6 @@ type ServiceGroup {
|
|||
%attribute string "action_url"
|
||||
}
|
||||
|
||||
type Endpoint {
|
||||
%attribute string "node",
|
||||
%attribute string "service",
|
||||
%attribute number "local"
|
||||
}
|
||||
|
||||
type TimePeriod {
|
||||
}
|
||||
|
||||
type Notification {
|
||||
%require "methods",
|
||||
%attribute dictionary "methods" {
|
||||
|
@ -258,21 +224,13 @@ type Notification {
|
|||
%attribute dictionary "groups" {
|
||||
%attribute string "*"
|
||||
},
|
||||
|
||||
|
||||
%attribute dictionary "notification_command" {
|
||||
%attribute string "_*"
|
||||
},
|
||||
%attribute string "notification_command"
|
||||
}
|
||||
|
||||
type Script {
|
||||
%require "language",
|
||||
%attribute string "language",
|
||||
|
||||
%require "code",
|
||||
%attribute string "code"
|
||||
}
|
||||
|
||||
type User {
|
||||
%attribute string "display_name",
|
||||
|
|
@ -0,0 +1 @@
|
|||
remoting-type.cpp
|
|
@ -4,6 +4,9 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libremoting.la
|
||||
|
||||
.conf.cpp:
|
||||
$(top_builddir)/tools/mkembedconfig $< $@
|
||||
|
||||
libremoting_la_SOURCES = \
|
||||
endpoint.cpp \
|
||||
endpoint.h \
|
||||
|
@ -15,6 +18,7 @@ libremoting_la_SOURCES = \
|
|||
jsonrpcconnection.h \
|
||||
messagepart.cpp \
|
||||
messagepart.h \
|
||||
remoting-type.cpp \
|
||||
requestmessage.cpp \
|
||||
requestmessage.h \
|
||||
responsemessage.cpp \
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************/
|
||||
|
||||
type Endpoint {
|
||||
%attribute string "node",
|
||||
%attribute string "service",
|
||||
%attribute number "local"
|
||||
}
|
Loading…
Reference in New Issue