mirror of https://github.com/Icinga/icinga2.git
parent
d14775f28f
commit
db4b3b78d6
|
@ -11,6 +11,7 @@ ipch
|
|||
*.gcda
|
||||
*.o
|
||||
*.a
|
||||
*.th
|
||||
.deps
|
||||
*.in
|
||||
Makefile
|
||||
|
|
|
@ -3,15 +3,22 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libchecker.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
checkercomponent.th
|
||||
|
||||
CLEANFILES = \
|
||||
checker-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libchecker_la_SOURCES = \
|
||||
checkercomponent.cpp \
|
||||
checkercomponent.h \
|
||||
checkercomponent.th \
|
||||
checker-type.conf
|
||||
|
||||
libchecker_la_CPPFLAGS = \
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class CheckerComponent : DynamicObject
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -3,18 +3,27 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libcluster.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
clusterlistener.th \
|
||||
endpoint.th
|
||||
|
||||
CLEANFILES = \
|
||||
cluster-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libcluster_la_SOURCES = \
|
||||
clusterlistener.cpp \
|
||||
clusterlistener.h \
|
||||
clusterlistener.ti \
|
||||
cluster-type.conf \
|
||||
endpoint.cpp \
|
||||
endpoint.h \
|
||||
endpoint.ti \
|
||||
jsonrpc.cpp \
|
||||
jsonrpc.h
|
||||
|
||||
|
|
|
@ -51,16 +51,16 @@ void ClusterListener::Start(void)
|
|||
}
|
||||
|
||||
/* set up SSL context */
|
||||
shared_ptr<X509> cert = GetX509Certificate(GetCertificateFile());
|
||||
m_Identity = GetCertificateCN(cert);
|
||||
Log(LogInformation, "cluster", "My identity: " + m_Identity);
|
||||
shared_ptr<X509> cert = GetX509Certificate(GetCertPath());
|
||||
SetIdentity(GetCertificateCN(cert));
|
||||
Log(LogInformation, "cluster", "My identity: " + GetIdentity());
|
||||
|
||||
Endpoint::Ptr self = Endpoint::GetByName(GetIdentity());
|
||||
|
||||
if (!self)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("No configuration available for the local endpoint."));
|
||||
|
||||
m_SSLContext = MakeSSLContext(GetCertificateFile(), GetKeyFile(), GetCAFile());
|
||||
m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||
|
||||
/* create the primary JSON-RPC listener */
|
||||
if (!GetBindPort().IsEmpty())
|
||||
|
@ -127,62 +127,11 @@ void ClusterListener::Stop(void)
|
|||
RotateLogFile();
|
||||
}
|
||||
|
||||
String ClusterListener::GetCertificateFile(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_CertPath;
|
||||
}
|
||||
|
||||
String ClusterListener::GetKeyFile(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_KeyPath;
|
||||
}
|
||||
|
||||
String ClusterListener::GetCAFile(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_CAPath;
|
||||
}
|
||||
|
||||
String ClusterListener::GetBindHost(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_BindHost;
|
||||
}
|
||||
|
||||
String ClusterListener::GetBindPort(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_BindPort;
|
||||
}
|
||||
|
||||
Array::Ptr ClusterListener::GetPeers(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_Peers;
|
||||
}
|
||||
|
||||
shared_ptr<SSL_CTX> ClusterListener::GetSSLContext(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_SSLContext;
|
||||
}
|
||||
|
||||
String ClusterListener::GetIdentity(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_Identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new JSON-RPC listener on the specified port.
|
||||
*
|
||||
|
@ -270,7 +219,7 @@ void ClusterListener::PersistMessage(const Endpoint::Ptr& source, const Dictiona
|
|||
String json = Value(pmessage).Serialize();
|
||||
NetString::WriteStringToStream(m_LogFile, json);
|
||||
m_LogMessageCount++;
|
||||
m_LogMessageTimestamp = ts;
|
||||
SetLogMessageTimestamp(ts);
|
||||
|
||||
if (m_LogMessageCount > 50000) {
|
||||
CloseLogFile();
|
||||
|
@ -330,7 +279,7 @@ void ClusterListener::RelayMessage(const Endpoint::Ptr& source, const Dictionary
|
|||
{
|
||||
ObjectLock olock(endpoint);
|
||||
|
||||
if (!endpoint->IsSyncing())
|
||||
if (!endpoint->GetSyncing())
|
||||
endpoint->SendMessage(message);
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +310,7 @@ void ClusterListener::OpenLogFile(void)
|
|||
m_LogFile = logStream;
|
||||
#endif /* HAVE_BIOZLIB */
|
||||
m_LogMessageCount = 0;
|
||||
m_LogMessageTimestamp = 0;
|
||||
SetLogMessageTimestamp(0);
|
||||
}
|
||||
|
||||
void ClusterListener::CloseLogFile(void)
|
||||
|
@ -380,7 +329,7 @@ void ClusterListener::RotateLogFile(void)
|
|||
{
|
||||
ASSERT(OwnsLock());
|
||||
|
||||
double ts = m_LogMessageTimestamp;
|
||||
double ts = GetLogMessageTimestamp();
|
||||
|
||||
if (ts == 0)
|
||||
ts = Utility::GetTime();
|
||||
|
@ -1579,37 +1528,3 @@ bool ClusterListener::SupportsNotifications(void)
|
|||
|
||||
return !type->GetObjects().empty() && IcingaApplication::GetInstance()->GetEnableNotifications();
|
||||
}
|
||||
|
||||
void ClusterListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("cert_path", m_CertPath);
|
||||
bag->Set("key_path", m_KeyPath);
|
||||
bag->Set("ca_path", m_CAPath);
|
||||
bag->Set("bind_host", m_BindHost);
|
||||
bag->Set("bind_port", m_BindPort);
|
||||
bag->Set("peers", m_Peers);
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State)
|
||||
bag->Set("log_message_timestamp", m_LogMessageTimestamp);
|
||||
}
|
||||
|
||||
void ClusterListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_CertPath = bag->Get("cert_path");
|
||||
m_KeyPath = bag->Get("key_path");
|
||||
m_CAPath = bag->Get("ca_path");
|
||||
m_BindHost = bag->Get("bind_host");
|
||||
m_BindPort = bag->Get("bind_port");
|
||||
m_Peers = bag->Get("peers");
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State)
|
||||
m_LogMessageTimestamp = bag->Get("log_message_timestamp");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef CLUSTERLISTENER_H
|
||||
#define CLUSTERLISTENER_H
|
||||
|
||||
#include "cluster/clusterlistener.th"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/array.h"
|
||||
|
@ -38,7 +39,7 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup cluster
|
||||
*/
|
||||
class ClusterListener : public DynamicObject
|
||||
class ClusterListener : public ReflectionObjectImpl<ClusterListener>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(ClusterListener);
|
||||
|
@ -47,31 +48,11 @@ public:
|
|||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
String GetCertificateFile(void) const;
|
||||
String GetKeyFile(void) const;
|
||||
String GetCAFile(void) const;
|
||||
String GetBindHost(void) const;
|
||||
String GetBindPort(void) const;
|
||||
Array::Ptr GetPeers(void) const;
|
||||
shared_ptr<SSL_CTX> GetSSLContext(void) const;
|
||||
String GetClusterDir(void) const;
|
||||
|
||||
shared_ptr<SSL_CTX> GetSSLContext(void) const;
|
||||
String GetIdentity(void) const;
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_CertPath;
|
||||
String m_KeyPath;
|
||||
String m_CAPath;
|
||||
String m_BindHost;
|
||||
String m_BindPort;
|
||||
Array::Ptr m_Peers;
|
||||
|
||||
shared_ptr<SSL_CTX> m_SSLContext;
|
||||
String m_Identity;
|
||||
|
||||
WorkQueue m_RelayQueue;
|
||||
WorkQueue m_MessageQueue;
|
||||
|
@ -100,7 +81,6 @@ private:
|
|||
void ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Ptr& stream);
|
||||
|
||||
Stream::Ptr m_LogFile;
|
||||
double m_LogMessageTimestamp;
|
||||
size_t m_LogMessageCount;
|
||||
|
||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class ClusterListener : DynamicObject
|
||||
{
|
||||
[config] String cert_path;
|
||||
[config] String key_path;
|
||||
[config] String ca_path;
|
||||
[config] String bind_host;
|
||||
[config] String bind_port;
|
||||
[config] Array::Ptr peers;
|
||||
[state] double log_message_timestamp;
|
||||
String identity;
|
||||
};
|
||||
|
||||
}
|
|
@ -34,10 +34,6 @@ REGISTER_TYPE(Endpoint);
|
|||
boost::signals2::signal<void (const Endpoint::Ptr&)> Endpoint::OnConnected;
|
||||
boost::signals2::signal<void (const Endpoint::Ptr&, const Dictionary::Ptr&)> Endpoint::OnMessageReceived;
|
||||
|
||||
Endpoint::Endpoint(void)
|
||||
: m_Syncing(false)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Checks whether this endpoint is connected.
|
||||
*
|
||||
|
@ -107,86 +103,6 @@ void Endpoint::MessageThreadProc(const Stream::Ptr& stream)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node address for this endpoint.
|
||||
*
|
||||
* @returns The node address (hostname).
|
||||
*/
|
||||
String Endpoint::GetHost(void) const
|
||||
{
|
||||
return m_Host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service name for this endpoint.
|
||||
*
|
||||
* @returns The service name (port).
|
||||
*/
|
||||
String Endpoint::GetPort(void) const
|
||||
{
|
||||
return m_Port;
|
||||
}
|
||||
|
||||
Array::Ptr Endpoint::GetConfigFiles(void) const
|
||||
{
|
||||
return m_ConfigFiles;
|
||||
}
|
||||
|
||||
Array::Ptr Endpoint::GetAcceptConfig(void) const
|
||||
{
|
||||
return m_AcceptConfig;
|
||||
}
|
||||
|
||||
double Endpoint::GetSeen(void) const
|
||||
{
|
||||
return m_Seen;
|
||||
}
|
||||
|
||||
void Endpoint::SetSeen(double ts)
|
||||
{
|
||||
m_Seen = ts;
|
||||
}
|
||||
|
||||
double Endpoint::GetLocalLogPosition(void) const
|
||||
{
|
||||
return m_LocalLogPosition;
|
||||
}
|
||||
|
||||
void Endpoint::SetLocalLogPosition(double ts)
|
||||
{
|
||||
m_LocalLogPosition = ts;
|
||||
}
|
||||
|
||||
double Endpoint::GetRemoteLogPosition(void) const
|
||||
{
|
||||
return m_RemoteLogPosition;
|
||||
}
|
||||
|
||||
void Endpoint::SetRemoteLogPosition(double ts)
|
||||
{
|
||||
m_RemoteLogPosition = ts;
|
||||
}
|
||||
|
||||
bool Endpoint::IsSyncing(void) const
|
||||
{
|
||||
return m_Syncing;
|
||||
}
|
||||
|
||||
void Endpoint::SetSyncing(bool syncing)
|
||||
{
|
||||
m_Syncing = syncing;
|
||||
}
|
||||
|
||||
Dictionary::Ptr Endpoint::GetFeatures(void) const
|
||||
{
|
||||
return m_Features;
|
||||
}
|
||||
|
||||
void Endpoint::SetFeatures(const Dictionary::Ptr& features)
|
||||
{
|
||||
m_Features = features;
|
||||
}
|
||||
|
||||
bool Endpoint::HasFeature(const String& type) const
|
||||
{
|
||||
Dictionary::Ptr features = GetFeatures();
|
||||
|
@ -197,40 +113,3 @@ bool Endpoint::HasFeature(const String& type) const
|
|||
return features->Get(type);
|
||||
}
|
||||
|
||||
void Endpoint::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("host", m_Host);
|
||||
bag->Set("port", m_Port);
|
||||
bag->Set("config_files", m_ConfigFiles);
|
||||
bag->Set("accept_config", m_AcceptConfig);
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State) {
|
||||
bag->Set("seen", m_Seen);
|
||||
bag->Set("local_log_position", m_LocalLogPosition);
|
||||
bag->Set("remote_log_position", m_RemoteLogPosition);
|
||||
bag->Set("features", m_Features);
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Host = bag->Get("host");
|
||||
m_Port = bag->Get("port");
|
||||
m_ConfigFiles = bag->Get("config_files");
|
||||
m_AcceptConfig = bag->Get("accept_config");
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State) {
|
||||
m_Seen = bag->Get("seen");
|
||||
m_LocalLogPosition = bag->Get("local_log_position");
|
||||
m_RemoteLogPosition = bag->Get("remote_log_position");
|
||||
m_Features = bag->Get("features");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef ENDPOINT_H
|
||||
#define ENDPOINT_H
|
||||
|
||||
#include "base/dynamicobject.h"
|
||||
#include "cluster/endpoint.th"
|
||||
#include "base/stream.h"
|
||||
#include "base/array.h"
|
||||
#include <boost/signals2.hpp>
|
||||
|
@ -35,14 +35,12 @@ class EndpointManager;
|
|||
*
|
||||
* @ingroup cluster
|
||||
*/
|
||||
class Endpoint : public DynamicObject
|
||||
class Endpoint : public ReflectionObjectImpl<Endpoint>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Endpoint);
|
||||
DECLARE_TYPENAME(Endpoint);
|
||||
|
||||
Endpoint(void);
|
||||
|
||||
static boost::signals2::signal<void (const Endpoint::Ptr&)> OnConnected;
|
||||
static boost::signals2::signal<void (const Endpoint::Ptr&, const Dictionary::Ptr&)> OnMessageReceived;
|
||||
|
||||
|
@ -53,46 +51,10 @@ public:
|
|||
|
||||
void SendMessage(const Dictionary::Ptr& request);
|
||||
|
||||
String GetHost(void) const;
|
||||
String GetPort(void) const;
|
||||
Array::Ptr GetConfigFiles(void) const;
|
||||
Array::Ptr GetAcceptConfig(void) const;
|
||||
|
||||
double GetSeen(void) const;
|
||||
void SetSeen(double ts);
|
||||
|
||||
double GetLocalLogPosition(void) const;
|
||||
void SetLocalLogPosition(double ts);
|
||||
|
||||
double GetRemoteLogPosition(void) const;
|
||||
void SetRemoteLogPosition(double ts);
|
||||
|
||||
Dictionary::Ptr GetFeatures(void) const;
|
||||
void SetFeatures(const Dictionary::Ptr& features);
|
||||
|
||||
bool HasFeature(const String& type) const;
|
||||
|
||||
bool IsSyncing(void) const;
|
||||
void SetSyncing(bool syncing);
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
Dictionary::Ptr m_Subscriptions;
|
||||
String m_Host;
|
||||
String m_Port;
|
||||
Array::Ptr m_ConfigFiles;
|
||||
Array::Ptr m_AcceptConfig;
|
||||
|
||||
Stream::Ptr m_Client;
|
||||
double m_Seen;
|
||||
double m_LocalLogPosition;
|
||||
double m_RemoteLogPosition;
|
||||
Dictionary::Ptr m_Features;
|
||||
bool m_Syncing;
|
||||
|
||||
boost::thread m_Thread;
|
||||
|
||||
void MessageThreadProc(const Stream::Ptr& stream);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Endpoint : DynamicObject
|
||||
{
|
||||
[config] String host;
|
||||
[config] String port;
|
||||
[config] Array::Ptr config_files;
|
||||
[config] Array::Ptr accept_config;
|
||||
|
||||
[state] double seen;
|
||||
[state] double local_log_position;
|
||||
[state] double remote_log_position;
|
||||
[state] Dictionary::Ptr features;
|
||||
|
||||
bool syncing {
|
||||
default {{{ return false; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -3,21 +3,34 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libcompat.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
checkresultreader.th \
|
||||
externalcommandlistener.th \
|
||||
statusdatawriter.th \
|
||||
compatlogger.th
|
||||
|
||||
CLEANFILES = \
|
||||
compat-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libcompat_la_SOURCES = \
|
||||
checkresultreader.cpp \
|
||||
checkresultreader.h \
|
||||
checkresultreader.th \
|
||||
externalcommandlistener.cpp \
|
||||
externalcommandlistener.h \
|
||||
externalcommandlistener.th \
|
||||
statusdatawriter.cpp \
|
||||
statusdatawriter.h \
|
||||
statusdatawriter.th \
|
||||
compatlogger.cpp \
|
||||
compatlogger.h \
|
||||
compatlogger.th \
|
||||
compat-type.conf
|
||||
|
||||
libcompat_la_CPPFLAGS = \
|
||||
|
|
|
@ -44,17 +44,6 @@ void CheckResultReader::Start(void)
|
|||
m_ReadTimer->Start();
|
||||
}
|
||||
|
||||
/**
|
||||
* @threadsafety Always.
|
||||
*/
|
||||
String CheckResultReader::GetSpoolDir(void) const
|
||||
{
|
||||
if (!m_SpoolDir.IsEmpty())
|
||||
return m_SpoolDir;
|
||||
else
|
||||
return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/";
|
||||
}
|
||||
|
||||
/**
|
||||
* @threadsafety Always.
|
||||
*/
|
||||
|
@ -134,18 +123,3 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
|||
}
|
||||
}
|
||||
|
||||
void CheckResultReader::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
bag->Set("spool_dir", m_SpoolDir);
|
||||
}
|
||||
|
||||
void CheckResultReader::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
m_SpoolDir = bag->Get("spool_dir");
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef CHECKRESULTREADER_H
|
||||
#define CHECKRESULTREADER_H
|
||||
|
||||
#include "base/dynamicobject.h"
|
||||
#include "compat/checkresultreader.th"
|
||||
#include "base/timer.h"
|
||||
#include <fstream>
|
||||
|
||||
|
@ -32,23 +32,16 @@ namespace icinga
|
|||
*
|
||||
* @ingroup compat
|
||||
*/
|
||||
class CheckResultReader : public DynamicObject
|
||||
class CheckResultReader : public ReflectionObjectImpl<CheckResultReader>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(CheckResultReader);
|
||||
DECLARE_TYPENAME(CheckResultReader);
|
||||
|
||||
String GetSpoolDir(void) const;
|
||||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_SpoolDir;
|
||||
|
||||
Timer::Ptr m_ReadTimer;
|
||||
void ReadTimerHandler(void) const;
|
||||
void ProcessCheckResultFile(const String& path) const;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class CheckResultReader : DynamicObject
|
||||
{
|
||||
[config] String spool_dir {
|
||||
default {{{ return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -67,28 +67,6 @@ void CompatLogger::Start(void)
|
|||
ScheduleNextRotation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @threadsafety Always.
|
||||
*/
|
||||
String CompatLogger::GetLogDir(void) const
|
||||
{
|
||||
if (!m_LogDir.IsEmpty())
|
||||
return m_LogDir;
|
||||
else
|
||||
return Application::GetLocalStateDir() + "/log/icinga2/compat";
|
||||
}
|
||||
|
||||
/**
|
||||
* @threadsafety Always.
|
||||
*/
|
||||
String CompatLogger::GetRotationMethod(void) const
|
||||
{
|
||||
if (!m_RotationMethod.IsEmpty())
|
||||
return m_RotationMethod;
|
||||
else
|
||||
return "HOURLY";
|
||||
}
|
||||
|
||||
/**
|
||||
* @threadsafety Always.
|
||||
*/
|
||||
|
@ -412,10 +390,8 @@ void CompatLogger::FlappingHandler(const Service::Ptr& service, FlappingState fl
|
|||
ObjectLock oLock(this);
|
||||
Flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
|
||||
{
|
||||
std::ostringstream msgbuf;
|
||||
|
@ -496,7 +472,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
<< host->GetName() << ";"
|
||||
<< Host::StateToString(Host::CalculateState(hc->GetState(), reachable)) << ";"
|
||||
<< Service::StateTypeToString(hc->GetStateType()) << ";"
|
||||
<< hc->GetCurrentCheckAttempt() << ";"
|
||||
<< hc->GetCheckAttempt() << ";"
|
||||
<< "";
|
||||
|
||||
WriteLine(msgbuf.str());
|
||||
|
@ -514,7 +490,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
<< service->GetShortName() << ";"
|
||||
<< Service::StateToString(service->GetState()) << ";"
|
||||
<< Service::StateTypeToString(service->GetStateType()) << ";"
|
||||
<< service->GetCurrentCheckAttempt() << ";"
|
||||
<< service->GetCheckAttempt() << ";"
|
||||
<< "";
|
||||
|
||||
WriteLine(msgbuf.str());
|
||||
|
@ -599,22 +575,3 @@ void CompatLogger::ValidateRotationMethod(const String& location, const Dictiona
|
|||
}
|
||||
}
|
||||
|
||||
void CompatLogger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("log_dir", m_LogDir);
|
||||
bag->Set("rotation_method", m_RotationMethod);
|
||||
}
|
||||
}
|
||||
|
||||
void CompatLogger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_LogDir = bag->Get("log_dir");
|
||||
m_RotationMethod = bag->Get("rotation_method");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#ifndef COMPATLOGGER_H
|
||||
#define COMPATLOGGER_H
|
||||
|
||||
#include "compat/compatlogger.th"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/timer.h"
|
||||
#include <fstream>
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup compat
|
||||
*/
|
||||
class CompatLogger : public DynamicObject
|
||||
class CompatLogger : public ReflectionObjectImpl<CompatLogger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(CompatLogger);
|
||||
|
@ -41,21 +41,12 @@ public:
|
|||
|
||||
CompatLogger(void);
|
||||
|
||||
String GetLogDir(void) const;
|
||||
String GetRotationMethod(void) const;
|
||||
|
||||
static void ValidateRotationMethod(const String& location, const Dictionary::Ptr& attrs);
|
||||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_LogDir;
|
||||
String m_RotationMethod;
|
||||
|
||||
double m_LastRotation;
|
||||
|
||||
void WriteLine(const String& line);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class CompatLogger : DynamicObject
|
||||
{
|
||||
[config] String log_dir {
|
||||
default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
|
||||
};
|
||||
[config] String rotation_method {
|
||||
default {{{ return "HOURLY"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -42,20 +42,6 @@ void ExternalCommandListener::Start(void)
|
|||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the icinga.cmd path.
|
||||
*
|
||||
* @returns icinga.cmd path
|
||||
*/
|
||||
String ExternalCommandListener::GetCommandPath(void) const
|
||||
{
|
||||
if (m_CommandPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd";
|
||||
else
|
||||
return m_CommandPath;
|
||||
}
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
||||
{
|
||||
|
@ -143,19 +129,3 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||
}
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
void ExternalCommandListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
bag->Set("command_path", m_CommandPath);
|
||||
}
|
||||
|
||||
void ExternalCommandListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
m_CommandPath = bag->Get("command_path");
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef EXTERNALCOMMANDLISTENER_H
|
||||
#define EXTERNALCOMMANDLISTENER_H
|
||||
|
||||
#include "base/dynamicobject.h"
|
||||
#include "compat/externalcommandlistener.th"
|
||||
#include "base/objectlock.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/utility.h"
|
||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup compat
|
||||
*/
|
||||
class ExternalCommandListener : public DynamicObject
|
||||
class ExternalCommandListener : public ReflectionObjectImpl<ExternalCommandListener>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
|
||||
|
@ -41,19 +41,12 @@ public:
|
|||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_CommandPath;
|
||||
|
||||
#ifndef _WIN32
|
||||
boost::thread m_CommandThread;
|
||||
|
||||
void CommandPipeThread(const String& commandPath);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
String GetCommandPath(void) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class ExternalCommandListener : DynamicObject
|
||||
{
|
||||
[config] String command_path {
|
||||
default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -64,40 +64,11 @@ void StatusDataWriter::Start(void)
|
|||
m_StatusTimer->Reschedule(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the status.dat path.
|
||||
*
|
||||
* @returns statuspath from config, or static default
|
||||
*/
|
||||
String StatusDataWriter::GetStatusPath(void) const
|
||||
{
|
||||
if (m_StatusPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/status.dat";
|
||||
else
|
||||
return m_StatusPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the objects.cache path.
|
||||
*
|
||||
* @returns objectspath from config, or static default
|
||||
*/
|
||||
String StatusDataWriter::GetObjectsPath(void) const
|
||||
{
|
||||
if (m_ObjectsPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache";
|
||||
else
|
||||
return m_ObjectsPath;
|
||||
}
|
||||
|
||||
void StatusDataWriter::DumpComments(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type)
|
||||
{
|
||||
Service::Ptr service;
|
||||
Dictionary::Ptr comments = owner->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return;
|
||||
|
||||
Host::Ptr host = owner->GetHost();
|
||||
|
||||
if (!host)
|
||||
|
@ -202,9 +173,6 @@ void StatusDataWriter::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner
|
|||
|
||||
Dictionary::Ptr downtimes = owner->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
||||
String id;
|
||||
|
@ -474,7 +442,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
|||
<< "\t" << "active_checks_enabled" << "\t" << (service->GetEnableActiveChecks() ? 1 : 0) << "\n"
|
||||
<< "\t" << "passive_checks_enabled" << "\t" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
||||
<< "\t" << "flap_detection_enabled" << "\t" << (service->GetEnableFlapping() ? 1 : 0) << "\n"
|
||||
<< "\t" << "is_volatile" << "\t" << (service->IsVolatile() ? 1 : 0) << "\n"
|
||||
<< "\t" << "is_volatile" << "\t" << (service->GetVolatile() ? 1 : 0) << "\n"
|
||||
<< "\t" << "notifications_enabled" << "\t" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||
<< "\t" << "notification_options" << "\t" << "u,w,c,r" << "\n"
|
||||
<< "\t" << "notification_interval" << "\t" << notification_interval / 60.0 << "\n"
|
||||
|
@ -610,7 +578,7 @@ void StatusDataWriter::StatusTimerHandler(void)
|
|||
statusfp << "programstatus {" << "\n"
|
||||
<< "\t" << "icinga_pid=" << Utility::GetPid() << "\n"
|
||||
<< "\t" << "daemon_mode=1" << "\n"
|
||||
<< "\t" << "program_start=" << static_cast<long>(IcingaApplication::GetInstance()->GetStartTime()) << "\n"
|
||||
<< "\t" << "program_start=" << static_cast<long>(Application::GetStartTime()) << "\n"
|
||||
<< "\t" << "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0) << "\n"
|
||||
<< "\t" << "passive_service_checks_enabled=1" << "\n"
|
||||
<< "\t" << "active_host_checks_enabled=1" << "\n"
|
||||
|
@ -782,22 +750,3 @@ void StatusDataWriter::StatusTimerHandler(void)
|
|||
}
|
||||
}
|
||||
|
||||
void StatusDataWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("status_path", m_StatusPath);
|
||||
bag->Set("objects_path", m_ObjectsPath);
|
||||
}
|
||||
}
|
||||
|
||||
void StatusDataWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_StatusPath = bag->Get("status_path");
|
||||
m_ObjectsPath = bag->Get("objects_path");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#ifndef STATUSDATAWRITER_H
|
||||
#define STATUSDATAWRITER_H
|
||||
|
||||
#include "compat/statusdatawriter.th"
|
||||
#include "icinga/host.h"
|
||||
#include "icinga/service.h"
|
||||
#include "icinga/command.h"
|
||||
#include "icinga/compatutility.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/objectlock.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/utility.h"
|
||||
|
@ -37,7 +37,7 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup compat
|
||||
*/
|
||||
class StatusDataWriter : public DynamicObject
|
||||
class StatusDataWriter : public ReflectionObjectImpl<StatusDataWriter>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(StatusDataWriter);
|
||||
|
@ -45,18 +45,9 @@ public:
|
|||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_StatusPath;
|
||||
String m_ObjectsPath;
|
||||
|
||||
Timer::Ptr m_StatusTimer;
|
||||
|
||||
String GetStatusPath(void) const;
|
||||
String GetObjectsPath(void) const;
|
||||
|
||||
void DumpCommand(std::ostream& fp, const Command::Ptr& command);
|
||||
void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp);
|
||||
void DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class StatusDataWriter : DynamicObject
|
||||
{
|
||||
[config] String status_path {
|
||||
default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/status.dat"; }}}
|
||||
};
|
||||
[config] String objects_path {
|
||||
default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -8,16 +8,23 @@ SUBDIRS = \
|
|||
pkglib_LTLIBRARIES = \
|
||||
libdb_ido_mysql.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
idomysqlconnection.th
|
||||
|
||||
CLEANFILES = \
|
||||
db_ido_mysql-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libdb_ido_mysql_la_SOURCES = \
|
||||
db_ido_mysql-type.conf \
|
||||
idomysqlconnection.cpp \
|
||||
idomysqlconnection.h
|
||||
idomysqlconnection.h \
|
||||
idomysqlconnection.ti
|
||||
|
||||
libdb_ido_mysql_la_CPPFLAGS = \
|
||||
$(LTDLINCL) \
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "base/convert.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/application.h"
|
||||
#include "base/dynamictype.h"
|
||||
#include "db_ido/dbtype.h"
|
||||
#include "db_ido/dbvalue.h"
|
||||
#include "db_ido_mysql/idomysqlconnection.h"
|
||||
|
@ -34,12 +35,13 @@ using namespace icinga;
|
|||
|
||||
REGISTER_TYPE(IdoMysqlConnection);
|
||||
|
||||
#define SCHEMA_VERSION "1.10.0"
|
||||
|
||||
void IdoMysqlConnection::Start(void)
|
||||
{
|
||||
DbConnection::Start();
|
||||
|
||||
m_Connected = false;
|
||||
m_RequiredSchemaVersion = "1.10.0";
|
||||
|
||||
m_TxTimer = boost::make_shared<Timer>();
|
||||
m_TxTimer->SetInterval(5);
|
||||
|
@ -99,13 +101,13 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
|
|||
const char *host, *user , *passwd, *db;
|
||||
long port;
|
||||
|
||||
ihost = m_Host;
|
||||
iuser = m_User;
|
||||
ipasswd = m_Password;
|
||||
idb = m_Database;
|
||||
ihost = GetHost();
|
||||
iuser = GetUser();
|
||||
ipasswd = GetPassword();
|
||||
idb = GetDatabase();
|
||||
|
||||
host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
|
||||
port = m_Port;
|
||||
port = GetPort();
|
||||
user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
|
||||
passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
|
||||
db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
|
||||
|
@ -127,20 +129,17 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
|
|||
Dictionary::Ptr version_row = version_rows->Get(0);
|
||||
String version = version_row->Get("version");
|
||||
|
||||
if (Utility::CompareVersion(m_RequiredSchemaVersion, version) < 0) {
|
||||
if (Utility::CompareVersion(SCHEMA_VERSION, version) < 0) {
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Schema version '" + version + "' does not match the required version '" +
|
||||
m_RequiredSchemaVersion + "'! Please check the upgrade documentation."));
|
||||
SCHEMA_VERSION + "'! Please check the upgrade documentation."));
|
||||
}
|
||||
|
||||
String instanceName = "default";
|
||||
|
||||
if (!m_InstanceName.IsEmpty())
|
||||
instanceName = m_InstanceName;
|
||||
String instanceName = GetInstanceName();
|
||||
|
||||
Array::Ptr rows = Query("SELECT instance_id FROM " + GetTablePrefix() + "instances WHERE instance_name = '" + Escape(instanceName) + "'");
|
||||
|
||||
if (rows->GetLength() == 0) {
|
||||
Query("INSERT INTO " + GetTablePrefix() + "instances (instance_name, instance_description) VALUES ('" + Escape(instanceName) + "', '" + m_InstanceDescription + "')");
|
||||
Query("INSERT INTO " + GetTablePrefix() + "instances (instance_name, instance_description) VALUES ('" + Escape(instanceName) + "', '" + Escape(GetInstanceDescription()) + "')");
|
||||
m_InstanceID = GetLastInsertID();
|
||||
} else {
|
||||
Dictionary::Ptr row = rows->Get(0);
|
||||
|
@ -539,32 +538,3 @@ void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String&
|
|||
"<FROM_UNIXTIME(" + Convert::ToString(static_cast<long>(time_value)) + ")");
|
||||
}
|
||||
|
||||
void IdoMysqlConnection::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DbConnection::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("host", m_Host);
|
||||
bag->Set("port", m_Port);
|
||||
bag->Set("user", m_User);
|
||||
bag->Set("password", m_Password);
|
||||
bag->Set("database", m_Database);
|
||||
bag->Set("instance_name", m_InstanceName);
|
||||
bag->Set("instance_description", m_InstanceDescription);
|
||||
}
|
||||
}
|
||||
|
||||
void IdoMysqlConnection::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DbConnection::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Host = bag->Get("host");
|
||||
m_Port = bag->Get("port");
|
||||
m_User = bag->Get("user");
|
||||
m_Password = bag->Get("password");
|
||||
m_Database = bag->Get("database");
|
||||
m_InstanceName = bag->Get("instance_name");
|
||||
m_InstanceDescription = bag->Get("instance_description");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
#ifndef IDOMYSQLCONNECTION_H
|
||||
#define IDOMYSQLCONNECTION_H
|
||||
|
||||
#include "db_ido_mysql/idomysqlconnection.th"
|
||||
#include "base/array.h"
|
||||
#include "base/dynamictype.h"
|
||||
#include "base/timer.h"
|
||||
#include "db_ido/dbconnection.h"
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
namespace icinga
|
||||
|
@ -34,7 +33,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup ido
|
||||
*/
|
||||
class IdoMysqlConnection : public DbConnection
|
||||
class IdoMysqlConnection : public ReflectionObjectImpl<IdoMysqlConnection>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
|
||||
|
@ -54,14 +53,6 @@ protected:
|
|||
virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
|
||||
|
||||
private:
|
||||
String m_Host;
|
||||
Value m_Port;
|
||||
String m_User;
|
||||
String m_Password;
|
||||
String m_Database;
|
||||
String m_InstanceName;
|
||||
String m_InstanceDescription;
|
||||
|
||||
DbReference m_InstanceID;
|
||||
DbReference m_LastNotificationID;
|
||||
|
||||
|
@ -69,8 +60,6 @@ private:
|
|||
bool m_Connected;
|
||||
MYSQL m_Connection;
|
||||
|
||||
String m_RequiredSchemaVersion;
|
||||
|
||||
Timer::Ptr m_ReconnectTimer;
|
||||
Timer::Ptr m_TxTimer;
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#include "db_ido/dbconnection.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class IdoMysqlConnection : DbConnection
|
||||
{
|
||||
[config] String host;
|
||||
[config] int port;
|
||||
[config] String user;
|
||||
[config] String password;
|
||||
[config] String database;
|
||||
[config] String instance_name {
|
||||
default {{{ return "default"; }}}
|
||||
};
|
||||
[config] String instance_description;
|
||||
};
|
||||
|
||||
}
|
|
@ -3,15 +3,22 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libdemo.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
demo.th
|
||||
|
||||
CLEANFILES = \
|
||||
demo-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libdemo_la_SOURCES = \
|
||||
demo.cpp \
|
||||
demo.h \
|
||||
demo.ti \
|
||||
demo-type.conf
|
||||
|
||||
libdemo_la_CPPFLAGS = \
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef DEMO_H
|
||||
#define DEMO_H
|
||||
|
||||
#include "base/dynamicobject.h"
|
||||
#include "demo/demo.th"
|
||||
#include "base/timer.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -29,7 +29,7 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup demo
|
||||
*/
|
||||
class Demo : public DynamicObject
|
||||
class Demo : public ReflectionObjectImpl<Demo>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Demo);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Demo : DynamicObject
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -3,12 +3,18 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
liblivestatus.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
listener.th
|
||||
|
||||
CLEANFILES = \
|
||||
livestatus-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
liblivestatus_la_SOURCES = \
|
||||
aggregator.cpp \
|
||||
aggregator.h \
|
||||
|
@ -46,6 +52,7 @@ liblivestatus_la_SOURCES = \
|
|||
invsumaggregator.h \
|
||||
listener.cpp \
|
||||
listener.h \
|
||||
listener.ti \
|
||||
livestatus-type.conf \
|
||||
logtable.cpp \
|
||||
logtable.h \
|
||||
|
|
|
@ -61,9 +61,6 @@ void CommentsTable::FetchRows(const AddRowFunction& addRowFn)
|
|||
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
|
||||
Dictionary::Ptr comments = service->GetComments();
|
||||
|
||||
if (!comments)
|
||||
continue;
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
||||
String id;
|
||||
|
|
|
@ -61,9 +61,6 @@ void DowntimesTable::FetchRows(const AddRowFunction& addRowFn)
|
|||
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
|
||||
Dictionary::Ptr downtimes = service->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
continue;
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
||||
String id;
|
||||
|
|
|
@ -604,7 +604,7 @@ Value HostsTable::CurrentAttemptAccessor(const Value& row)
|
|||
if (!hc)
|
||||
return Empty;
|
||||
|
||||
return hc->GetCurrentCheckAttempt();
|
||||
return hc->GetCheckAttempt();
|
||||
}
|
||||
|
||||
Value HostsTable::LastNotificationAccessor(const Value& row)
|
||||
|
@ -761,7 +761,7 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
notification_interval = notification->GetNotificationInterval();
|
||||
}
|
||||
|
||||
if (notification_interval == 0 && !hc->IsVolatile())
|
||||
if (notification_interval == 0 && !hc->GetVolatile())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -1054,9 +1054,6 @@ Value HostsTable::DowntimesAccessor(const Value& row)
|
|||
|
||||
Dictionary::Ptr downtimes = hc->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
@ -1087,9 +1084,6 @@ Value HostsTable::DowntimesWithInfoAccessor(const Value& row)
|
|||
|
||||
Dictionary::Ptr downtimes = hc->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
@ -1124,9 +1118,6 @@ Value HostsTable::CommentsAccessor(const Value& row)
|
|||
|
||||
Dictionary::Ptr comments = hc->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
@ -1157,9 +1148,6 @@ Value HostsTable::CommentsWithInfoAccessor(const Value& row)
|
|||
|
||||
Dictionary::Ptr comments = hc->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
@ -1194,9 +1182,6 @@ Value HostsTable::CommentsWithExtraInfoAccessor(const Value& row)
|
|||
|
||||
Dictionary::Ptr comments = hc->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
|
|
@ -83,40 +83,6 @@ void LivestatusListener::Start(void)
|
|||
}
|
||||
}
|
||||
|
||||
String LivestatusListener::GetSocketType(void) const
|
||||
{
|
||||
Value socketType = m_SocketType;
|
||||
if (socketType.IsEmpty())
|
||||
return "unix";
|
||||
else
|
||||
return socketType;
|
||||
}
|
||||
|
||||
String LivestatusListener::GetSocketPath(void) const
|
||||
{
|
||||
Value socketPath = m_SocketPath;
|
||||
if (socketPath.IsEmpty())
|
||||
return Application::GetLocalStateDir() + "/run/icinga2/cmd/livestatus";
|
||||
else
|
||||
return socketPath;
|
||||
}
|
||||
|
||||
String LivestatusListener::GetBindHost(void) const
|
||||
{
|
||||
if (m_BindHost.IsEmpty())
|
||||
return "127.0.0.1";
|
||||
else
|
||||
return m_BindHost;
|
||||
}
|
||||
|
||||
String LivestatusListener::GetBindPort(void) const
|
||||
{
|
||||
if (m_BindPort.IsEmpty())
|
||||
return "6558";
|
||||
else
|
||||
return m_BindPort;
|
||||
}
|
||||
|
||||
int LivestatusListener::GetClientsConnected(void)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_ComponentMutex);
|
||||
|
@ -189,26 +155,3 @@ void LivestatusListener::ValidateSocketType(const String& location, const Dictio
|
|||
}
|
||||
}
|
||||
|
||||
void LivestatusListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("socket_type", m_SocketType);
|
||||
bag->Set("socket_path", m_SocketPath);
|
||||
bag->Set("bind_host", m_BindHost);
|
||||
bag->Set("bind_port", m_BindPort);
|
||||
}
|
||||
}
|
||||
|
||||
void LivestatusListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_SocketType = bag->Get("socket_type");
|
||||
m_SocketPath = bag->Get("socket_path");
|
||||
m_BindHost = bag->Get("bind_host");
|
||||
m_BindPort = bag->Get("bind_port");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#ifndef LIVESTATUSLISTENER_H
|
||||
#define LIVESTATUSLISTENER_H
|
||||
|
||||
#include "livestatus/listener.th"
|
||||
#include "livestatus/query.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/socket.h"
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
|
@ -33,16 +33,11 @@ namespace livestatus
|
|||
/**
|
||||
* @ingroup livestatus
|
||||
*/
|
||||
class LivestatusListener : public DynamicObject
|
||||
class LivestatusListener : public ReflectionObjectImpl<LivestatusListener>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(LivestatusListener);
|
||||
|
||||
String GetSocketType(void) const;
|
||||
String GetSocketPath(void) const;
|
||||
String GetBindHost(void) const;
|
||||
String GetBindPort(void) const;
|
||||
|
||||
static int GetClientsConnected(void);
|
||||
static int GetConnections(void);
|
||||
|
||||
|
@ -51,15 +46,7 @@ public:
|
|||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_SocketType;
|
||||
String m_SocketPath;
|
||||
String m_BindHost;
|
||||
String m_BindPort;
|
||||
|
||||
void ServerThreadProc(const Socket::Ptr& server);
|
||||
void ClientThreadProc(const Socket::Ptr& client);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace livestatus
|
||||
{
|
||||
|
||||
code {{{
|
||||
class LivestatusListener;
|
||||
}}}
|
||||
|
||||
}
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class livestatus::LivestatusListener : DynamicObject {
|
||||
[config] String socket_type {
|
||||
default {{{ return "unix"; }}}
|
||||
};
|
||||
[config] String socket_path {
|
||||
default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/livestatus"; }}}
|
||||
};
|
||||
[config] String bind_host {
|
||||
default {{{ return "127.0.0.1"; }}}
|
||||
};
|
||||
[config] String bind_port {
|
||||
default {{{ return "6558"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -407,7 +407,7 @@ Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
|
|||
|
||||
Value ServicesTable::CurrentAttemptAccessor(const Value& row)
|
||||
{
|
||||
return static_cast<Service::Ptr>(row)->GetCurrentCheckAttempt();
|
||||
return static_cast<Service::Ptr>(row)->GetCheckAttempt();
|
||||
}
|
||||
|
||||
Value ServicesTable::StateAccessor(const Value& row)
|
||||
|
@ -471,7 +471,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
notification_interval = notification->GetNotificationInterval();
|
||||
}
|
||||
|
||||
if (notification_interval == 0 && !service->IsVolatile())
|
||||
if (notification_interval == 0 && !service->GetVolatile())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -731,9 +731,6 @@ Value ServicesTable::DowntimesAccessor(const Value& row)
|
|||
{
|
||||
Dictionary::Ptr downtimes = static_cast<Service::Ptr>(row)->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
@ -758,9 +755,6 @@ Value ServicesTable::DowntimesWithInfoAccessor(const Value& row)
|
|||
{
|
||||
Dictionary::Ptr downtimes = static_cast<Service::Ptr>(row)->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
@ -789,9 +783,6 @@ Value ServicesTable::CommentsAccessor(const Value& row)
|
|||
{
|
||||
Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
@ -816,9 +807,6 @@ Value ServicesTable::CommentsWithInfoAccessor(const Value& row)
|
|||
{
|
||||
Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
@ -847,9 +835,6 @@ Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row)
|
|||
{
|
||||
Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return Empty;
|
||||
|
||||
Array::Ptr ids = boost::make_shared<Array>();
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
|
|
@ -120,7 +120,7 @@ Value StatusTable::ConnectionsAccessor(const Value& row)
|
|||
|
||||
Value StatusTable::ConnectionsRateAccessor(const Value& row)
|
||||
{
|
||||
return (LivestatusListener::GetConnections() / (Utility::GetTime() - IcingaApplication::GetInstance()->GetStartTime()));
|
||||
return (LivestatusListener::GetConnections() / (Utility::GetTime() - Application::GetStartTime()));
|
||||
}
|
||||
|
||||
Value StatusTable::ExternalCommandsAccessor(const Value& row)
|
||||
|
@ -130,7 +130,7 @@ Value StatusTable::ExternalCommandsAccessor(const Value& row)
|
|||
|
||||
Value StatusTable::ExternalCommandsRateAccessor(const Value& row)
|
||||
{
|
||||
return (Query::GetExternalCommands() / (Utility::GetTime() - IcingaApplication::GetInstance()->GetStartTime()));
|
||||
return (Query::GetExternalCommands() / (Utility::GetTime() - Application::GetStartTime()));
|
||||
}
|
||||
|
||||
Value StatusTable::NagiosPidAccessor(const Value& row)
|
||||
|
@ -140,7 +140,7 @@ Value StatusTable::NagiosPidAccessor(const Value& row)
|
|||
|
||||
Value StatusTable::ProgramStartAccessor(const Value& row)
|
||||
{
|
||||
return static_cast<int>(IcingaApplication::GetInstance()->GetStartTime());
|
||||
return Application::GetStartTime();
|
||||
}
|
||||
|
||||
Value StatusTable::NumHostsAccessor(const Value& row)
|
||||
|
|
|
@ -3,15 +3,22 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libnotification.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
notificationcomponent.th
|
||||
|
||||
CLEANFILES = \
|
||||
notification-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libnotification_la_SOURCES = \
|
||||
notificationcomponent.cpp \
|
||||
notificationcomponent.h \
|
||||
notificationcomponent.ti \
|
||||
notification-type.conf
|
||||
|
||||
libnotification_la_CPPFLAGS = \
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef NOTIFICATIONCOMPONENT_H
|
||||
#define NOTIFICATIONCOMPONENT_H
|
||||
|
||||
#include "notification/notificationcomponent.th"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/timer.h"
|
||||
|
@ -30,7 +31,7 @@ namespace icinga
|
|||
/**
|
||||
* @ingroup notification
|
||||
*/
|
||||
class NotificationComponent : public DynamicObject
|
||||
class NotificationComponent : public ReflectionObjectImpl<NotificationComponent>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(NotificationComponent);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class NotificationComponent : DynamicObject
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -4,17 +4,26 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libperfdata.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
graphitewriter.th \
|
||||
perfdatawriter.th
|
||||
|
||||
CLEANFILES = \
|
||||
perfdata-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libperfdata_la_SOURCES = \
|
||||
graphitewriter.cpp \
|
||||
graphitewriter.h \
|
||||
graphitewriter.ti \
|
||||
perfdatawriter.cpp \
|
||||
perfdatawriter.h \
|
||||
perfdatawriter.th \
|
||||
perfdata-type.conf
|
||||
|
||||
libperfdata_la_CPPFLAGS = \
|
||||
|
|
|
@ -57,22 +57,6 @@ void GraphiteWriter::Start(void)
|
|||
Service::OnNewCheckResult.connect(boost::bind(&GraphiteWriter::CheckResultHandler, this, _1, _2));
|
||||
}
|
||||
|
||||
String GraphiteWriter::GetHost(void) const
|
||||
{
|
||||
if (m_Host.IsEmpty())
|
||||
return "127.0.0.1";
|
||||
else
|
||||
return m_Host;
|
||||
}
|
||||
|
||||
String GraphiteWriter::GetPort(void) const
|
||||
{
|
||||
if (m_Port.IsEmpty())
|
||||
return "2003";
|
||||
else
|
||||
return m_Port;
|
||||
}
|
||||
|
||||
void GraphiteWriter::ReconnectTimerHandler(void)
|
||||
{
|
||||
try {
|
||||
|
@ -110,7 +94,7 @@ void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const Dicti
|
|||
Value metricValue;
|
||||
|
||||
/* basic metrics */
|
||||
AddServiceMetric(metrics, service, "current_attempt", service->GetCurrentCheckAttempt());
|
||||
AddServiceMetric(metrics, service, "current_attempt", service->GetCheckAttempt());
|
||||
AddServiceMetric(metrics, service, "max_check_attempts", service->GetMaxCheckAttempts());
|
||||
AddServiceMetric(metrics, service, "state_type", service->GetStateType());
|
||||
AddServiceMetric(metrics, service, "state", service->GetState());
|
||||
|
@ -267,22 +251,3 @@ void GraphiteWriter::SanitizeMetric(String& str)
|
|||
boost::replace_all(str, "/", "_");
|
||||
}
|
||||
|
||||
void GraphiteWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("host", m_Host);
|
||||
bag->Set("port", m_Port);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphiteWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Host = bag->Get("host");
|
||||
m_Port = bag->Get("port");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef GRAPHITEWRITER_H
|
||||
#define GRAPHITEWRITER_H
|
||||
|
||||
#include "perfdata/graphitewriter.th"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/tcpsocket.h"
|
||||
|
@ -34,24 +35,16 @@ namespace icinga
|
|||
*
|
||||
* @ingroup perfdata
|
||||
*/
|
||||
class GraphiteWriter : public DynamicObject
|
||||
class GraphiteWriter : public ReflectionObjectImpl<GraphiteWriter>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(GraphiteWriter);
|
||||
DECLARE_TYPENAME(GraphiteWriter);
|
||||
|
||||
String GetHost(void) const;
|
||||
String GetPort(void) const;
|
||||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_Host;
|
||||
String m_Port;
|
||||
Stream::Ptr m_Stream;
|
||||
|
||||
Timer::Ptr m_ReconnectTimer;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class GraphiteWriter : DynamicObject
|
||||
{
|
||||
[config] String host {
|
||||
default {{{ return "127.0.0.1"; }}}
|
||||
};
|
||||
[config] String port {
|
||||
default {{{ return "2003"; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -33,10 +33,6 @@ using namespace icinga;
|
|||
|
||||
REGISTER_TYPE(PerfdataWriter);
|
||||
|
||||
PerfdataWriter::PerfdataWriter(void)
|
||||
: m_RotationInterval(30)
|
||||
{ }
|
||||
|
||||
void PerfdataWriter::Start(void)
|
||||
{
|
||||
DynamicObject::Start();
|
||||
|
@ -51,37 +47,6 @@ void PerfdataWriter::Start(void)
|
|||
RotateFile();
|
||||
}
|
||||
|
||||
String PerfdataWriter::GetPerfdataPath(void) const
|
||||
{
|
||||
if (!m_PerfdataPath.IsEmpty())
|
||||
return m_PerfdataPath;
|
||||
else
|
||||
return Application::GetLocalStateDir() + "/cache/icinga2/perfdata/perfdata";
|
||||
}
|
||||
|
||||
String PerfdataWriter::GetFormatTemplate(void) const
|
||||
{
|
||||
if (!m_FormatTemplate.IsEmpty()) {
|
||||
return m_FormatTemplate;
|
||||
} else {
|
||||
return "DATATYPE::SERVICEPERFDATA\t"
|
||||
"TIMET::$TIMET$\t"
|
||||
"HOSTNAME::$HOSTNAME$\t"
|
||||
"SERVICEDESC::$SERVICEDESC$\t"
|
||||
"SERVICEPERFDATA::$SERVICEPERFDATA$\t"
|
||||
"SERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\t"
|
||||
"HOSTSTATE::$HOSTSTATE$\t"
|
||||
"HOSTSTATETYPE::$HOSTSTATETYPE$\t"
|
||||
"SERVICESTATE::$SERVICESTATE$\t"
|
||||
"SERVICESTATETYPE::$SERVICESTATETYPE$";
|
||||
}
|
||||
}
|
||||
|
||||
double PerfdataWriter::GetRotationInterval(void) const
|
||||
{
|
||||
return m_RotationInterval;
|
||||
}
|
||||
|
||||
void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
|
||||
{
|
||||
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
|
||||
|
@ -130,24 +95,3 @@ void PerfdataWriter::RotationTimerHandler(void)
|
|||
RotateFile();
|
||||
}
|
||||
|
||||
void PerfdataWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("perfdata_path", m_PerfdataPath);
|
||||
bag->Set("format_template", m_FormatTemplate);
|
||||
bag->Set("rotation_interval", m_RotationInterval);
|
||||
}
|
||||
}
|
||||
|
||||
void PerfdataWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_PerfdataPath = bag->Get("perfdata_path");
|
||||
m_FormatTemplate = bag->Get("format_template");
|
||||
m_RotationInterval = bag->Get("rotation_interval");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PERFDATAWRITER_H
|
||||
#define PERFDATAWRITER_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "perfdata/perfdatawriter.th"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/timer.h"
|
||||
|
@ -34,29 +34,16 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class PerfdataWriter : public DynamicObject
|
||||
class PerfdataWriter : public ReflectionObjectImpl<PerfdataWriter>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(PerfdataWriter);
|
||||
DECLARE_TYPENAME(PerfdataWriter);
|
||||
|
||||
PerfdataWriter(void);
|
||||
|
||||
String GetPerfdataPath(void) const;
|
||||
String GetFormatTemplate(void) const;
|
||||
double GetRotationInterval(void) const;
|
||||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_PerfdataPath;
|
||||
String m_FormatTemplate;
|
||||
double m_RotationInterval;
|
||||
|
||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr);
|
||||
|
||||
Timer::Ptr m_RotationTimer;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include "base/application.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class PerfdataWriter : DynamicObject
|
||||
{
|
||||
[config] String perfdata_path {
|
||||
default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/perfdata/perfdata"; }}}
|
||||
};
|
||||
[config] String format_template {
|
||||
default {{{
|
||||
return "DATATYPE::SERVICEPERFDATA\t"
|
||||
"TIMET::$TIMET$\t"
|
||||
"HOSTNAME::$HOSTNAME$\t"
|
||||
"SERVICEDESC::$SERVICEDESC$\t"
|
||||
"SERVICEPERFDATA::$SERVICEPERFDATA$\t"
|
||||
"SERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\t"
|
||||
"HOSTSTATE::$HOSTSTATE$\t"
|
||||
"HOSTSTATETYPE::$HOSTSTATETYPE$\t"
|
||||
"SERVICESTATE::$SERVICESTATE$\t"
|
||||
"SERVICESTATETYPE::$SERVICESTATETYPE$";
|
||||
}}}
|
||||
};
|
||||
|
||||
[config] double rotation_interval {
|
||||
default {{{ return 30; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -210,6 +210,7 @@ third-party/mmatch/Makefile
|
|||
tools/Makefile
|
||||
tools/migration/Makefile
|
||||
tools/icinga2-enable-feature
|
||||
tools/mkclass/Makefile
|
||||
tools/mkembedconfig/Makefile
|
||||
])
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ Attributes:
|
|||
max\_check\_attempts|**Optional.** The number of times a service is re-checked before changing into a hard state. Defaults to 3.
|
||||
check\_period |**Optional.** The name of a time period which determines when this service should be checked. Not set by default.
|
||||
check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the service is in a `HARD` state. Defaults to 5 minutes.
|
||||
retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1/5th of the check interval if not specified.
|
||||
retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1 minute.
|
||||
enable\_active\_checks|**Optional.** Whether active checks are enabled. Defaults to true.
|
||||
enable\_passive\_checks|**Optional.** Whether passive checks are enabled. Defaults to true.
|
||||
enable\_event\_handler|**Optional.** Enables event handlers for this service. Defaults to true.
|
||||
|
|
|
@ -160,6 +160,8 @@ static bool Daemonize(const String& stderrFile)
|
|||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Application::SetStartTime(Utility::GetTime());
|
||||
|
||||
#ifndef _WIN32
|
||||
LTDL_SET_PRELOADED_SYMBOLS();
|
||||
#endif /* _WIN32 */
|
||||
|
|
20
icinga2.sln
20
icinga2.sln
|
@ -14,6 +14,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\demo.vcxproj", "{2E6C1133-730F-4875-A72C-B455B1DD4C5C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -21,6 +22,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\dem
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "notification", "components\notification\notification.vcxproj", "{EBEA7D10-66FB-4760-8AA8-81CD500D899E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{950E8743-BB34-4F8A-99EC-C87E8FC0EB3F} = {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
|
@ -34,6 +36,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checker", "components\checker\checker.vcxproj", "{38CE81CC-2660-4EF0-A936-4A337591DA3E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -42,6 +45,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "components\compat\compat.vcxproj", "{2BD1C70C-43DB-4F44-B66B-67CF5C7044AA}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -57,6 +61,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "lib\base\base.vcxpr
|
|||
ProjectSection(ProjectDependencies) = postProject
|
||||
{19CBCE06-3F5C-479A-BD75-E2AB6215D345} = {19CBCE06-3F5C-479A-BD75-E2AB6215D345}
|
||||
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config", "lib\config\config.vcxproj", "{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}"
|
||||
|
@ -68,6 +73,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "lib\icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
EndProjectSection
|
||||
|
@ -80,6 +86,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "livestatus", "components\livestatus\livestatus.vcxproj", "{950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -90,6 +97,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cluster", "components\cluster\cluster.vcxproj", "{8732E0CD-E3D0-41F2-A538-94884543890F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -107,6 +115,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db_ido", "lib\db_ido\db_ido.vcxproj", "{87BBCE4C-36F5-4C04-90FB-9B74618AF988}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
|
@ -114,12 +123,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db_ido", "lib\db_ido\db_ido
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perfdata", "components\perfdata\perfdata.vcxproj", "{E08A9B69-97E2-4203-B4D7-501DFF020CCF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{950E8743-BB34-4F8A-99EC-C87E8FC0EB3F} = {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}
|
||||
{D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mkclass", "tools\mkclass\mkclass.vcxproj", "{CBC9DD83-BAEB-4995-8D0B-F711898908E7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -265,6 +277,14 @@ Global
|
|||
{E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|Win32.Build.0 = Release|Win32
|
||||
{E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|x64.ActiveCfg = Release|x64
|
||||
{E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|x64.Build.0 = Release|x64
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|x64.Build.0 = Debug|x64
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|Win32.Build.0 = Release|Win32
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|x64.ActiveCfg = Release|x64
|
||||
{CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -4,15 +4,30 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libbase.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
application.th \
|
||||
consolelogger.th \
|
||||
dynamicobject.th \
|
||||
filelogger.th \
|
||||
logger.th \
|
||||
script.th \
|
||||
streamlogger.th \
|
||||
sysloglogger.th
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libbase_la_SOURCES = \
|
||||
application.cpp \
|
||||
application.h \
|
||||
application.ti \
|
||||
array.cpp \
|
||||
array.h \
|
||||
bufferedstream.cpp \
|
||||
bufferedstream.h \
|
||||
consolelogger.cpp \
|
||||
consolelogger.h \
|
||||
consolelogger.ti \
|
||||
convert.cpp \
|
||||
convert.h \
|
||||
debug.h \
|
||||
|
@ -20,6 +35,7 @@ libbase_la_SOURCES = \
|
|||
dictionary.h \
|
||||
dynamicobject.cpp \
|
||||
dynamicobject.h \
|
||||
dynamicobject.ti \
|
||||
dynamictype.cpp \
|
||||
dynamictype.h \
|
||||
exception.cpp \
|
||||
|
@ -28,10 +44,12 @@ libbase_la_SOURCES = \
|
|||
fifo.h \
|
||||
filelogger.cpp \
|
||||
filelogger.h \
|
||||
filelogger.ti \
|
||||
i2-base.h \
|
||||
initialize.h \
|
||||
logger.cpp \
|
||||
logger.h \
|
||||
logger.ti \
|
||||
logger_fwd.h \
|
||||
netstring.cpp \
|
||||
netstring.h \
|
||||
|
@ -47,11 +65,14 @@ libbase_la_SOURCES = \
|
|||
process.h \
|
||||
qstring.cpp \
|
||||
qstring.h \
|
||||
reflectionobject.cpp \
|
||||
reflectionobject.h \
|
||||
registry.h \
|
||||
ringbuffer.cpp \
|
||||
ringbuffer.h \
|
||||
script.cpp \
|
||||
script.h \
|
||||
script.ti \
|
||||
scriptfunction.cpp \
|
||||
scriptfunction.h \
|
||||
scriptfunctionwrapper.cpp \
|
||||
|
@ -75,8 +96,10 @@ libbase_la_SOURCES = \
|
|||
stream_bio.h \
|
||||
streamlogger.cpp \
|
||||
streamlogger.h \
|
||||
streamlogger.ti \
|
||||
sysloglogger.cpp \
|
||||
sysloglogger.h \
|
||||
sysloglogger.ti \
|
||||
tcpsocket.cpp \
|
||||
tcpsocket.h \
|
||||
threadpool.cpp \
|
||||
|
|
|
@ -51,6 +51,7 @@ bool Application::m_Restarting = false;
|
|||
bool Application::m_Debugging = false;
|
||||
int Application::m_ArgC;
|
||||
char **Application::m_ArgV;
|
||||
double Application::m_StartTime;
|
||||
|
||||
/**
|
||||
* Constructor for the Application class.
|
||||
|
@ -718,3 +719,13 @@ String Application::GetVersion(void)
|
|||
return "unspecified version";
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
double Application::GetStartTime(void)
|
||||
{
|
||||
return m_StartTime;
|
||||
}
|
||||
|
||||
void Application::SetStartTime(double ts)
|
||||
{
|
||||
m_StartTime = ts;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define APPLICATION_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/application.th"
|
||||
#include "base/threadpool.h"
|
||||
#include "base/dynamicobject.h"
|
||||
|
||||
|
@ -33,7 +34,7 @@ class Component;
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API Application : public DynamicObject {
|
||||
class I2_BASE_API Application : public ReflectionObjectImpl<Application> {
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Application);
|
||||
|
||||
|
@ -94,6 +95,9 @@ public:
|
|||
|
||||
static String GetVersion(void);
|
||||
|
||||
static double GetStartTime(void);
|
||||
static void SetStartTime(double ts);
|
||||
|
||||
protected:
|
||||
virtual void OnConfigLoaded(void);
|
||||
virtual void Stop(void);
|
||||
|
@ -112,6 +116,7 @@ private:
|
|||
static char **m_ArgV; /**< Command-line arguments. */
|
||||
FILE *m_PidFile; /**< The PID file */
|
||||
static bool m_Debugging; /**< Whether debugging is enabled. */
|
||||
static double m_StartTime;
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigIntHandler(int signum);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Application : DynamicObject
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -30,6 +30,7 @@
|
|||
<ClCompile Include="dynamictype.cpp" />
|
||||
<ClCompile Include="filelogger.cpp" />
|
||||
<ClCompile Include="networkstream.cpp" />
|
||||
<ClCompile Include="reflectionobject.cpp" />
|
||||
<ClCompile Include="script.cpp" />
|
||||
<ClCompile Include="scriptinterpreter.cpp" />
|
||||
<ClCompile Include="scriptlanguage.cpp" />
|
||||
|
@ -78,6 +79,7 @@
|
|||
<ClInclude Include="filelogger.h" />
|
||||
<ClInclude Include="initialize.h" />
|
||||
<ClInclude Include="networkstream.h" />
|
||||
<ClInclude Include="reflectionobject.h" />
|
||||
<ClInclude Include="script.h" />
|
||||
<ClInclude Include="scriptinterpreter.h" />
|
||||
<ClInclude Include="scriptlanguage.h" />
|
||||
|
@ -118,7 +120,105 @@
|
|||
<ClInclude Include="zlibstream.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="dynamicobject.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="dynamicobject.th">
|
||||
<FileType>Document</FileType>
|
||||
</ClInclude>
|
||||
<CustomBuild Include="application.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="application.th" />
|
||||
<CustomBuild Include="logger.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="filelogger.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="consolelogger.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="consolelogger.th" />
|
||||
<None Include="filelogger.th" />
|
||||
<None Include="logger.th" />
|
||||
<None Include="packages.config" />
|
||||
<CustomBuild Include="script.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="script.th" />
|
||||
<CustomBuild Include="streamlogger.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="streamlogger.th" />
|
||||
<CustomBuild Include="sysloglogger.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="sysloglogger.th" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9C92DA90-FD53-43A9-A244-90F2E8AF9677}</ProjectGuid>
|
||||
|
|
|
@ -133,6 +133,9 @@
|
|||
<ClCompile Include="zlibstream.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="reflectionobject.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="application.h">
|
||||
|
@ -285,6 +288,12 @@
|
|||
<ClInclude Include="zlibstream.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="reflectionobject.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dynamicobject.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Quelldateien">
|
||||
|
@ -296,5 +305,52 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="script.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="application.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="logger.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="streamlogger.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="filelogger.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="sysloglogger.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
<None Include="consolelogger.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="dynamicobject.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="script.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="application.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="logger.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="streamlogger.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="filelogger.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="sysloglogger.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="consolelogger.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -21,7 +21,7 @@
|
|||
#define CONSOLELOGGER_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/streamlogger.h"
|
||||
#include "base/consolelogger.th"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API ConsoleLogger : public StreamLogger
|
||||
class I2_BASE_API ConsoleLogger : public ReflectionObjectImpl<ConsoleLogger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(ConsoleLogger);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/streamlogger.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class ConsoleLogger : StreamLogger
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -22,30 +22,45 @@
|
|||
|
||||
#include "i2-base.h"
|
||||
|
||||
#ifdef NDEBUG
|
||||
#ifndef _DEBUG
|
||||
# define ASSERT(expr) ((void)0)
|
||||
#else /* NDEBUG */
|
||||
#else /* _DEBUG */
|
||||
# define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
|
||||
#endif /* NDEBUG */
|
||||
#endif /* _DEBUG */
|
||||
|
||||
#define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define NORETURNPRE __declspec(noreturn)
|
||||
#else /* _MSC_VER */
|
||||
# define NORETURNPRE
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define NORETURN __attribute__((noreturn))
|
||||
# define NORETURNPOST __attribute__((noreturn))
|
||||
#else /* __GNUC__ */
|
||||
# define NORETURN
|
||||
# define NORETURNPOST
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
int icinga_assert_fail(const char *expr, const char *file, int line) NORETURN;
|
||||
NORETURNPRE int icinga_assert_fail(const char *expr, const char *file, int line) NORETURNPOST;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4646 ) /* function declared with __declspec(noreturn) has non-void return type */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
inline int icinga_assert_fail(const char *expr, const char *file, int line)
|
||||
{
|
||||
fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
|
||||
abort();
|
||||
|
||||
#ifndef __GNUC__
|
||||
#if !defined(__GNUC__) && !defined(_MSC_VER)
|
||||
return 0;
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* !defined(__GNUC__) && !defined(_MSC_VER) */
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( pop )
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
|
|
@ -42,90 +42,21 @@ boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnState
|
|||
boost::signals2::signal<void (const DynamicObject::Ptr&, const String&, bool)> DynamicObject::OnAuthorityChanged;
|
||||
|
||||
DynamicObject::DynamicObject(void)
|
||||
: m_Active(false)
|
||||
{ }
|
||||
{
|
||||
SetActive(false);
|
||||
}
|
||||
|
||||
DynamicObject::~DynamicObject(void)
|
||||
{ }
|
||||
|
||||
Dictionary::Ptr DynamicObject::Serialize(int attributeTypes) const
|
||||
{
|
||||
Dictionary::Ptr update = boost::make_shared<Dictionary>();
|
||||
|
||||
ASSERT(!OwnsLock());
|
||||
ObjectLock olock(this);
|
||||
|
||||
InternalSerialize(update, attributeTypes);
|
||||
|
||||
/* Make sure our own InternalSerialize() method was called. */
|
||||
ASSERT(update->Contains("__marker"));
|
||||
update->Remove("__marker");
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
|
||||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
InternalDeserialize(update, attributeTypes);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("__name", m_Name);
|
||||
bag->Set("__type", m_Type);
|
||||
bag->Set("methods", m_Methods);
|
||||
bag->Set("custom", m_Custom);
|
||||
bag->Set("authorities", m_Authorities);
|
||||
bag->Set("domains", m_Domains);
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State)
|
||||
bag->Set("extensions", m_Extensions);
|
||||
|
||||
/* This attribute is used by Serialize() to check that this
|
||||
* method was called. */
|
||||
bag->Set("__marker", 1);
|
||||
}
|
||||
|
||||
void DynamicObject::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Name = bag->Get("__name");
|
||||
m_Type = bag->Get("__type");
|
||||
m_Methods = bag->Get("methods");
|
||||
m_Custom = bag->Get("custom");
|
||||
m_Authorities = bag->Get("authorities");
|
||||
m_Domains = bag->Get("domains");
|
||||
}
|
||||
|
||||
if (attributeTypes & Attribute_State)
|
||||
m_Extensions = bag->Get("extensions");
|
||||
}
|
||||
|
||||
DynamicType::Ptr DynamicObject::GetType(void) const
|
||||
{
|
||||
return DynamicType::GetByName(m_Type);
|
||||
}
|
||||
|
||||
String DynamicObject::GetName(void) const
|
||||
{
|
||||
return m_Name;
|
||||
return DynamicType::GetByName(GetTypeName());
|
||||
}
|
||||
|
||||
bool DynamicObject::IsActive(void) const
|
||||
{
|
||||
return m_Active;
|
||||
}
|
||||
|
||||
Array::Ptr DynamicObject::GetAuthorities(void) const
|
||||
{
|
||||
return m_Authorities;
|
||||
return GetActive();
|
||||
}
|
||||
|
||||
void DynamicObject::SetAuthority(const String& type, bool value)
|
||||
|
@ -135,15 +66,12 @@ void DynamicObject::SetAuthority(const String& type, bool value)
|
|||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
if (!m_Authority)
|
||||
m_Authority = boost::make_shared<Dictionary>();
|
||||
|
||||
bool old_value = HasAuthority(type);
|
||||
|
||||
if (old_value == value)
|
||||
return;
|
||||
|
||||
m_Authority->Set(type, value);
|
||||
GetAuthorityInfo()->Set(type, value);
|
||||
}
|
||||
|
||||
OnAuthorityChanged(GetSelf(), type, value);
|
||||
|
@ -151,15 +79,7 @@ void DynamicObject::SetAuthority(const String& type, bool value)
|
|||
|
||||
bool DynamicObject::HasAuthority(const String& type) const
|
||||
{
|
||||
if (!m_Authority)
|
||||
return true;
|
||||
|
||||
return m_Authority->Get(type);
|
||||
}
|
||||
|
||||
Array::Ptr DynamicObject::GetDomains(void) const
|
||||
{
|
||||
return m_Domains;
|
||||
return GetAuthorityInfo()->Get(type);
|
||||
}
|
||||
|
||||
void DynamicObject::SetPrivileges(const String& instance, int privs)
|
||||
|
@ -183,11 +103,11 @@ bool DynamicObject::HasPrivileges(const String& instance, int privs) const
|
|||
|
||||
void DynamicObject::SetExtension(const String& key, const Object::Ptr& object)
|
||||
{
|
||||
Dictionary::Ptr extensions = m_Extensions;
|
||||
Dictionary::Ptr extensions = GetExtensions();
|
||||
|
||||
if (!extensions) {
|
||||
extensions = boost::make_shared<Dictionary>();
|
||||
m_Extensions = extensions;
|
||||
SetExtensions(extensions);
|
||||
}
|
||||
|
||||
extensions->Set(key, object);
|
||||
|
@ -195,7 +115,7 @@ void DynamicObject::SetExtension(const String& key, const Object::Ptr& object)
|
|||
|
||||
Object::Ptr DynamicObject::GetExtension(const String& key)
|
||||
{
|
||||
Dictionary::Ptr extensions = m_Extensions;
|
||||
Dictionary::Ptr extensions = GetExtensions();
|
||||
|
||||
if (!extensions)
|
||||
return Object::Ptr();
|
||||
|
@ -205,7 +125,7 @@ Object::Ptr DynamicObject::GetExtension(const String& key)
|
|||
|
||||
void DynamicObject::ClearExtension(const String& key)
|
||||
{
|
||||
Dictionary::Ptr extensions = m_Extensions;
|
||||
Dictionary::Ptr extensions = GetExtensions();
|
||||
|
||||
if (!extensions)
|
||||
return;
|
||||
|
@ -225,8 +145,8 @@ void DynamicObject::Start(void)
|
|||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
||||
ASSERT(!m_Active);
|
||||
m_Active = true;
|
||||
ASSERT(!IsActive());
|
||||
SetActive(true);
|
||||
|
||||
OnStarted(GetSelf());
|
||||
}
|
||||
|
@ -235,8 +155,8 @@ void DynamicObject::Stop(void)
|
|||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
||||
ASSERT(m_Active);
|
||||
m_Active = false;
|
||||
ASSERT(IsActive());
|
||||
SetActive(false);
|
||||
|
||||
OnStopped(GetSelf());
|
||||
}
|
||||
|
@ -256,7 +176,7 @@ Value DynamicObject::InvokeMethod(const String& method,
|
|||
{
|
||||
Dictionary::Ptr methods;
|
||||
|
||||
methods = m_Methods;
|
||||
methods = GetMethods();
|
||||
|
||||
if (!methods)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Method '" + method + "' does not exist."));
|
||||
|
@ -383,8 +303,3 @@ DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& na
|
|||
DynamicType::Ptr dtype = DynamicType::GetByName(type);
|
||||
return dtype->GetObject(name);
|
||||
}
|
||||
|
||||
Dictionary::Ptr DynamicObject::GetCustom(void) const
|
||||
{
|
||||
return m_Custom;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define DYNAMICOBJECT_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/dynamicobject.th"
|
||||
#include "base/object.h"
|
||||
#include "base/dictionary.h"
|
||||
#include "base/array.h"
|
||||
|
@ -40,8 +41,8 @@ class DynamicType;
|
|||
*/
|
||||
enum AttributeType
|
||||
{
|
||||
Attribute_State = 1,
|
||||
Attribute_Config = 2,
|
||||
Attribute_State = FAState,
|
||||
Attribute_Config = FAConfig
|
||||
};
|
||||
|
||||
enum DomainPriv
|
||||
|
@ -57,16 +58,13 @@ enum DomainPriv
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API DynamicObject : public Object
|
||||
class I2_BASE_API DynamicObject : public ReflectionObjectImpl<DynamicObject>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(DynamicObject);
|
||||
|
||||
~DynamicObject(void);
|
||||
|
||||
Dictionary::Ptr Serialize(int attributeTypes) const;
|
||||
void Deserialize(const Dictionary::Ptr& update, int attributeTypes);
|
||||
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged;
|
||||
|
@ -75,17 +73,12 @@ public:
|
|||
Value InvokeMethod(const String& method, const std::vector<Value>& arguments);
|
||||
|
||||
shared_ptr<DynamicType> GetType(void) const;
|
||||
String GetName(void) const;
|
||||
|
||||
bool IsActive(void) const;
|
||||
|
||||
Array::Ptr GetAuthorities(void) const;
|
||||
|
||||
void SetAuthority(const String& type, bool value);
|
||||
bool HasAuthority(const String& type) const;
|
||||
|
||||
Array::Ptr GetDomains(void) const;
|
||||
|
||||
void SetPrivileges(const String& instance, int privs);
|
||||
bool HasPrivileges(const String& instance, int privs) const;
|
||||
|
||||
|
@ -116,27 +109,12 @@ public:
|
|||
static void RestoreObjects(const String& filename, int attributeTypes = Attribute_State);
|
||||
static void StopObjects(void);
|
||||
|
||||
Dictionary::Ptr GetCustom(void) const;
|
||||
|
||||
protected:
|
||||
explicit DynamicObject(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_Name;
|
||||
String m_Type;
|
||||
Dictionary::Ptr m_Extensions;
|
||||
Dictionary::Ptr m_Methods;
|
||||
Dictionary::Ptr m_Custom;
|
||||
Array::Ptr m_Authorities;
|
||||
Array::Ptr m_Domains;
|
||||
std::map<String, int> m_Privileges;
|
||||
|
||||
bool m_Active;
|
||||
Dictionary::Ptr m_Authority;
|
||||
|
||||
static DynamicObject::Ptr GetObject(const String& type, const String& name);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class DynamicObject
|
||||
{
|
||||
[config] String __name (Name);
|
||||
[config, get_protected] String __type (TypeName);
|
||||
[config] Dictionary::Ptr methods;
|
||||
[config] Dictionary::Ptr custom;
|
||||
[config] Array::Ptr domains;
|
||||
[config] Array::Ptr authorities;
|
||||
[get_protected] bool active;
|
||||
Dictionary::Ptr authority_info {
|
||||
default {{{ return boost::make_shared<Dictionary>(); }}}
|
||||
};
|
||||
[protected] Dictionary::Ptr extensions;
|
||||
};
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ void FileLogger::Start()
|
|||
|
||||
std::ofstream *stream = new std::ofstream();
|
||||
|
||||
String path = m_Path;
|
||||
String path = GetPath();
|
||||
|
||||
try {
|
||||
stream->open(path.CStr(), std::fstream::out | std::fstream::trunc);
|
||||
|
@ -48,19 +48,3 @@ void FileLogger::Start()
|
|||
|
||||
BindStream(stream, true);
|
||||
}
|
||||
|
||||
void FileLogger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
StreamLogger::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
bag->Set("path", m_Path);
|
||||
}
|
||||
|
||||
void FileLogger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
StreamLogger::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
m_Path = bag->Get("path");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define FILELOGGER_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/streamlogger.h"
|
||||
#include "base/filelogger.th"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -31,19 +31,12 @@ namespace icinga
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API FileLogger : public StreamLogger
|
||||
class I2_BASE_API FileLogger : public ReflectionObjectImpl<FileLogger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(FileLogger);
|
||||
|
||||
virtual void Start(void);
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_Path;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "base/streamlogger.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class FileLogger : StreamLogger
|
||||
{
|
||||
[config] String path;
|
||||
};
|
||||
|
||||
}
|
|
@ -105,7 +105,7 @@ void icinga::Log(LogSeverity severity, const String& facility,
|
|||
*/
|
||||
LogSeverity Logger::GetMinSeverity(void) const
|
||||
{
|
||||
String severity = m_Severity;
|
||||
String severity = GetSeverity();
|
||||
if (severity.IsEmpty())
|
||||
return LogInformation;
|
||||
else
|
||||
|
@ -151,19 +151,3 @@ LogSeverity Logger::StringToSeverity(const String& severity)
|
|||
else
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
|
||||
}
|
||||
|
||||
void Logger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
bag->Set("severity", m_Severity);
|
||||
}
|
||||
|
||||
void Logger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config)
|
||||
m_Severity = bag->Get("severity");
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define LOGGER_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/logger.th"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/logger_fwd.h"
|
||||
#include <set>
|
||||
|
@ -45,7 +46,7 @@ struct LogEntry {
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API Logger : public DynamicObject
|
||||
class I2_BASE_API Logger : public ReflectionObjectImpl<Logger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Logger);
|
||||
|
@ -69,12 +70,7 @@ protected:
|
|||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_Severity;
|
||||
|
||||
static boost::mutex m_Mutex;
|
||||
static std::set<Logger::Ptr> m_Loggers;
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Logger : DynamicObject
|
||||
{
|
||||
[config] String severity;
|
||||
};
|
||||
|
||||
}
|
|
@ -129,7 +129,7 @@ ProcessResult Process::Run(void)
|
|||
(void) close(fds[0]);
|
||||
(void) close(fds[1]);
|
||||
|
||||
if (execvpe(argv[0], argv, envp) < 0) {
|
||||
if (icinga2_execvpe(argv[0], argv, envp) < 0) {
|
||||
perror("execvpe() failed.");
|
||||
_exit(128);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2013 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 "base/reflectionobject.h"
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
Dictionary::Ptr ReflectionObject::Serialize(int attributeTypes) const
|
||||
{
|
||||
Dictionary::Ptr update = boost::make_shared<Dictionary>();
|
||||
|
||||
for (int i = 0; i < GetFieldCount(); i++) {
|
||||
ReflectionField field = GetFieldInfo(i);
|
||||
|
||||
if ((field.Attributes & attributeTypes) == 0)
|
||||
continue;
|
||||
|
||||
update->Set(field.Name, GetField(i));
|
||||
}
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
void ReflectionObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
|
||||
{
|
||||
for (int i = 0; i < GetFieldCount(); i++) {
|
||||
ReflectionField field = GetFieldInfo(i);
|
||||
|
||||
if ((field.Attributes & attributeTypes) == 0)
|
||||
continue;
|
||||
|
||||
if (!update->Contains(field.Name))
|
||||
continue;
|
||||
|
||||
SetField(i, update->Get(field.Name));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2013 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 REFLECTIONOBJECT_H
|
||||
#define REFLECTIONOBJECT_H
|
||||
|
||||
#include "base/object.h"
|
||||
#include "base/dictionary.h"
|
||||
#include <vector>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
enum ReflectionFieldAttribute
|
||||
{
|
||||
FAConfig = 1,
|
||||
FAState = 2
|
||||
};
|
||||
|
||||
struct ReflectionField
|
||||
{
|
||||
int ID;
|
||||
String Name;
|
||||
int Attributes;
|
||||
Value DefaultValue;
|
||||
|
||||
ReflectionField(int id, const String& name, int attributes, const Value& default_value = Empty)
|
||||
: ID(id), Name(name), Attributes(attributes), DefaultValue(default_value)
|
||||
{ }
|
||||
};
|
||||
|
||||
enum InvokationType
|
||||
{
|
||||
ITGet,
|
||||
ITSet
|
||||
};
|
||||
|
||||
class I2_BASE_API ReflectionObject : public Object
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(ReflectionObject);
|
||||
|
||||
virtual int GetFieldId(const String& name) const = 0;
|
||||
virtual ReflectionField GetFieldInfo(int id) const = 0;
|
||||
virtual int GetFieldCount(void) const = 0;
|
||||
virtual void SetField(int id, const Value& value) = 0;
|
||||
virtual Value GetField(int id) const = 0;
|
||||
|
||||
Dictionary::Ptr Serialize(int attributeTypes) const;
|
||||
void Deserialize(const Dictionary::Ptr& update, int attributeTypes);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ReflectionObjectImpl
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* REFLECTIONOBJECT_H */
|
|
@ -37,20 +37,6 @@ void Script::Start(void)
|
|||
SpawnInterpreter();
|
||||
}
|
||||
|
||||
String Script::GetLanguage(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_Language;
|
||||
}
|
||||
|
||||
String Script::GetCode(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_Code;
|
||||
}
|
||||
|
||||
void Script::SpawnInterpreter(void)
|
||||
{
|
||||
Log(LogInformation, "base", "Reloading script '" + GetName() + "'");
|
||||
|
@ -58,23 +44,3 @@ void Script::SpawnInterpreter(void)
|
|||
ScriptLanguage::Ptr language = ScriptLanguage::GetByName(GetLanguage());
|
||||
m_Interpreter = language->CreateInterpreter(GetSelf());
|
||||
}
|
||||
|
||||
void Script::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("language", m_Language);
|
||||
bag->Set("code", m_Code);
|
||||
}
|
||||
}
|
||||
|
||||
void Script::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Language = bag->Get("language");
|
||||
m_Code = bag->Get("code");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define SCRIPT_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/script.th"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -33,24 +33,14 @@ class ScriptInterpreter;
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API Script : public DynamicObject
|
||||
class I2_BASE_API Script : public ReflectionObjectImpl<Script>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Script);
|
||||
|
||||
virtual void Start(void);
|
||||
|
||||
String GetLanguage(void) const;
|
||||
String GetCode(void) const;
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
String m_Language;
|
||||
String m_Code;
|
||||
|
||||
shared_ptr<ScriptInterpreter> m_Interpreter;
|
||||
|
||||
void SpawnInterpreter(void);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Script : DynamicObject
|
||||
{
|
||||
[config] String language;
|
||||
[config] String "code";
|
||||
};
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
#define STREAMLOGGER_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/streamlogger.th"
|
||||
#include "base/timer.h"
|
||||
#include <ostream>
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API StreamLogger : public Logger
|
||||
class I2_BASE_API StreamLogger : public ReflectionObjectImpl<StreamLogger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(StreamLogger);
|
||||
|
@ -53,11 +53,11 @@ private:
|
|||
static boost::mutex m_Mutex;
|
||||
std::ostream *m_Stream;
|
||||
bool m_OwnsStream;
|
||||
bool m_Tty;
|
||||
bool m_Tty;
|
||||
|
||||
Timer::Ptr m_FlushLogTimer;
|
||||
Timer::Ptr m_FlushLogTimer;
|
||||
|
||||
void FlushLogTimerHandler(void);
|
||||
void FlushLogTimerHandler(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/logger.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class StreamLogger : Logger
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
#define SYSLOGLOGGER_H
|
||||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/sysloglogger.th"
|
||||
|
||||
#ifndef _WIN32
|
||||
namespace icinga
|
||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class I2_BASE_API SyslogLogger : public Logger
|
||||
class I2_BASE_API SyslogLogger : public ReflectionObjectImpl<SyslogLogger>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(SyslogLogger);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "base/logger.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class SyslogLogger : Logger
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -3,17 +3,24 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libdb_ido.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
dbconnection.th
|
||||
|
||||
CLEANFILES = \
|
||||
db_ido-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libdb_ido_la_SOURCES = \
|
||||
commanddbobject.cpp \
|
||||
commanddbobject.h \
|
||||
dbconnection.cpp \
|
||||
dbconnection.h \
|
||||
dbconnection.ti \
|
||||
dbobject.cpp \
|
||||
dbobject.h \
|
||||
dbquery.cpp \
|
||||
|
|
|
@ -74,6 +74,18 @@
|
|||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="dbconnection.ti">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" > "%(Filename).th"</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<None Include="dbconnection.th" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
|
|
@ -101,10 +101,16 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="dbconnection.th">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="db_ido-type.conf">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="dbconnection.ti">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -55,14 +55,6 @@ void DbConnection::StaticInitialize(void)
|
|||
m_ProgramStatusTimer->Start();
|
||||
}
|
||||
|
||||
String DbConnection::GetTablePrefix(void) const
|
||||
{
|
||||
if (m_TablePrefix.IsEmpty())
|
||||
return "icinga_";
|
||||
else
|
||||
return m_TablePrefix;
|
||||
}
|
||||
|
||||
void DbConnection::InsertRuntimeVariable(const String& key, const Value& value)
|
||||
{
|
||||
DbQuery query;
|
||||
|
@ -91,7 +83,7 @@ void DbConnection::ProgramStatusHandler(void)
|
|||
query2.Fields = boost::make_shared<Dictionary>();
|
||||
query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
query2.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
query2.Fields->Set("program_start_time", DbValue::FromTimestamp(IcingaApplication::GetInstance()->GetStartTime()));
|
||||
query2.Fields->Set("program_start_time", DbValue::FromTimestamp(Application::GetStartTime()));
|
||||
query2.Fields->Set("is_currently_running", 1);
|
||||
query2.Fields->Set("process_id", Utility::GetPid());
|
||||
query2.Fields->Set("daemon_mode", 1);
|
||||
|
@ -122,95 +114,95 @@ void DbConnection::CleanUpHandler(void)
|
|||
{
|
||||
long now = static_cast<long>(Utility::GetTime());
|
||||
|
||||
if (GetCleanUpAcknowledgementsAge() > 0) {
|
||||
CleanUpExecuteQuery("acknowledgements", "entry_time", now - GetCleanUpAcknowledgementsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpAcknowledgementsAge: " + Convert::ToString(GetCleanUpAcknowledgementsAge()) +
|
||||
if (GetCleanupAcknowledgementsAge() > 0) {
|
||||
CleanUpExecuteQuery("acknowledgements", "entry_time", now - GetCleanupAcknowledgementsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupAcknowledgementsAge: " + Convert::ToString(GetCleanupAcknowledgementsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpAcknowledgementsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupAcknowledgementsAge()));
|
||||
}
|
||||
if (GetCleanUpCommentHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("commenthistory", "entry_time", now - GetCleanUpCommentHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpCommentHistoryAge: " + Convert::ToString(GetCleanUpCommentHistoryAge()) +
|
||||
if (GetCleanupCommentHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("commenthistory", "entry_time", now - GetCleanupCommentHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupCommentHistoryAge: " + Convert::ToString(GetCleanupCommentHistoryAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpCommentHistoryAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupCommentHistoryAge()));
|
||||
}
|
||||
if (GetCleanUpContactNotificationsAge() > 0) {
|
||||
CleanUpExecuteQuery("contactnotifications", "start_time", now - GetCleanUpContactNotificationsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpContactNotificationsAge: " + Convert::ToString(GetCleanUpContactNotificationsAge()) +
|
||||
if (GetCleanupContactNotificationsAge() > 0) {
|
||||
CleanUpExecuteQuery("contactnotifications", "start_time", now - GetCleanupContactNotificationsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupContactNotificationsAge: " + Convert::ToString(GetCleanupContactNotificationsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpContactNotificationsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupContactNotificationsAge()));
|
||||
}
|
||||
if (GetCleanUpContactNotificationMethodsAge() > 0) {
|
||||
CleanUpExecuteQuery("contactnotificationmethods", "start_time", now - GetCleanUpContactNotificationMethodsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpContactNotificationMethodsAge: " + Convert::ToString(GetCleanUpContactNotificationMethodsAge()) +
|
||||
if (GetCleanupContactNotificationMethodsAge() > 0) {
|
||||
CleanUpExecuteQuery("contactnotificationmethods", "start_time", now - GetCleanupContactNotificationMethodsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupContactNotificationMethodsAge: " + Convert::ToString(GetCleanupContactNotificationMethodsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpContactNotificationMethodsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupContactNotificationMethodsAge()));
|
||||
}
|
||||
if (GetCleanUpDowntimeHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("downtimehistory", "entry_time", now - GetCleanUpDowntimeHistoryAge());
|
||||
Log(LogDebug, "db_ido", "CleanUpDowntimeHistoryAge: " + Convert::ToString(GetCleanUpDowntimeHistoryAge()) +
|
||||
if (GetCleanupDowntimeHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("downtimehistory", "entry_time", now - GetCleanupDowntimeHistoryAge());
|
||||
Log(LogDebug, "db_ido", "CleanUpDowntimeHistoryAge: " + Convert::ToString(GetCleanupDowntimeHistoryAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpDowntimeHistoryAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupDowntimeHistoryAge()));
|
||||
}
|
||||
if (GetCleanUpEventHandlersAge() > 0) {
|
||||
CleanUpExecuteQuery("eventhandlers", "start_time", now - GetCleanUpEventHandlersAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpEventHandlersAge: " + Convert::ToString(GetCleanUpEventHandlersAge()) +
|
||||
if (GetCleanupEventHandlersAge() > 0) {
|
||||
CleanUpExecuteQuery("eventhandlers", "start_time", now - GetCleanupEventHandlersAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupEventHandlersAge: " + Convert::ToString(GetCleanupEventHandlersAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpEventHandlersAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupEventHandlersAge()));
|
||||
}
|
||||
if (GetCleanUpExternalCommandsAge() > 0) {
|
||||
CleanUpExecuteQuery("externalcommands", "entry_time", now - GetCleanUpExternalCommandsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpExternalCommandsAge: " + Convert::ToString(GetCleanUpExternalCommandsAge()) +
|
||||
if (GetCleanupExternalCommandsAge() > 0) {
|
||||
CleanUpExecuteQuery("externalcommands", "entry_time", now - GetCleanupExternalCommandsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupExternalCommandsAge: " + Convert::ToString(GetCleanupExternalCommandsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpExternalCommandsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupExternalCommandsAge()));
|
||||
}
|
||||
if (GetCleanUpFlappingHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("flappinghistory", "event_time", now - GetCleanUpFlappingHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpFlappingHistoryAge: " + Convert::ToString(GetCleanUpFlappingHistoryAge()) +
|
||||
if (GetCleanupFlappingHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("flappinghistory", "event_time", now - GetCleanupFlappingHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupFlappingHistoryAge: " + Convert::ToString(GetCleanupFlappingHistoryAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpFlappingHistoryAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupFlappingHistoryAge()));
|
||||
}
|
||||
if (GetCleanUpHostChecksAge() > 0) {
|
||||
CleanUpExecuteQuery("hostchecks", "start_time", now - GetCleanUpHostChecksAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpHostChecksAge: " + Convert::ToString(GetCleanUpHostChecksAge()) +
|
||||
if (GetCleanupHostChecksAge() > 0) {
|
||||
CleanUpExecuteQuery("hostchecks", "start_time", now - GetCleanupHostChecksAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupHostChecksAge: " + Convert::ToString(GetCleanupHostChecksAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpHostChecksAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupHostChecksAge()));
|
||||
}
|
||||
if (GetCleanUpLogEntriesAge() > 0) {
|
||||
CleanUpExecuteQuery("logentries", "logentry_time", now - GetCleanUpLogEntriesAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpLogEntriesAge: " + Convert::ToString(GetCleanUpLogEntriesAge()) +
|
||||
if (GetCleanupLogEntriesAge() > 0) {
|
||||
CleanUpExecuteQuery("logentries", "logentry_time", now - GetCleanupLogEntriesAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupLogEntriesAge: " + Convert::ToString(GetCleanupLogEntriesAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpLogEntriesAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupLogEntriesAge()));
|
||||
}
|
||||
if (GetCleanUpNotificationsAge() > 0) {
|
||||
CleanUpExecuteQuery("notifications", "start_time", now - GetCleanUpNotificationsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpNotificationsAge: " + Convert::ToString(GetCleanUpNotificationsAge()) +
|
||||
if (GetCleanupNotificationsAge() > 0) {
|
||||
CleanUpExecuteQuery("notifications", "start_time", now - GetCleanupNotificationsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupNotificationsAge: " + Convert::ToString(GetCleanupNotificationsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpNotificationsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupNotificationsAge()));
|
||||
}
|
||||
if (GetCleanUpProcessEventsAge() > 0) {
|
||||
CleanUpExecuteQuery("processevents", "event_time", now - GetCleanUpProcessEventsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpProcessEventsAge: " + Convert::ToString(GetCleanUpProcessEventsAge()) +
|
||||
if (GetCleanupProcessEventsAge() > 0) {
|
||||
CleanUpExecuteQuery("processevents", "event_time", now - GetCleanupProcessEventsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupProcessEventsAge: " + Convert::ToString(GetCleanupProcessEventsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpProcessEventsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupProcessEventsAge()));
|
||||
}
|
||||
if (GetCleanUpStateHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("statehistory", "state_time", now - GetCleanUpStateHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpStateHistoryAge: " + Convert::ToString(GetCleanUpStateHistoryAge()) +
|
||||
if (GetCleanupStateHistoryAge() > 0) {
|
||||
CleanUpExecuteQuery("statehistory", "state_time", now - GetCleanupStateHistoryAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupStateHistoryAge: " + Convert::ToString(GetCleanupStateHistoryAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpStateHistoryAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupStateHistoryAge()));
|
||||
}
|
||||
if (GetCleanUpServiceChecksAge() > 0) {
|
||||
CleanUpExecuteQuery("servicechecks", "start_time", now - GetCleanUpServiceChecksAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpServiceChecksAge: " + Convert::ToString(GetCleanUpServiceChecksAge()) +
|
||||
if (GetCleanupServiceChecksAge() > 0) {
|
||||
CleanUpExecuteQuery("servicechecks", "start_time", now - GetCleanupServiceChecksAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupServiceChecksAge: " + Convert::ToString(GetCleanupServiceChecksAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpServiceChecksAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupServiceChecksAge()));
|
||||
}
|
||||
if (GetCleanUpSystemCommandsAge() > 0) {
|
||||
CleanUpExecuteQuery("systemcommands", "start_time", now - GetCleanUpSystemCommandsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanUpSystemCommandsAge: " + Convert::ToString(GetCleanUpSystemCommandsAge()) +
|
||||
if (GetCleanupSystemCommandsAge() > 0) {
|
||||
CleanUpExecuteQuery("systemcommands", "start_time", now - GetCleanupSystemCommandsAge());
|
||||
Log(LogDebug, "db_ido", "GetCleanupSystemCommandsAge: " + Convert::ToString(GetCleanupSystemCommandsAge()) +
|
||||
" now: " + Convert::ToString(now) +
|
||||
" old: " + Convert::ToString(now - GetCleanUpSystemCommandsAge()));
|
||||
" old: " + Convert::ToString(now - GetCleanupSystemCommandsAge()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,162 +211,79 @@ void DbConnection::CleanUpExecuteQuery(const String& table, const String& time_k
|
|||
/* Default handler does nothing. */
|
||||
}
|
||||
|
||||
Dictionary::Ptr DbConnection::GetCleanUp(void) const
|
||||
double DbConnection::GetCleanupAcknowledgementsAge(void) const
|
||||
{
|
||||
if (!m_CleanUp)
|
||||
return Empty;
|
||||
else
|
||||
return m_CleanUp;
|
||||
return GetCleanup()->Get("acknowledgement_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpAcknowledgementsAge(void) const
|
||||
double DbConnection::GetCleanupCommentHistoryAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("acknowledgement_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("acknowledgement_age");
|
||||
return GetCleanup()->Get("commenthistory_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpCommentHistoryAge(void) const
|
||||
double DbConnection::GetCleanupContactNotificationsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("commenthistory_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("commenthistory_age");
|
||||
return GetCleanup()->Get("contactnotifications_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpContactNotificationsAge(void) const
|
||||
double DbConnection::GetCleanupContactNotificationMethodsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("contactnotifications_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("contactnotifications_age");
|
||||
return GetCleanup()->Get("contactnotificationmethods_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpContactNotificationMethodsAge(void) const
|
||||
double DbConnection::GetCleanupDowntimeHistoryAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("contactnotificationmethods_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("contactnotificationmethods_age");
|
||||
return GetCleanup()->Get("downtimehistory_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpDowntimeHistoryAge(void) const
|
||||
double DbConnection::GetCleanupEventHandlersAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("downtimehistory_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("downtimehistory_age");
|
||||
return GetCleanup()->Get("eventhandlers_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpEventHandlersAge(void) const
|
||||
double DbConnection::GetCleanupExternalCommandsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("eventhandlers_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("eventhandlers_age");
|
||||
return GetCleanup()->Get("externalcommands_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpExternalCommandsAge(void) const
|
||||
double DbConnection::GetCleanupFlappingHistoryAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("externalcommands_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("externalcommands_age");
|
||||
return GetCleanup()->Get("flappinghistory_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpFlappingHistoryAge(void) const
|
||||
double DbConnection::GetCleanupHostChecksAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("flappinghistory_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("flappinghistory_age");
|
||||
return GetCleanup()->Get("hostchecks_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpHostChecksAge(void) const
|
||||
double DbConnection::GetCleanupLogEntriesAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("hostchecks_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("hostchecks_age");
|
||||
return GetCleanup()->Get("logentries_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpLogEntriesAge(void) const
|
||||
double DbConnection::GetCleanupNotificationsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("logentries_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("logentries_age");
|
||||
return GetCleanup()->Get("notifications_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpNotificationsAge(void) const
|
||||
double DbConnection::GetCleanupProcessEventsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("notifications_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("notifications_age");
|
||||
return GetCleanup()->Get("processevents_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpProcessEventsAge(void) const
|
||||
double DbConnection::GetCleanupStateHistoryAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("processevents_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("processevents_age");
|
||||
return GetCleanup()->Get("statehistory_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpStateHistoryAge(void) const
|
||||
double DbConnection::GetCleanupServiceChecksAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("statehistory_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("statehistory_age");
|
||||
return GetCleanup()->Get("servicechecks_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpServiceChecksAge(void) const
|
||||
double DbConnection::GetCleanupSystemCommandsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("servicechecks_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("servicechecks_age");
|
||||
}
|
||||
|
||||
Value DbConnection::GetCleanUpSystemCommandsAge(void) const
|
||||
{
|
||||
Dictionary::Ptr cleanup = GetCleanUp();
|
||||
|
||||
if (!cleanup || cleanup->Get("systemcommands_age").IsEmpty())
|
||||
return CleanUpAgeNone;
|
||||
else
|
||||
return cleanup->Get("systemcommands_age");
|
||||
return GetCleanup()->Get("systemcommands_age");
|
||||
}
|
||||
|
||||
void DbConnection::SetObjectID(const DbObject::Ptr& dbobj, const DbReference& dbref)
|
||||
|
@ -463,23 +372,3 @@ void DbConnection::UpdateAllObjects(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DbConnection::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("table_prefix", m_TablePrefix);
|
||||
bag->Set("cleanup", m_CleanUp);
|
||||
}
|
||||
}
|
||||
|
||||
void DbConnection::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_TablePrefix = bag->Get("table_prefix");
|
||||
m_CleanUp = bag->Get("cleanup");
|
||||
}
|
||||
}
|
|
@ -20,28 +20,20 @@
|
|||
#ifndef DBCONNECTION_H
|
||||
#define DBCONNECTION_H
|
||||
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/timer.h"
|
||||
#include "db_ido/dbconnection.th"
|
||||
#include "db_ido/dbobject.h"
|
||||
#include "db_ido/dbquery.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
enum CleanUpAge
|
||||
{
|
||||
CleanUpAgeNone = 0,
|
||||
CleanUpAgeOneMonth = 44640,
|
||||
CleanUpAgeOneMeek = 10080,
|
||||
CleanUpAgeOneDay = 1440,
|
||||
};
|
||||
|
||||
/**
|
||||
* A database connection.
|
||||
*
|
||||
* @ingroup db_ido
|
||||
*/
|
||||
class DbConnection : public DynamicObject
|
||||
class DbConnection : public ReflectionObjectImpl<DbConnection>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(DbConnection);
|
||||
|
@ -60,49 +52,41 @@ public:
|
|||
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
||||
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
||||
|
||||
String GetTablePrefix(void) const;
|
||||
Dictionary::Ptr GetCleanUp(void) const;
|
||||
Value GetCleanUpAcknowledgementsAge(void) const;
|
||||
Value GetCleanUpCommentHistoryAge(void) const;
|
||||
Value GetCleanUpContactNotificationsAge(void) const;
|
||||
Value GetCleanUpContactNotificationMethodsAge(void) const;
|
||||
Value GetCleanUpDowntimeHistoryAge(void) const;
|
||||
Value GetCleanUpEventHandlersAge(void) const;
|
||||
Value GetCleanUpExternalCommandsAge(void) const;
|
||||
Value GetCleanUpFlappingHistoryAge(void) const;
|
||||
Value GetCleanUpHostChecksAge(void) const;
|
||||
Value GetCleanUpLogEntriesAge(void) const;
|
||||
Value GetCleanUpNotificationsAge(void) const;
|
||||
Value GetCleanUpProcessEventsAge(void) const;
|
||||
Value GetCleanUpStateHistoryAge(void) const;
|
||||
Value GetCleanUpServiceChecksAge(void) const;
|
||||
Value GetCleanUpSystemCommandsAge(void) const;
|
||||
double GetCleanupAcknowledgementsAge(void) const;
|
||||
double GetCleanupCommentHistoryAge(void) const;
|
||||
double GetCleanupContactNotificationsAge(void) const;
|
||||
double GetCleanupContactNotificationMethodsAge(void) const;
|
||||
double GetCleanupDowntimeHistoryAge(void) const;
|
||||
double GetCleanupEventHandlersAge(void) const;
|
||||
double GetCleanupExternalCommandsAge(void) const;
|
||||
double GetCleanupFlappingHistoryAge(void) const;
|
||||
double GetCleanupHostChecksAge(void) const;
|
||||
double GetCleanupLogEntriesAge(void) const;
|
||||
double GetCleanupNotificationsAge(void) const;
|
||||
double GetCleanupProcessEventsAge(void) const;
|
||||
double GetCleanupStateHistoryAge(void) const;
|
||||
double GetCleanupServiceChecksAge(void) const;
|
||||
double GetCleanupSystemCommandsAge(void) const;
|
||||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
virtual void ExecuteQuery(const DbQuery& query) = 0;
|
||||
virtual void ActivateObject(const DbObject::Ptr& dbobj) = 0;
|
||||
virtual void DeactivateObject(const DbObject::Ptr& dbobj) = 0;
|
||||
|
||||
virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) = 0;
|
||||
virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) = 0;
|
||||
|
||||
void UpdateAllObjects(void);
|
||||
|
||||
private:
|
||||
String m_TablePrefix;
|
||||
Dictionary::Ptr m_CleanUp;
|
||||
|
||||
std::map<DbObject::Ptr, DbReference> m_ObjectIDs;
|
||||
std::map<DbObject::Ptr, DbReference> m_InsertIDs;
|
||||
std::set<DbObject::Ptr> m_ConfigUpdates;
|
||||
std::set<DbObject::Ptr> m_StatusUpdates;
|
||||
Timer::Ptr m_CleanUpTimer;
|
||||
Timer::Ptr m_CleanUpTimer;
|
||||
|
||||
void CleanUpHandler(void);
|
||||
void CleanUpHandler(void);
|
||||
|
||||
static Timer::Ptr m_ProgramStatusTimer;
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include "base/dynamicobject.h"
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class DbConnection : DynamicObject
|
||||
{
|
||||
[config] String table_prefix {
|
||||
default {{{ return "icinga_"; }}}
|
||||
};
|
||||
|
||||
[config] Dictionary::Ptr cleanup {
|
||||
default {{{ return boost::make_shared<Dictionary>(); }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -362,9 +362,6 @@ void ServiceDbObject::AddComments(const Service::Ptr& service)
|
|||
/* dump all comments */
|
||||
Dictionary::Ptr comments = service->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return;
|
||||
|
||||
ObjectLock olock(comments);
|
||||
|
||||
String comment_id;
|
||||
|
@ -532,9 +529,6 @@ void ServiceDbObject::AddDowntimes(const Service::Ptr& service)
|
|||
/* dump all downtimes */
|
||||
Dictionary::Ptr downtimes = service->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
||||
ObjectLock olock(downtimes);
|
||||
|
||||
String downtime_id;
|
||||
|
@ -926,7 +920,7 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const D
|
|||
fields1->Set("state_change", 1); /* service */
|
||||
fields1->Set("state", service->GetState());
|
||||
fields1->Set("state_type", service->GetStateType());
|
||||
fields1->Set("current_check_attempt", service->GetCurrentCheckAttempt());
|
||||
fields1->Set("current_check_attempt", service->GetCheckAttempt());
|
||||
fields1->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||
fields1->Set("last_state", service->GetLastState());
|
||||
fields1->Set("last_hard_state", service->GetLastHardState());
|
||||
|
|
|
@ -4,37 +4,63 @@
|
|||
pkglib_LTLIBRARIES = \
|
||||
libicinga.la
|
||||
|
||||
BUILT_SOURCES = \
|
||||
checkcommand.th \
|
||||
command.th \
|
||||
domain.th \
|
||||
eventcommand.th \
|
||||
host.th \
|
||||
hostgroup.th \
|
||||
icingaapplication.th \
|
||||
notification.th \
|
||||
notificationcommand.th \
|
||||
service.th \
|
||||
servicegroup.th \
|
||||
timeperiod.th \
|
||||
user.th \
|
||||
usergroup.th
|
||||
|
||||
CLEANFILES = \
|
||||
icinga-type.cpp
|
||||
|
||||
.conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
|
||||
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
|
||||
|
||||
.ti.th: $(top_builddir)/tools/mkclass/mkclass
|
||||
$(top_builddir)/tools/mkclass/mkclass $< > $@
|
||||
|
||||
libicinga_la_SOURCES = \
|
||||
api.cpp \
|
||||
api.h \
|
||||
checkcommand.cpp \
|
||||
checkcommand.h \
|
||||
checkcommand.ti \
|
||||
cib.cpp \
|
||||
cib.h \
|
||||
command.cpp \
|
||||
command.h \
|
||||
command.ti \
|
||||
compatutility.cpp \
|
||||
compatutility.h \
|
||||
domain.cpp \
|
||||
domain.h \
|
||||
domain.ti \
|
||||
eventcommand.cpp \
|
||||
eventcommand.h \
|
||||
eventcommand.ti \
|
||||
externalcommandprocessor.cpp \
|
||||
externalcommandprocessor.h \
|
||||
host.cpp \
|
||||
host.h \
|
||||
host.ti \
|
||||
hostgroup.cpp \
|
||||
hostgroup.h \
|
||||
host.h \
|
||||
hostgroup.ti \
|
||||
i2-icinga.h \
|
||||
icinga-type.conf \
|
||||
icingaapplication.cpp \
|
||||
icingaapplication.h \
|
||||
icingaapplication.ti \
|
||||
legacytimeperiod.cpp \
|
||||
legacytimeperiod.h \
|
||||
macroprocessor.cpp \
|
||||
|
@ -43,8 +69,10 @@ libicinga_la_SOURCES = \
|
|||
macroresolver.h \
|
||||
notification.cpp \
|
||||
notification.h \
|
||||
notification.ti \
|
||||
notificationcommand.cpp \
|
||||
notificationcommand.h \
|
||||
notificationcommand.ti \
|
||||
nullchecktask.cpp \
|
||||
nullchecktask.h \
|
||||
nulleventtask.cpp \
|
||||
|
@ -58,21 +86,26 @@ libicinga_la_SOURCES = \
|
|||
randomchecktask.cpp \
|
||||
randomchecktask.h \
|
||||
service.cpp \
|
||||
service.h \
|
||||
service.ti \
|
||||
service-check.cpp \
|
||||
service-comment.cpp \
|
||||
service-downtime.cpp \
|
||||
service-event.cpp \
|
||||
service-flapping.cpp \
|
||||
service-notification.cpp \
|
||||
service.h \
|
||||
servicegroup.cpp \
|
||||
servicegroup.h \
|
||||
servicegroup.ti \
|
||||
timeperiod.cpp \
|
||||
timeperiod.h \
|
||||
timeperiod.ti \
|
||||
user.cpp \
|
||||
user.h \
|
||||
user.ti \
|
||||
usergroup.cpp \
|
||||
usergroup.h
|
||||
usergroup.h \
|
||||
usergroup.ti
|
||||
|
||||
libicinga_la_CPPFLAGS = \
|
||||
-DI2_ICINGA_BUILD \
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef CHECKCOMMAND_H
|
||||
#define CHECKCOMMAND_H
|
||||
|
||||
#include "icinga/command.h"
|
||||
#include "icinga/checkcommand.th"
|
||||
#include "icinga/service.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API CheckCommand : public Command
|
||||
class I2_ICINGA_API CheckCommand : public ReflectionObjectImpl<CheckCommand>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "icinga/command.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class CheckCommand : Command
|
||||
{
|
||||
};
|
||||
|
||||
}
|
|
@ -21,34 +21,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
Value Command::GetCommandLine(void) const
|
||||
{
|
||||
return m_CommandLine;
|
||||
}
|
||||
|
||||
double Command::GetTimeout(void) const
|
||||
{
|
||||
if (m_Timeout.IsEmpty())
|
||||
return 300;
|
||||
else
|
||||
return m_Timeout;
|
||||
}
|
||||
|
||||
Dictionary::Ptr Command::GetMacros(void) const
|
||||
{
|
||||
return m_Macros;
|
||||
}
|
||||
|
||||
Array::Ptr Command::GetExportMacros(void) const
|
||||
{
|
||||
return m_ExportMacros;
|
||||
}
|
||||
|
||||
Array::Ptr Command::GetEscapeMacros(void) const
|
||||
{
|
||||
return m_EscapeMacros;
|
||||
}
|
||||
|
||||
bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
||||
{
|
||||
Dictionary::Ptr macros = GetMacros();
|
||||
|
@ -60,30 +32,3 @@ bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Command::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("command", m_CommandLine);
|
||||
bag->Set("timeout", m_Timeout);
|
||||
bag->Set("macros", m_Macros);
|
||||
bag->Set("export_macros", m_ExportMacros);
|
||||
bag->Set("escape_macros", m_EscapeMacros);
|
||||
}
|
||||
}
|
||||
|
||||
void Command::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_CommandLine = bag->Get("command");
|
||||
m_Timeout = bag->Get("timeout");
|
||||
m_Macros = bag->Get("macros");
|
||||
m_Macros = bag->Get("macros");
|
||||
m_ExportMacros = bag->Get("export_macros");
|
||||
m_EscapeMacros = bag->Get("escape_macros");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#include "icinga/command.th"
|
||||
#include "icinga/macroresolver.h"
|
||||
#include "base/i2-base.h"
|
||||
#include "base/array.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "base/logger_fwd.h"
|
||||
#include <set>
|
||||
|
||||
|
@ -35,31 +35,14 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API Command : public DynamicObject, public MacroResolver
|
||||
class I2_ICINGA_API Command : public ReflectionObjectImpl<Command>, public MacroResolver
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Command);
|
||||
|
||||
//virtual Dictionary::Ptr Execute(const Object::Ptr& context) = 0;
|
||||
|
||||
Value GetCommandLine(void) const;
|
||||
double GetTimeout(void) const;
|
||||
|
||||
Dictionary::Ptr GetMacros(void) const;
|
||||
Array::Ptr GetExportMacros(void) const;
|
||||
Array::Ptr GetEscapeMacros(void) const;
|
||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
Value m_CommandLine;
|
||||
Value m_Timeout;
|
||||
Dictionary::Ptr m_Macros;
|
||||
Array::Ptr m_ExportMacros;
|
||||
Array::Ptr m_EscapeMacros;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Command : DynamicObject
|
||||
{
|
||||
[config] Value command_line;
|
||||
[config] Value timeout {
|
||||
default {{{ return 300; }}}
|
||||
};
|
||||
[config] Dictionary::Ptr macros;
|
||||
[config] Array::Ptr export_macros;
|
||||
[config] Array::Ptr escape_macros;
|
||||
};
|
||||
|
||||
}
|
|
@ -263,7 +263,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
|
|||
attr->Set("check_type", (service->GetEnableActiveChecks() ? 0 : 1));
|
||||
attr->Set("last_check", schedule_end);
|
||||
attr->Set("next_check", service->GetNextCheck());
|
||||
attr->Set("current_attempt", service->GetCurrentCheckAttempt());
|
||||
attr->Set("current_attempt", service->GetCheckAttempt());
|
||||
attr->Set("max_attempts", service->GetMaxCheckAttempts());
|
||||
attr->Set("last_state_change", service->GetLastStateChange());
|
||||
attr->Set("last_hard_state_change", service->GetLastHardStateChange());
|
||||
|
@ -393,7 +393,7 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
|
|||
attr->Set("high_flap_threshold", service->GetFlappingThreshold());
|
||||
attr->Set("notifications_enabled", (service->GetEnableNotifications() ? 1 : 0));
|
||||
attr->Set("eventhandler_enabled", 1); /* always 1 */
|
||||
attr->Set("is_volatile", (service->IsVolatile() ? 1 : 0));
|
||||
attr->Set("is_volatile", (service->GetVolatile() ? 1 : 0));
|
||||
attr->Set("notifications_enabled", (service->GetEnableNotifications() ? 1 : 0));
|
||||
attr->Set("notification_options", boost::algorithm::join(notification_options, ","));
|
||||
attr->Set("notification_interval", notification_interval / 60.0);
|
||||
|
|
|
@ -24,30 +24,7 @@ using namespace icinga;
|
|||
|
||||
REGISTER_TYPE(Domain);
|
||||
|
||||
Dictionary::Ptr Domain::GetAcl(void) const
|
||||
{
|
||||
return m_Acl;
|
||||
}
|
||||
|
||||
int Domain::GetPrivileges(const String& instance) const
|
||||
{
|
||||
return m_Acl->Get(instance);
|
||||
}
|
||||
|
||||
void Domain::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||
{
|
||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
bag->Set("acl", m_Acl);
|
||||
}
|
||||
}
|
||||
|
||||
void Domain::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||
{
|
||||
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||
|
||||
if (attributeTypes & Attribute_Config) {
|
||||
m_Acl = bag->Get("acl");
|
||||
}
|
||||
return GetAcl()->Get(instance);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define DOMAIN_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "icinga/domain.th"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -32,21 +32,13 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API Domain : public DynamicObject
|
||||
class I2_ICINGA_API Domain : public ReflectionObjectImpl<Domain>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Domain);
|
||||
DECLARE_TYPENAME(Domain);
|
||||
|
||||
Dictionary::Ptr GetAcl(void) const;
|
||||
int GetPrivileges(const String& instance) const;
|
||||
|
||||
protected:
|
||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||
|
||||
private:
|
||||
Dictionary::Ptr m_Acl;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "base/dynamicobject.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class Domain : DynamicObject
|
||||
{
|
||||
[config] Dictionary::Ptr acl;
|
||||
};
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef EVENTCOMMAND_H
|
||||
#define EVENTCOMMAND_H
|
||||
|
||||
#include "icinga/command.h"
|
||||
#include "icinga/eventcommand.th"
|
||||
#include "icinga/service.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API EventCommand : public Command
|
||||
class I2_ICINGA_API EventCommand : public ReflectionObjectImpl<EventCommand>
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(EventCommand);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "icinga/command.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class EventCommand : Command
|
||||
{
|
||||
};
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue