set(base_SOURCES
application.cpp application.thpp array.cpp configerror.cpp console.cpp context.cpp
convert.cpp debuginfo.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
- exception.cpp fifo.cpp filelogger.cpp filelogger.thpp json.cpp logger.cpp logger.thpp
+ exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp logger.cpp logger.thpp
netstring.cpp networkstream.cpp object.cpp objectlock.cpp primitivetype.cpp process.cpp
ringbuffer.cpp scriptfunction.cpp scriptfunctionwrapper.cpp
scriptutils.cpp scriptvariable.cpp serializer.cpp socket.cpp stacktrace.cpp
REGISTER_TYPE(Application);
boost::signals2::signal<void (void)> Application::OnReopenLogs;
-Application *Application::m_Instance = NULL;
+Application::Ptr Application::m_Instance = NULL;
bool Application::m_ShuttingDown = false;
bool Application::m_RequestRestart = false;
bool Application::m_RequestReopenLogs = false;
*/
Application::Ptr Application::GetInstance(void)
{
- if (!m_Instance)
- return Application::Ptr();
-
- return m_Instance->GetSelf();
+ return m_Instance;
}
void Application::SetResourceLimits(void)
Log(LogInformation, "Application", "Got reload command: Starting new instance.");
// prepare arguments
- Array::Ptr args = make_shared<Array>();
+ Array::Ptr args = new Array();
args->Add(GetExePath(m_ArgV[0]));
for (int i=1; i < Application::GetArgC(); i++) {
args->Add("--reload-internal");
args->Add(Convert::ToString(Utility::GetPid()));
- Process::Ptr process = make_shared<Process>(Process::PrepareCommand(args));
+ Process::Ptr process = new Process(Process::PrepareCommand(args));
process->SetTimeout(300);
process->Run(&ReloadProcessCallback);
virtual void OnShutdown(void);
private:
- static Application *m_Instance; /**< The application instance. */
+ static Application::Ptr m_Instance; /**< The application instance. */
static bool m_ShuttingDown; /**< Whether the application is in the process of
shutting down. */
*/
Array::Ptr Array::ShallowClone(void) const
{
- Array::Ptr clone = make_shared<Array>();
+ Array::Ptr clone = new Array();
CopyTo(clone);
return clone;
}
Array::Ptr icinga::MakeArray(const Value& val1)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
result->Add(val1);
return result;
}
Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
result->Add(val1);
result->Add(val2);
return result;
Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2, const Value& val3)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
result->Add(val1);
result->Add(val2);
result->Add(val3);
Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2, const Value& val3, const Value& val4)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
result->Add(val1);
result->Add(val2);
result->Add(val3);
int m_Color;
};
+I2_BASE_API std::ostream& operator<<(std::ostream& fp, const ConsoleColorTag& cct);
+
/**
* Console utilities.
*
*/
Dictionary::Ptr Dictionary::ShallowClone(void) const
{
- Dictionary::Ptr clone = make_shared<Dictionary>();
+ Dictionary::Ptr clone = new Dictionary();
CopyTo(clone);
return clone;
}
Dictionary::Ptr extensions = GetExtensions();
if (!extensions) {
- extensions = make_shared<Dictionary>();
+ extensions = new Dictionary();
SetExtensions(extensions);
}
ASSERT(!OwnsLock());
DynamicType::Ptr dtype = GetType();
- dtype->RegisterObject(GetSelf());
+ dtype->RegisterObject(this);
}
void DynamicObject::Start(void)
SetActive(true);
}
- OnStarted(GetSelf());
+ OnStarted(this);
SetAuthority(true);
}
ASSERT(GetStopCalled());
- OnStopped(GetSelf());
+ OnStopped(this);
}
void DynamicObject::OnConfigLoaded(void)
Resume();
ASSERT(GetResumeCalled());
SetPaused(false);
- OnResumed(GetSelf());
+ OnResumed(this);
} else if (!authority && !GetPaused()) {
SetPauseCalled(false);
Pause();
ASSERT(GetPauseCalled());
SetPaused(true);
- OnPaused(GetSelf());
+ OnPaused(this);
}
}
if (!fp)
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open '" + tempFilename + "' file"));
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream(&fp, false);
BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) {
BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) {
- Dictionary::Ptr persistentObject = make_shared<Dictionary>();
+ Dictionary::Ptr persistentObject = new Dictionary();
persistentObject->Set("type", type->GetName());
persistentObject->Set("name", object->GetName());
std::fstream fp;
fp.open(filename.CStr(), std::ios_base::in);
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream (&fp, false);
unsigned long restored = 0;
Value InvokeMethod(const String& method, const std::vector<Value>& arguments);
- shared_ptr<DynamicType> GetType(void) const;
+ intrusive_ptr<DynamicType> GetType(void) const;
DebugInfo GetDebugInfo(void) const;
void SetDebugInfo(const DebugInfo& di);
virtual void OnStateLoaded(void);
template<typename T>
- static shared_ptr<T> GetObject(const String& name)
+ static intrusive_ptr<T> GetObject(const String& name)
{
DynamicObject::Ptr object = GetObject(T::GetTypeName(), name);
DebugInfo m_DebugInfo;
};
-#define DECLARE_OBJECTNAME(klass) \
- inline static String GetTypeName(void) \
- { \
- return #klass; \
- } \
- \
- inline static shared_ptr<klass> GetByName(const String& name) \
- { \
- return DynamicObject::GetObject<klass>(name); \
+#define DECLARE_OBJECTNAME(klass) \
+ inline static String GetTypeName(void) \
+ { \
+ return #klass; \
+ } \
+ \
+ inline static intrusive_ptr<klass> GetByName(const String& name) \
+ { \
+ return DynamicObject::GetObject<klass>(name); \
}
}
|| type->IsAbstract())
return DynamicType::Ptr();
- DynamicType::Ptr dtype = make_shared<DynamicType>(name);
+ DynamicType::Ptr dtype = new DynamicType(name);
InternalGetTypeMap()[type->GetName()] = dtype;
InternalGetTypeVector().push_back(dtype);
std::pair<DynamicTypeIterator<DynamicObject>, DynamicTypeIterator<DynamicObject> > DynamicType::GetObjects(void)
{
return std::make_pair(
- DynamicTypeIterator<DynamicObject>(GetSelf(), 0),
- DynamicTypeIterator<DynamicObject>(GetSelf(), -1)
+ DynamicTypeIterator<DynamicObject>(this, 0),
+ DynamicTypeIterator<DynamicObject>(this, -1)
);
}
};
template<typename T>
-class DynamicTypeIterator : public boost::iterator_facade<DynamicTypeIterator<T>, const shared_ptr<T>, boost::forward_traversal_tag>
+class DynamicTypeIterator : public boost::iterator_facade<DynamicTypeIterator<T>, const intrusive_ptr<T>, boost::forward_traversal_tag>
{
public:
DynamicTypeIterator(const DynamicType::Ptr& type, int index)
DynamicType::Ptr m_Type;
DynamicType::ObjectVector::size_type m_Index;
- mutable shared_ptr<T> m_Current;
+ mutable intrusive_ptr<T> m_Current;
void increment(void)
{
return (other.m_Index == m_Index);
}
- const shared_ptr<T>& dereference(void) const
+ const intrusive_ptr<T>& dereference(void) const
{
ObjectLock olock(m_Type);
m_Current = static_pointer_cast<T>(*(m_Type->m_ObjectVector.begin() + m_Index));
Value FileLogger::StatsFunc(Dictionary::Ptr& status, Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const FileLogger::Ptr& filelogger, DynamicType::GetObjectsByType<FileLogger>()) {
nodes->Set(filelogger->GetName(), 1); //add more stats
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2014 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/initialize.hpp"
+#include "base/utility.hpp"
+
+using namespace icinga;
+
+bool icinga::InitializeOnceHelper(void (*func)(void))
+{
+ Utility::AddDeferredInitializer(func);
+ return true;
+}
+
#define INITIALIZE_H
#include "base/i2-base.hpp"
-#include "base/utility.hpp"
namespace icinga
{
-typedef void (*InitializeFunc)(void);
+I2_BASE_API bool InitializeOnceHelper(void (*func)(void));
-inline bool InitializeOnceHelper(InitializeFunc func)
-{
- Utility::AddDeferredInitializer(func);
- return true;
-}
-
-#define INITIALIZE_ONCE(func) \
- namespace { namespace UNIQUE_NAME(io) { \
- I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
+#define INITIALIZE_ONCE(func) \
+ namespace { namespace UNIQUE_NAME(io) { \
+ I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
} }
}
JsonContext *context = static_cast<JsonContext *>(ctx);
try {
- context->Push(make_shared<Dictionary>());
+ context->Push(new Dictionary());
} catch (...) {
context->SaveException();
return 0;
JsonContext *context = static_cast<JsonContext *>(ctx);
try {
- context->Push(make_shared<Array>());
+ context->Push(new Array());
} catch (...) {
context->SaveException();
return 0;
DynamicObject::Start();
boost::mutex::scoped_lock lock(m_Mutex);
- m_Loggers.insert(GetSelf());
+ m_Loggers.insert(this);
}
void Logger::Stop(void)
{
boost::mutex::scoped_lock lock(m_Mutex);
- m_Loggers.erase(GetSelf());
+ m_Loggers.erase(this);
}
std::set<Logger::Ptr> Logger::GetLoggers(void)
* Default constructor for the Object class.
*/
Object::Object(void)
+ : m_References(0)
#ifdef _DEBUG
- : m_Locked(false)
+ , m_Locked(false)
#endif /* _DEBUG */
{ }
Object::~Object(void)
{ }
-/**
- * Returns a reference-counted pointer to this object.
- *
- * @returns A shared_ptr object that points to this object
- */
-Object::SharedPtrHolder Object::GetSelf(void)
-{
- return Object::SharedPtrHolder(shared_from_this());
-}
-
#ifdef _DEBUG
/**
* Checks if the calling thread owns the lock on this object.
}
#endif /* _DEBUG */
-Object::SharedPtrHolder::operator Value(void) const
-{
- return m_Object;
-}
-
void Object::SetField(int, const Value&)
{
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
#include <boost/thread/recursive_mutex.hpp>
#endif /* _DEBUG */
-#ifndef _MSC_VER
-#include <boost/smart_ptr/shared_ptr.hpp>
-#include <boost/smart_ptr/weak_ptr.hpp>
-#include <boost/smart_ptr/enable_shared_from_this.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-using boost::shared_ptr;
-using boost::weak_ptr;
-using boost::enable_shared_from_this;
+#include <boost/smart_ptr/intrusive_ptr.hpp>
+
+using boost::intrusive_ptr;
using boost::dynamic_pointer_cast;
using boost::static_pointer_cast;
-using boost::make_shared;
-#else /* _MSC_VER */
-#include <memory>
-
-using std::shared_ptr;
-using std::weak_ptr;
-using std::enable_shared_from_this;
-using std::dynamic_pointer_cast;
-using std::static_pointer_cast;
-using std::make_shared;
-#endif /* _MSC_VER */
#include <boost/tuple/tuple.hpp>
using boost::tie;
class Type;
#define DECLARE_PTR_TYPEDEFS(klass) \
- typedef shared_ptr<klass> Ptr; \
- typedef weak_ptr<klass> WeakPtr
-
-#define IMPL_TYPE_LOOKUP(klass) \
- static shared_ptr<Type> TypeInstance; \
- inline virtual shared_ptr<Type> GetReflectionType(void) const \
- { \
- return TypeInstance; \
+ typedef intrusive_ptr<klass> Ptr
+
+#define IMPL_TYPE_LOOKUP(klass) \
+ static intrusive_ptr<Type> TypeInstance; \
+ virtual intrusive_ptr<Type> GetReflectionType(void) const \
+ { \
+ return TypeInstance; \
}
#define DECLARE_OBJECT(klass) \
IMPL_TYPE_LOOKUP(klass);
template<typename T>
-shared_ptr<Object> DefaultObjectFactory(void)
+intrusive_ptr<Object> DefaultObjectFactory(void)
{
- return make_shared<T>();
+ return new T();
}
-typedef shared_ptr<Object> (*ObjectFactory)(void);
+typedef intrusive_ptr<Object> (*ObjectFactory)(void);
template<typename T>
struct TypeHelper
*
* @ingroup base
*/
-class I2_BASE_API Object : public enable_shared_from_this<Object>
+class I2_BASE_API Object
{
public:
DECLARE_OBJECT(Object);
virtual void SetField(int id, const Value& value);
virtual Value GetField(int id) const;
- /**
- * Holds a shared pointer and provides support for implicit upcasts.
- *
- * @ingroup base
- */
- class SharedPtrHolder
- {
- public:
- /**
- * Constructor for the SharedPtrHolder class.
- *
- * @param object The shared pointer that should be used to
- * construct this shared pointer holder.
- */
- explicit SharedPtrHolder(const Object::Ptr& object)
- : m_Object(object)
- { }
-
- /**
- * Retrieves a shared pointer for the object that is associated
- * this holder instance.
- *
- * @returns A shared pointer.
- */
- template<typename T>
- operator shared_ptr<T>(void) const
- {
-#ifdef _DEBUG
- shared_ptr<T> other = dynamic_pointer_cast<T>(m_Object);
- ASSERT(other);
-#else /* _DEBUG */
- shared_ptr<T> other = static_pointer_cast<T>(m_Object);
-#endif /* _DEBUG */
-
- return other;
- }
-
- /**
- * Retrieves a weak pointer for the object that is associated
- * with this holder instance.
- *
- * @returns A weak pointer.
- */
- template<typename T>
- operator weak_ptr<T>(void) const
- {
- return static_cast<shared_ptr<T> >(*this);
- }
-
- operator Value(void) const;
-
- private:
- Object::Ptr m_Object; /**< The object that belongs to this
- holder instance */
- };
-
#ifdef _DEBUG
bool OwnsLock(void) const;
#endif /* _DEBUG */
-protected:
- SharedPtrHolder GetSelf(void);
-
private:
Object(const Object& other);
Object& operator=(const Object& rhs);
+ uintptr_t m_References;
mutable ThinMutex m_Mutex;
#ifdef _DEBUG
#endif /* _DEBUG */
friend struct ObjectLock;
+
+ friend void intrusive_ptr_add_ref(Object *object);
+ friend void intrusive_ptr_release(Object *object);
};
-/**
- * Compares a weak pointer with a raw pointer.
- *
- * @ingroup base
- */
-template<class T>
-struct WeakPtrEqual
+inline void intrusive_ptr_add_ref(Object *object)
{
-private:
- const void *m_Ref; /**< The object. */
+#ifdef _WIN32
+ InterlockedIncrement(&object->m_References);
+#else /* _WIN32 */
+ __sync_add_and_fetch(&object->m_References, 1);
+#endif /* _WIN32 */
+}
-public:
- /**
- * Constructor for the WeakPtrEqual class.
- *
- * @param ref The object that should be compared with the weak pointer.
- */
- WeakPtrEqual(const void *ref) : m_Ref(ref) { }
-
- /**
- * Compares the two pointers.
- *
- * @param wref The weak pointer.
- * @returns true if the pointers point to the same object, false otherwise.
- */
- bool operator()(const weak_ptr<T>& wref) const
- {
- return (wref.lock().get() == static_cast<const T *>(m_Ref));
- }
-};
+inline void intrusive_ptr_release(Object *object)
+{
+ uintptr_t refs;
+#ifdef _WIN32
+ refs = InterlockedDecrement(&object->m_References);
+#else /* _WIN32 */
+ refs = __sync_sub_and_fetch(&object->m_References, 1);
+#endif /* _WIN32 */
+
+ if (refs == 0)
+ delete object;
+}
template<typename T>
class ObjectImpl
}
#endif /* OBJECT_H */
+
+#include "base/type.hpp"
String m_Name;
};
-#define REGISTER_BUILTIN_TYPE(type) \
- namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
- void RegisterPrimitiveType(void) \
- { \
- icinga::Type::Ptr t = make_shared<PrimitiveType>(#type); \
- icinga::Type::Register(t); \
- } \
- \
- INITIALIZE_ONCE(RegisterPrimitiveType); \
+#define REGISTER_BUILTIN_TYPE(type) \
+ namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
+ void RegisterPrimitiveType(void) \
+ { \
+ icinga::Type::Ptr t = new PrimitiveType(#type); \
+ icinga::Type::Register(t); \
+ } \
+ INITIALIZE_ONCE(RegisterPrimitiveType); \
} } }
#define REGISTER_PRIMITIVE_TYPE(type) \
{
boost::mutex::scoped_lock lock(l_ProcessMutex[tid]);
- l_Processes[tid][m_Process] = GetSelf();
+ l_Processes[tid][m_Process] = this;
#ifndef _WIN32
l_FDs[tid][m_FD] = m_Process;
#endif /* _WIN32 */
RegisterFunctionHelper::RegisterFunctionHelper(const String& name, const ScriptFunction::Callback& function)
{
- ScriptFunction::Register(name, make_shared<ScriptFunction>(function));
+ ScriptFunction::Register(name, new ScriptFunction(function));
}
}
}
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
BOOST_FOREACH(const Value& value, values) {
result->Add(value);
}
Array::Ptr ScriptUtils::Intersection(const std::vector<Value>& arguments)
{
if (arguments.size() == 0)
- return make_shared<Array>();
+ return new Array();
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
Array::Ptr arr1 = static_cast<Array::Ptr>(arguments[0])->ShallowClone();
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for range()"));
}
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
if ((start < end && increment <= 0) ||
(start > end && increment >= 0))
Array::Ptr ScriptUtils::Keys(const Dictionary::Ptr& dict)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
ObjectLock olock(dict);
BOOST_FOREACH(const Dictionary::Pair& kv, dict) {
ScriptVariable::Ptr sv = GetByName(name);
if (!sv) {
- sv = make_shared<ScriptVariable>(value);
+ sv = new ScriptVariable(value);
ScriptVariableRegistry::GetInstance()->Register(name, sv);
} else if (overwrite) {
if (sv->IsConstant())
if (!fp)
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open '" + tempFilename + "' file"));
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream(&fp, false);
BOOST_FOREACH(const ScriptVariableRegistry::ItemMap::value_type& kv, ScriptVariableRegistry::GetInstance()->GetItems()) {
- Dictionary::Ptr persistentVariable = make_shared<Dictionary>();
+ Dictionary::Ptr persistentVariable = new Dictionary();
persistentVariable->Set("name", kv.first);
class ScriptVariable;
-class I2_BASE_API ScriptVariableRegistry : public Registry<ScriptVariableRegistry, shared_ptr<ScriptVariable> >
+class I2_BASE_API ScriptVariableRegistry : public Registry<ScriptVariableRegistry, intrusive_ptr<ScriptVariable> >
{
public:
static ScriptVariableRegistry *GetInstance(void);
static Array::Ptr SerializeArray(const Array::Ptr& input, int attributeTypes)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
ObjectLock olock(input);
static Dictionary::Ptr SerializeDictionary(const Dictionary::Ptr& input, int attributeTypes)
{
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
ObjectLock olock(input);
VERIFY(type);
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
for (int i = 0; i < type->GetFieldCount(); i++) {
Field field = type->GetFieldInfo(i);
static Array::Ptr DeserializeArray(const Array::Ptr& input, bool safe_mode, int attributeTypes)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
ObjectLock olock(input);
static Dictionary::Ptr DeserializeDictionary(const Dictionary::Ptr& input, bool safe_mode, int attributeTypes)
{
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
ObjectLock olock(input);
#endif /* _WIN32 */
}
- return make_shared<Socket>(fd);
+ return new Socket(fd);
}
bool Socket::Poll(bool read, bool write)
RegisterStatsFunctionHelper::RegisterStatsFunctionHelper(const String& name, const StatsFunction::Callback& function)
{
- StatsFunction::Ptr func = make_shared<StatsFunction>(function);
+ StatsFunction::Ptr func = new StatsFunction(function);
StatsFunctionRegistry::GetInstance()->Register(name, func);
}
m_Stream = stream;
m_OwnsStream = ownsStream;
- m_FlushLogTimer = make_shared<Timer>();
+ m_FlushLogTimer = new Timer();
m_FlushLogTimer->SetInterval(1);
m_FlushLogTimer->OnTimerExpired.connect(boost::bind(&StreamLogger::FlushLogTimerHandler, this));
m_FlushLogTimer->Start();
Value SyslogLogger::StatsFunc(Dictionary::Ptr& status, Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const SyslogLogger::Ptr& sysloglogger, DynamicType::GetObjectsByType<SyslogLogger>()) {
nodes->Set(sysloglogger->GetName(), 1); //add more stats
static void InitThinMutex(void)
{
- l_Timer = make_shared<Timer>();
+ l_Timer = new Timer();
l_Timer->SetInterval(10);
l_Timer->OnTimerExpired.connect(boost::bind(&ThinMutex::DebugTimerHandler));
l_Timer->Start();
{
ASSERT(!OwnsLock());
- Timer::Ptr self = GetSelf();
-
try {
- OnTimerExpired(self);
+ OnTimerExpired(Timer::Ptr(this));
} catch (...) {
Reschedule();
continue;
}
+ Timer::Ptr ptimer = timer;
+
/* Remove the timer from the list so it doesn't get called again
* until the current call is completed. */
l_Timers.erase(timer);
- Timer::Ptr ptimer = timer->GetSelf();
-
lock.unlock();
/* Asynchronously call the timer. */
* @param role The role of the client.
* @param sslContext The SSL context for the client.
*/
-TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const shared_ptr<SSL_CTX>& sslContext)
+TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext)
: m_Eof(false), m_VerifyOK(true), m_Socket(socket), m_Role(role)
{
std::ostringstream msgbuf;
char errbuf[120];
- m_SSL = shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);
+ m_SSL = boost::shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);
if (!m_SSL) {
msgbuf << "SSL_new() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
*
* @returns The X509 certificate.
*/
-shared_ptr<X509> TlsStream::GetClientCertificate(void) const
+boost::shared_ptr<X509> TlsStream::GetClientCertificate(void) const
{
boost::mutex::scoped_lock lock(m_SSLLock);
- return shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter);
+ return boost::shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter);
}
/**
*
* @returns The X509 certificate.
*/
-shared_ptr<X509> TlsStream::GetPeerCertificate(void) const
+boost::shared_ptr<X509> TlsStream::GetPeerCertificate(void) const
{
boost::mutex::scoped_lock lock(m_SSLLock);
- return shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
+ return boost::shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
}
void TlsStream::Handshake(void)
public:
DECLARE_PTR_TYPEDEFS(TlsStream);
- TlsStream(const Socket::Ptr& socket, ConnectionRole role, const shared_ptr<SSL_CTX>& sslContext);
+ TlsStream(const Socket::Ptr& socket, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext);
- shared_ptr<X509> GetClientCertificate(void) const;
- shared_ptr<X509> GetPeerCertificate(void) const;
+ boost::shared_ptr<X509> GetClientCertificate(void) const;
+ boost::shared_ptr<X509> GetPeerCertificate(void) const;
void Handshake(void);
bool IsVerifyOK(void) const;
private:
- shared_ptr<SSL> m_SSL;
+ boost::shared_ptr<SSL> m_SSL;
bool m_Eof;
mutable boost::mutex m_SSLLock;
mutable boost::mutex m_IOActionLock;
* @param cakey CA certificate chain file.
* @returns An SSL context.
*/
-shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey)
+boost::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey)
{
std::ostringstream msgbuf;
char errbuf[120];
InitializeOpenSSL();
- shared_ptr<SSL_CTX> sslContext = shared_ptr<SSL_CTX>(SSL_CTX_new(TLSv1_method()), SSL_CTX_free);
+ boost::shared_ptr<SSL_CTX> sslContext = boost::shared_ptr<SSL_CTX>(SSL_CTX_new(TLSv1_method()), SSL_CTX_free);
SSL_CTX_set_mode(sslContext.get(), SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
* @param context The SSL context.
* @param crlPath The path to the CRL file.
*/
-void AddCRLToSSLContext(const shared_ptr<SSL_CTX>& context, const String& crlPath)
+void AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath)
{
char errbuf[120];
X509_STORE *x509_store = SSL_CTX_get_cert_store(context.get());
* @param certificate The X509 certificate.
* @returns The common name.
*/
-String GetCertificateCN(const shared_ptr<X509>& certificate)
+String GetCertificateCN(const boost::shared_ptr<X509>& certificate)
{
char errbuf[120];
char buffer[256];
* @param pemfile The filename.
* @returns An X509 certificate.
*/
-shared_ptr<X509> GetX509Certificate(const String& pemfile)
+boost::shared_ptr<X509> GetX509Certificate(const String& pemfile)
{
char errbuf[120];
X509 *cert;
BIO_free(fpcert);
- return shared_ptr<X509>(cert, X509_free);
+ return boost::shared_ptr<X509>(cert, X509_free);
}
int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile, const String& certfile, bool ca)
X509_NAME *subject = X509_NAME_new();
X509_NAME_add_entry_by_txt(subject, "CN", MBSTRING_ASC, (unsigned char *)cn.CStr(), -1, -1, 0);
- shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca);
+ boost::shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca);
X509_NAME_free(subject);
return 1;
}
-shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca, const String& serialfile)
+boost::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca, const String& serialfile)
{
X509 *cert = X509_new();
X509_gmtime_adj(X509_get_notBefore(cert), 0);
X509_sign(cert, cakey, NULL);
- return shared_ptr<X509>(cert, X509_free);
+ return boost::shared_ptr<X509>(cert, X509_free);
}
String GetIcingaCADir(void)
return Application::GetLocalStateDir() + "/lib/icinga2/ca";
}
-shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
+boost::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
{
char errbuf[120];
if (!cakeybio) {
Log(LogCritical, "SSL")
<< "Could not open CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
- return shared_ptr<X509>();
+ return boost::shared_ptr<X509>();
}
rsa = PEM_read_bio_RSAPrivateKey(cakeybio, NULL, NULL, NULL);
if (!rsa) {
Log(LogCritical, "SSL")
<< "Could not read RSA key from CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
- return shared_ptr<X509>();
+ return boost::shared_ptr<X509>();
}
BIO_free(cakeybio);
String cacertfile = cadir + "/ca.crt";
- shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
+ boost::shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
EVP_PKEY *privkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(privkey, rsa);
return CreateCert(pubkey, subject, X509_get_subject_name(cacert.get()), privkey, false, cadir + "/serial.txt");
}
-String CertificateToString(const shared_ptr<X509>& cert)
+String CertificateToString(const boost::shared_ptr<X509>& cert)
{
BIO *mem = BIO_new(BIO_s_mem());
PEM_write_bio_X509(mem, cert.get());
#include <openssl/x509v3.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
+#include <boost/smart_ptr/shared_ptr.hpp>
namespace icinga
{
void I2_BASE_API InitializeOpenSSL(void);
-shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey = String());
-void I2_BASE_API AddCRLToSSLContext(const shared_ptr<SSL_CTX>& context, const String& crlPath);
-String I2_BASE_API GetCertificateCN(const shared_ptr<X509>& certificate);
-shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile);
+boost::shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey = String());
+void I2_BASE_API AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath);
+String I2_BASE_API GetCertificateCN(const boost::shared_ptr<X509>& certificate);
+boost::shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile);
int I2_BASE_API MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile = String(), const String& certfile = String(), bool ca = false);
-shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca, const String& serialfile = String());
+boost::shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca, const String& serialfile = String());
String I2_BASE_API GetIcingaCADir(void);
-String I2_BASE_API CertificateToString(const shared_ptr<X509>& cert);
-shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
+String I2_BASE_API CertificateToString(const boost::shared_ptr<X509>& cert);
+boost::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
String I2_BASE_API PBKDF2_SHA1(const String& password, const String& salt, int iterations);
String I2_BASE_API SHA256(const String& s);
String I2_BASE_API RandomString(int length);
#include "base/string.hpp"
#include "base/object.hpp"
#include "base/initialize.hpp"
-#include "base/utility.hpp"
#include <boost/function.hpp>
namespace icinga
struct Field
{
int ID;
- shared_ptr<Type> FType;
+ intrusive_ptr<Type> FType;
const char *Name;
int Attributes;
- Field(int id, const shared_ptr<Type>& type, const char *name, int attributes)
+ Field(int id, const intrusive_ptr<Type>& type, const char *name, int attributes)
: ID(id), FType(type), Name(name), Attributes(attributes)
{ }
};
namespace { namespace UNIQUE_NAME(rt) { \
void RegisterType ## type(void) \
{ \
- icinga::Type::Ptr t = make_shared<TypeImpl<type> >(); \
+ icinga::Type::Ptr t = new TypeImpl<type>(); \
type::TypeInstance = t; \
icinga::Type::Register(t); \
} \
DEFINE_TYPE_INSTANCE(type)
#define DEFINE_TYPE_INSTANCE(type) \
- Type::Ptr type::TypeInstance;
+ Type::Ptr type::TypeInstance
}
namespace icinga
{
-#define TOKENPASTE(x, y) x ## y
-#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
-
-#ifdef HAVE_COUNTER_MACRO
-# define UNIQUE_NAME(prefix) TOKENPASTE2(prefix, __COUNTER__)
-#else /* HAVE_COUNTER_MACRO */
-# define UNIQUE_NAME(prefix) prefix
-#endif /* HAVE_COUNTER_MACRO */
-
#ifdef _WIN32
#define MS_VC_EXCEPTION 0x406D1388
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
return static_cast<double>(lhs) + static_cast<double>(rhs);
else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
if (!lhs.IsEmpty())
static_cast<Array::Ptr>(lhs)->CopyTo(result);
if (!rhs.IsEmpty())
static_cast<Array::Ptr>(rhs)->CopyTo(result);
return result;
} else if ((lhs.IsObjectType<Dictionary>() || lhs.IsEmpty()) && (rhs.IsObjectType<Dictionary>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
if (!lhs.IsEmpty())
static_cast<Dictionary::Ptr>(lhs)->CopyTo(result);
if (!rhs.IsEmpty())
return static_cast<double>(lhs) - static_cast<double>(rhs);
else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
if (lhs.IsEmpty())
- return make_shared<Array>();
+ return new Array();
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
Array::Ptr left = lhs;
Array::Ptr right = rhs;
Value(const String& value);
Value(const char *value);
+ inline Value(Object *value)
+ : m_Value()
+ {
+ if (!value)
+ return;
+
+ m_Value = Object::Ptr(value);
+ }
+
template<typename T>
- inline Value(const shared_ptr<T>& value)
+ inline Value(const intrusive_ptr<T>& value)
: m_Value()
{
if (!value)
bool operator!=(const Value& rhs) const;
template<typename T>
- operator shared_ptr<T>(void) const
+ operator intrusive_ptr<T>(void) const
{
if (IsEmpty())
- return shared_ptr<T>();
+ return intrusive_ptr<T>();
if (!IsObject())
BOOST_THROW_EXCEPTION(std::runtime_error("Cannot convert value to object."));
ASSERT(object);
- shared_ptr<T> tobject = dynamic_pointer_cast<T>(object);
+ intrusive_ptr<T> tobject = dynamic_pointer_cast<T>(object);
if (!tobject)
BOOST_THROW_EXCEPTION(std::bad_cast());
# define I2_IMPORT __declspec(dllimport)
#endif /* _WIN32 */
+#define TOKENPASTE(x, y) x ## y
+#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
+
+#ifdef HAVE_COUNTER_MACRO
+# define UNIQUE_NAME(prefix) TOKENPASTE2(prefix, __COUNTER__)
+#else /* HAVE_COUNTER_MACRO */
+# define UNIQUE_NAME(prefix) prefix
+#endif /* HAVE_COUNTER_MACRO */
+
#endif /* VISIBILITY_H */
: m_ID(m_NextID++), m_MaxItems(maxItems), m_Stopped(false),
m_Processing(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback)
{
- m_StatusTimer = make_shared<Timer>();
+ m_StatusTimer = new Timer();
m_StatusTimer->SetInterval(10);
m_StatusTimer->OnTimerExpired.connect(boost::bind(&WorkQueue::StatusTimerHandler, this));
m_StatusTimer->Start();
Value CheckerComponent::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const CheckerComponent::Ptr& checker, DynamicType::GetObjectsByType<CheckerComponent>()) {
unsigned long idle = checker->GetIdleCheckables();
unsigned long pending = checker->GetPendingCheckables();
- Dictionary::Ptr stats = make_shared<Dictionary>();
+ Dictionary::Ptr stats = new Dictionary();
stats->Set("idle", idle);
stats->Set("pending", pending);
nodes->Set(checker->GetName(), stats);
String perfdata_prefix = "checkercomponent_" + checker->GetName() + "_";
- perfdata->Add(make_shared<PerfdataValue>(perfdata_prefix + "idle", Convert::ToDouble(idle)));
- perfdata->Add(make_shared<PerfdataValue>(perfdata_prefix + "pending", Convert::ToDouble(pending)));
+ perfdata->Add(new PerfdataValue(perfdata_prefix + "idle", Convert::ToDouble(idle)));
+ perfdata->Add(new PerfdataValue(perfdata_prefix + "pending", Convert::ToDouble(pending)));
}
status->Set("checkercomponent", nodes);
m_Thread = boost::thread(boost::bind(&CheckerComponent::CheckThreadProc, this));
- m_ResultTimer = make_shared<Timer>();
+ m_ResultTimer = new Timer();
m_ResultTimer->SetInterval(5);
m_ResultTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::ResultTimerHandler, this));
m_ResultTimer->Start();
Log(LogDebug, "CheckerComponent")
<< "Executing check for '" << checkable->GetName() << "'";
- CheckerComponent::Ptr self = GetSelf();
- Utility::QueueAsyncCallback(boost::bind(&CheckerComponent::ExecuteCheckHelper, self, checkable));
+ Utility::QueueAsyncCallback(boost::bind(&CheckerComponent::ExecuteCheckHelper, CheckerComponent::Ptr(this), checkable));
lock.lock();
}
try {
checkable->ExecuteCheck();
} catch (const std::exception& ex) {
- CheckResult::Ptr cr = make_shared<CheckResult>();
+ CheckResult::Ptr cr = new CheckResult();
cr->SetState(ServiceUnknown);
String output = "Exception occured while checking '" + checkable->GetName() + "': " + DiagnosticInformation(ex);
#define REGISTER_CLICOMMAND(name, klass) \
namespace { namespace UNIQUE_NAME(cli) { \
- I2_EXPORT icinga::RegisterCLICommandHelper l_RegisterCLICommand(name, make_shared<klass>()); \
+ I2_EXPORT icinga::RegisterCLICommandHelper l_RegisterCLICommand(name, new klass()); \
} }
}
ConfigCompiler::CompileText(name, fragment);
}
- ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>();
+ ConfigItemBuilder::Ptr builder = new ConfigItemBuilder();
builder->SetType(appType);
builder->SetName("application");
ConfigItem::Ptr item = builder->Compile();
name.push_back("node");
name.push_back(ltype);
name.push_back("add");
- CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(type, BlackAndWhitelistCommandAdd));
+ CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandAdd));
name[2] = "remove";
- CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(type, BlackAndWhitelistCommandRemove));
+ CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandRemove));
name[2] = "list";
- CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(type, BlackAndWhitelistCommandList));
+ CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandList));
}
BlackAndWhitelistCommand::BlackAndWhitelistCommand(const String& type, BlackAndWhitelistCommandType command)
String inventory_path = NodeUtility::GetRepositoryPath() + "/inventory.index";
- Dictionary::Ptr old_inventory = make_shared<Dictionary>();
+ Dictionary::Ptr old_inventory = new Dictionary();
if (Utility::PathExists(inventory_path)) {
old_inventory = Utility::LoadJsonFile(inventory_path);
}
- Dictionary::Ptr inventory = make_shared<Dictionary>();
+ Dictionary::Ptr inventory = new Dictionary();
Log(LogInformation, "cli")
<< "Updating node configuration for ";
/* store existing structure in index */
inventory->Set(endpoint, node);
- Dictionary::Ptr host_services = make_shared<Dictionary>();
+ Dictionary::Ptr host_services = new Dictionary();
Log(LogInformation, "cli")
<< "Adding host '" << zone << "' to the repository.";
- Dictionary::Ptr host_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr host_attrs = new Dictionary();
host_attrs->Set("__name", zone);
host_attrs->Set("name", zone);
host_attrs->Set("check_command", "cluster-zone");
- Array::Ptr host_imports = make_shared<Array>();
+ Array::Ptr host_imports = new Array();
host_imports->Add("satellite-host"); //default host node template
host_attrs->Set("import", host_imports);
if (!skip_host) {
/* add a new host to the config repository */
- Dictionary::Ptr host_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr host_attrs = new Dictionary();
host_attrs->Set("__name", host);
host_attrs->Set("name", host);
host_attrs->Set("zone", zone);
}
- Array::Ptr host_imports = make_shared<Array>();
+ Array::Ptr host_imports = new Array();
host_imports->Add("satellite-host"); //default host node template
host_attrs->Set("import", host_imports);
continue;
/* add a new service for this host to the config repository */
- Dictionary::Ptr service_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr service_attrs = new Dictionary();
String long_name = host + "!" + service; //use NameComposer?
service_attrs->Set("__name", long_name);
service_attrs->Set("name", service);
service_attrs->Set("check_command", "dummy");
service_attrs->Set("zone", zone);
- Array::Ptr service_imports = make_shared<Array>();
+ Array::Ptr service_imports = new Array();
service_imports->Add("satellite-service"); //default service node template
service_attrs->Set("import", service_imports);
}
/* write a new zone and endpoint for the node */
- Dictionary::Ptr endpoint_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr endpoint_attrs = new Dictionary();
endpoint_attrs->Set("__name", endpoint);
endpoint_attrs->Set("name", endpoint);
<< "Cannot add node endpoint '" << endpoint << "' to the config repository!\n";
}
- Dictionary::Ptr zone_attrs = make_shared<Dictionary>();
- Array::Ptr zone_members = make_shared<Array>();
+ Dictionary::Ptr zone_attrs = new Dictionary();
+ Array::Ptr zone_members = new Array();
zone_members->Add(endpoint);
zone_attrs->Set("__name", zone);
BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) {
String host = kv.first;
- Dictionary::Ptr host_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr host_attrs = new Dictionary();
host_attrs->Set("name", host);
RepositoryUtility::RemoveObject(host, "Host", host_attrs); //this removes all services for this host as well
}
String zone = old_node->Get("zone");
String endpoint = old_node->Get("endpoint");
- Dictionary::Ptr zone_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr zone_attrs = new Dictionary();
zone_attrs->Set("name", zone);
RepositoryUtility::RemoveObject(zone, "Zone", zone_attrs);
- Dictionary::Ptr endpoint_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr endpoint_attrs = new Dictionary();
endpoint_attrs->Set("name", endpoint);
RepositoryUtility::RemoveObject(endpoint, "Endpoint", endpoint_attrs);
} else {
Log(LogInformation, "cli")
<< "Node update found old host '" << old_host << "' on node '" << old_node_name << "'. Removing it.";
- Dictionary::Ptr host_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr host_attrs = new Dictionary();
host_attrs->Set("name", old_host);
RepositoryUtility::RemoveObject(old_host, "Host", host_attrs); //this will remove all services for this host too
} else {
<< "Node update found old service '" << old_service << "' on host '" << old_host
<< "' on node '" << old_node_name << "'. Removing it.";
- Dictionary::Ptr service_attrs = make_shared<Dictionary>();
+ Dictionary::Ptr service_attrs = new Dictionary();
service_attrs->Set("name", old_service);
service_attrs->Set("host_name", old_host);
RepositoryUtility::RemoveObject(old_service, "Service", service_attrs);
void NodeUtility::PrintNodesJson(std::ostream& fp)
{
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
BOOST_FOREACH(const Dictionary::Ptr& node, GetNodes()) {
result->Set(node->Get("endpoint"), node);
<< "Node '" << name << "' exists already.";
}
- Dictionary::Ptr node = make_shared<Dictionary>();
+ Dictionary::Ptr node = new Dictionary();
node->Set("seen", Utility::GetTime());
node->Set("endpoint", name);
void NodeUtility::AddNodeSettings(const String& name, const String& host,
const String& port, double log_duration)
{
- Dictionary::Ptr settings = make_shared<Dictionary>();
+ Dictionary::Ptr settings = new Dictionary();
settings->Set("host", host);
settings->Set("port", port);
int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename, const String& zonename)
{
- Array::Ptr my_config = make_shared<Array>();
+ Array::Ptr my_config = new Array();
- Dictionary::Ptr my_master_zone = make_shared<Dictionary>();
- Array::Ptr my_master_zone_members = make_shared<Array>();
+ Dictionary::Ptr my_master_zone = new Dictionary();
+ Array::Ptr my_master_zone_members = new Array();
String master_zone_name = "master"; //TODO: Find a better name.
std::vector<String> tokens;
boost::algorithm::split(tokens, endpoint, boost::is_any_of(","));
- Dictionary::Ptr my_master_endpoint = make_shared<Dictionary>();
+ Dictionary::Ptr my_master_endpoint = new Dictionary();
if (tokens.size() > 1) {
String host = tokens[1];
my_config->Add(my_master_zone);
/* store the local generated node configuration */
- Dictionary::Ptr my_endpoint = make_shared<Dictionary>();
- Dictionary::Ptr my_zone = make_shared<Dictionary>();
+ Dictionary::Ptr my_endpoint = new Dictionary();
+ Dictionary::Ptr my_zone = new Dictionary();
my_endpoint->Set("__name", nodename);
my_endpoint->Set("__type", "Endpoint");
- Array::Ptr my_zone_members = make_shared<Array>();
+ Array::Ptr my_zone_members = new Array();
my_zone_members->Add(nodename);
my_zone->Set("__name", nodename);
int NodeUtility::GenerateNodeMasterIcingaConfig(const String& nodename)
{
- Array::Ptr my_config = make_shared<Array>();
+ Array::Ptr my_config = new Array();
/* store the local generated node master configuration */
- Dictionary::Ptr my_master_endpoint = make_shared<Dictionary>();
- Dictionary::Ptr my_master_zone = make_shared<Dictionary>();
- Array::Ptr my_master_zone_members = make_shared<Array>();
+ Dictionary::Ptr my_master_endpoint = new Dictionary();
+ Dictionary::Ptr my_master_zone = new Dictionary();
+ Array::Ptr my_master_zone_members = new Array();
my_master_endpoint->Set("__name", nodename);
my_master_endpoint->Set("__type", "Endpoint");
{
String list_path = GetBlackAndWhiteListPath(type);
- Array::Ptr lists = make_shared<Array>();
+ Array::Ptr lists = new Array();
if (Utility::PathExists(list_path)) {
lists = Utility::LoadJsonFile(list_path);
}
}
- Dictionary::Ptr new_filter = make_shared<Dictionary>();
+ Dictionary::Ptr new_filter = new Dictionary();
new_filter->Set("zone", zone_filter);
new_filter->Set("host", host_filter);
std::fstream fp;
fp.open(objectfile.CStr(), std::ios_base::in);
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream(&fp, false);
unsigned long objects_count = 0;
std::map<String, int> type_count;
BIO_free(csrbio);
- shared_ptr<X509> cert = CreateCertIcingaCA(X509_REQ_get_pubkey(req), X509_REQ_get_subject_name(req));
+ boost::shared_ptr<X509> cert = CreateCertIcingaCA(X509_REQ_get_pubkey(req), X509_REQ_get_subject_name(req));
X509_REQ_free(req);
int PkiUtility::SaveCert(const String& host, const String& port, const String& keyfile, const String& certfile, const String& trustedfile)
{
- TcpSocket::Ptr client = make_shared<TcpSocket>();
+ TcpSocket::Ptr client = new TcpSocket();
client->Connect(host, port);
- shared_ptr<SSL_CTX> sslContext = MakeSSLContext(certfile, keyfile);
+ boost::shared_ptr<SSL_CTX> sslContext = MakeSSLContext(certfile, keyfile);
- TlsStream::Ptr stream = make_shared<TlsStream>(client, RoleClient, sslContext);
+ TlsStream::Ptr stream = new TlsStream(client, RoleClient, sslContext);
try {
stream->Handshake();
}
- shared_ptr<X509> cert = stream->GetPeerCertificate();
+ boost::shared_ptr<X509> cert = stream->GetPeerCertificate();
std::ofstream fpcert;
fpcert.open(trustedfile.CStr());
int PkiUtility::RequestCertificate(const String& host, const String& port, const String& keyfile,
const String& certfile, const String& cafile, const String& trustedfile, const String& ticket)
{
- TcpSocket::Ptr client = make_shared<TcpSocket>();
+ TcpSocket::Ptr client = new TcpSocket();
try {
client->Connect(host, port);
return 1;
}
- shared_ptr<SSL_CTX> sslContext;
+ boost::shared_ptr<SSL_CTX> sslContext;
try {
sslContext = MakeSSLContext(certfile, keyfile);
return 1;
}
- TlsStream::Ptr stream = make_shared<TlsStream>(client, RoleClient, sslContext);
+ TlsStream::Ptr stream = new TlsStream(client, RoleClient, sslContext);
try {
stream->Handshake();
return 1;
}
- shared_ptr<X509> peerCert = stream->GetPeerCertificate();
+ boost::shared_ptr<X509> peerCert = stream->GetPeerCertificate();
- shared_ptr<X509> trustedCert;
+ boost::shared_ptr<X509> trustedCert;
try {
trustedCert = GetX509Certificate(trustedfile);
return 1;
}
- Dictionary::Ptr request = make_shared<Dictionary>();
+ Dictionary::Ptr request = new Dictionary();
String msgid = Utility::NewUniqueID();
request->Set("id", msgid);
request->Set("method", "pki::RequestCertificate");
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("ticket", String(ticket));
request->Set("params", params);
name.push_back("repository");
name.push_back(ltype);
name.push_back("add");
- CLICommand::Register(name, make_shared<RepositoryObjectCommand>(type, RepositoryCommandAdd));
+ CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandAdd));
name[2] = "remove";
- CLICommand::Register(name, make_shared<RepositoryObjectCommand>(type, RepositoryCommandRemove));
+ CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandRemove));
name[2] = "list";
- CLICommand::Register(name, make_shared<RepositoryObjectCommand>(type, RepositoryCommandList));
+ CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandList));
}
RepositoryObjectCommand::RepositoryObjectCommand(const String& type, RepositoryCommandType command)
String name = attrs->Get("name");
if (vm.count("import")) {
- Array::Ptr imports = make_shared<Array>();
+ Array::Ptr imports = new Array();
BOOST_FOREACH(const String& import, vm["import"].as<std::vector<std::string> >()) {
imports->Add(import);
Dictionary::Ptr RepositoryUtility::GetArgumentAttributes(const std::vector<std::string>& arguments)
{
- Dictionary::Ptr attrs = make_shared<Dictionary>();
+ Dictionary::Ptr attrs = new Dictionary();
BOOST_FOREACH(const String& kv, arguments) {
std::vector<String> tokens;
void RepositoryUtility::PrintChangeLog(std::ostream& fp)
{
- Array::Ptr changelog = make_shared<Array>();
+ Array::Ptr changelog = new Array();
GetChangeLog(boost::bind(RepositoryUtility::CollectChange, _1, changelog));
/* add a new changelog entry by timestamp */
String path = GetRepositoryChangeLogPath() + "/" + Convert::ToString(Utility::GetTime()) + "-" + type + "-" + SHA256(name) + ".change";
- Dictionary::Ptr change = make_shared<Dictionary>();
+ Dictionary::Ptr change = new Dictionary();
change->Set("timestamp", Utility::GetTime());
change->Set("name", name);
/* add a new changelog entry by timestamp */
String path = GetRepositoryChangeLogPath() + "/" + Convert::ToString(Utility::GetTime()) + "-" + type + "-" + SHA256(name) + ".change";
- Dictionary::Ptr change = make_shared<Dictionary>();
+ Dictionary::Ptr change = new Dictionary();
change->Set("timestamp", Utility::GetTime());
change->Set("name", name);
{
Dictionary::Ptr attrs = change->Get("attrs");
- Array::Ptr changelog = make_shared<Array>();
+ Array::Ptr changelog = new Array();
GetChangeLog(boost::bind(RepositoryUtility::CollectChange, _1, changelog));
bool RepositoryUtility::ChangeLogHasPendingChanges(void)
{
- Array::Ptr changelog = make_shared<Array>();
+ Array::Ptr changelog = new Array();
GetChangeLog(boost::bind(RepositoryUtility::CollectChange, _1, changelog));
return changelog->GetLength() > 0;
std::fstream fp;
fp.open(varsfile.CStr(), std::ios_base::in);
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream(&fp, false);
String message;
std::fstream fp;
fp.open(varsfile.CStr(), std::ios_base::in);
- StdioStream::Ptr sfp = make_shared<StdioStream>(&fp, false);
+ StdioStream::Ptr sfp = new StdioStream(&fp, false);
unsigned long variables_count = 0;
String message;
Value CheckResultReader::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const CheckResultReader::Ptr& checkresultreader, DynamicType::GetObjectsByType<CheckResultReader>()) {
nodes->Set(checkresultreader->GetName(), 1); //add more stats
*/
void CheckResultReader::Start(void)
{
- m_ReadTimer = make_shared<Timer>();
+ m_ReadTimer = new Timer();
m_ReadTimer->OnTimerExpired.connect(boost::bind(&CheckResultReader::ReadTimerHandler, this));
m_ReadTimer->SetInterval(5);
m_ReadTimer->Start();
return;
}
- CheckResult::Ptr result = make_shared<CheckResult>();
+ CheckResult::Ptr result = new CheckResult();
std::pair<String, Value> co = PluginUtility::ParseCheckOutput(attrs["output"]);
result->SetOutput(co.first);
result->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
Value CompatLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const CompatLogger::Ptr& compat_logger, DynamicType::GetObjectsByType<CompatLogger>()) {
nodes->Set(compat_logger->GetName(), 1); //add more stats
Checkable::OnEventCommandExecuted.connect(bind(&CompatLogger::EventCommandHandler, this, _1));
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
- m_RotationTimer = make_shared<Timer>();
+ m_RotationTimer = new Timer();
m_RotationTimer->OnTimerExpired.connect(boost::bind(&CompatLogger::RotationTimerHandler, this));
m_RotationTimer->Start();
Value ExternalCommandListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const ExternalCommandListener::Ptr& externalcommandlistener, DynamicType::GetObjectsByType<ExternalCommandListener>()) {
nodes->Set(externalcommandlistener->GetName(), 1); //add more stats
Value StatusDataWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const StatusDataWriter::Ptr& statusdatawriter, DynamicType::GetObjectsByType<StatusDataWriter>()) {
nodes->Set(statusdatawriter->GetName(), 1); //add more stats
{
DynamicObject::Start();
- m_StatusTimer = make_shared<Timer>();
+ m_StatusTimer = new Timer();
m_StatusTimer->SetInterval(GetUpdateInterval());
m_StatusTimer->OnTimerExpired.connect(boost::bind(&StatusDataWriter::StatusTimerHandler, this));
m_StatusTimer->Start();
static void MakeRBinaryOp(Value** result, Expression::OpCallback& op, Value *left, Value *right, DebugInfo& diLeft, DebugInfo& diRight)
{
- *result = new Value(make_shared<Expression>(op, *left, *right, DebugInfoRange(diLeft, diRight)));
+ *result = new Value(new Expression(op, *left, *right, DebugInfoRange(diLeft, diRight)));
delete left;
delete right;
}
void ConfigCompiler::Compile(void)
{
- m_ModuleScope = make_shared<Dictionary>();
+ m_ModuleScope = new Dictionary();
m_Abstract = std::stack<bool>();
m_RuleLists = std::stack<TypeRuleList::Ptr>();
m_Type = ConfigType::GetByName(name);
if (!m_Type) {
- m_Type = make_shared<ConfigType>(name, DebugInfoRange(@1, @2));
+ m_Type = new ConfigType(name, DebugInfoRange(@1, @2));
m_Type->Register();
}
}
typerulelist: '{'
{
- m_RuleLists.push(make_shared<TypeRuleList>());
+ m_RuleLists.push(new TypeRuleList());
}
typerules
'}'
{
m_ObjectAssign.pop();
- Array::Ptr args = make_shared<Array>();
+ Array::Ptr args = new Array();
args->Add(m_Abstract.top());
m_Abstract.pop();
m_SeenAssign.pop();
- Expression::Ptr rex = make_shared<Expression>(&Expression::OpLogicalNegate, m_Ignore.top(), DebugInfoRange(@2, @5));
+ Expression::Ptr rex = new Expression(&Expression::OpLogicalNegate, m_Ignore.top(), DebugInfoRange(@2, @5));
m_Ignore.pop();
- Expression::Ptr filter = make_shared<Expression>(&Expression::OpLogicalAnd, m_Assign.top(), rex, DebugInfoRange(@2, @5));
+ Expression::Ptr filter = new Expression(&Expression::OpLogicalAnd, m_Assign.top(), rex, DebugInfoRange(@2, @5));
m_Assign.pop();
args->Add(filter);
args->Add(context->GetZone());
- $$ = new Value(make_shared<Expression>(&Expression::OpObject, args, exprl, DebugInfoRange(@2, @5)));
+ $$ = new Value(new Expression(&Expression::OpObject, args, exprl, DebugInfoRange(@2, @5)));
}
;
lterm: indexer combined_set_op rterm
{
- $$ = new Value(make_shared<Expression>(&Expression::OpSet, MakeArray(Array::Ptr($1), $2), *$3, DebugInfoRange(@1, @3)));
+ $$ = new Value(new Expression(&Expression::OpSet, MakeArray(Array::Ptr($1), $2), *$3, DebugInfoRange(@1, @3)));
delete $3;
}
| T_IMPORT rterm
{
- Expression::Ptr avar = make_shared<Expression>(&Expression::OpVariable, "type", DebugInfoRange(@1, @2));
- $$ = new Value(make_shared<Expression>(&Expression::OpImport, avar, *$2, DebugInfoRange(@1, @2)));
+ Expression::Ptr avar = new Expression(&Expression::OpVariable, "type", DebugInfoRange(@1, @2));
+ $$ = new Value(new Expression(&Expression::OpImport, avar, *$2, DebugInfoRange(@1, @2)));
delete $2;
}
| T_ASSIGN T_WHERE rterm
m_SeenAssign.top() = true;
- m_Assign.top() = make_shared<Expression>(&Expression::OpLogicalOr, m_Assign.top(), *$3, DebugInfoRange(@1, @3));
+ m_Assign.top() = new Expression(&Expression::OpLogicalOr, m_Assign.top(), *$3, DebugInfoRange(@1, @3));
delete $3;
$$ = new Value(MakeLiteral());
if ((m_Apply.empty() || !m_Apply.top()) && (m_ObjectAssign.empty() || !m_ObjectAssign.top()))
BOOST_THROW_EXCEPTION(ConfigError("'ignore' keyword not valid in this context."));
- m_Ignore.top() = make_shared<Expression>(&Expression::OpLogicalOr, m_Ignore.top(), *$3, DebugInfoRange(@1, @3));
+ m_Ignore.top() = new Expression(&Expression::OpLogicalOr, m_Ignore.top(), *$3, DebugInfoRange(@1, @3));
delete $3;
$$ = new Value(MakeLiteral());
| T_RETURN rterm
{
Expression::Ptr aname = MakeLiteral("__result");
- $$ = new Value(make_shared<Expression>(&Expression::OpSet, MakeArray(MakeArray(MakeLiteral(aname)), OpSetLiteral), *$2, DebugInfoRange(@1, @2)));
+ $$ = new Value(new Expression(&Expression::OpSet, MakeArray(MakeArray(MakeLiteral(aname)), OpSetLiteral), *$2, DebugInfoRange(@1, @2)));
delete $2;
}
rterm_array: '[' newlines rterm_items newlines ']'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @5)));
+ $$ = new Value(new Expression(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @5)));
}
| '[' newlines rterm_items ']'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @4)));
}
| '[' rterm_items newlines ']'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @4)));
}
| '[' rterm_items ']'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @3)));
+ $$ = new Value(new Expression(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @3)));
}
;
rterm_scope: '{' newlines lterm_items newlines '}'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @5)));
+ $$ = new Value(new Expression(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @5)));
}
| '{' newlines lterm_items '}'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @4)));
}
| '{' lterm_items newlines '}'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @4)));
}
| '{' lterm_items '}'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @3)));
+ $$ = new Value(new Expression(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @3)));
}
;
}
| rterm '.' T_IDENTIFIER
{
- $$ = new Value(make_shared<Expression>(&Expression::OpIndexer, *$1, MakeLiteral($3), DebugInfoRange(@1, @3)));
+ $$ = new Value(new Expression(&Expression::OpIndexer, *$1, MakeLiteral($3), DebugInfoRange(@1, @3)));
delete $1;
free($3);
}
| rterm '(' rterm_items ')'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpFunctionCall, *$1, MakeLiteral(Array::Ptr($3)), DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpFunctionCall, *$1, MakeLiteral(Array::Ptr($3)), DebugInfoRange(@1, @4)));
delete $1;
}
| T_IDENTIFIER
{
- $$ = new Value(make_shared<Expression>(&Expression::OpVariable, $1, @1));
+ $$ = new Value(new Expression(&Expression::OpVariable, $1, @1));
free($1);
}
| '!' rterm
{
- $$ = new Value(make_shared<Expression>(&Expression::OpLogicalNegate, *$2, DebugInfoRange(@1, @2)));
+ $$ = new Value(new Expression(&Expression::OpLogicalNegate, *$2, DebugInfoRange(@1, @2)));
delete $2;
}
| '~' rterm
{
- $$ = new Value(make_shared<Expression>(&Expression::OpNegate, *$2, DebugInfoRange(@1, @2)));
+ $$ = new Value(new Expression(&Expression::OpNegate, *$2, DebugInfoRange(@1, @2)));
delete $2;
}
| rterm '[' rterm ']'
{
- $$ = new Value(make_shared<Expression>(&Expression::OpIndexer, *$1, *$3, DebugInfoRange(@1, @4)));
+ $$ = new Value(new Expression(&Expression::OpIndexer, *$1, *$3, DebugInfoRange(@1, @4)));
delete $1;
delete $3;
}
delete $6;
aexpr->MakeInline();
- $$ = new Value(make_shared<Expression>(&Expression::OpFunction, MakeArray($2, aexpr), Array::Ptr($4), DebugInfoRange(@1, @6)));
+ $$ = new Value(new Expression(&Expression::OpFunction, MakeArray($2, aexpr), Array::Ptr($4), DebugInfoRange(@1, @6)));
free($2);
}
| T_FUNCTION '(' identifier_items ')' rterm_scope
delete $5;
aexpr->MakeInline();
- $$ = new Value(make_shared<Expression>(&Expression::OpFunction, MakeArray(Empty, aexpr), Array::Ptr($3), DebugInfoRange(@1, @5)));
+ $$ = new Value(new Expression(&Expression::OpFunction, MakeArray(Empty, aexpr), Array::Ptr($3), DebugInfoRange(@1, @5)));
}
| T_FOR '(' identifier T_FOLLOWS identifier T_IN rterm ')' rterm_scope
{
Expression::Ptr ascope = *$9;
delete $9;
- $$ = new Value(make_shared<Expression>(&Expression::OpFor, MakeArray($3, $5, aexpr), ascope, DebugInfoRange(@1, @9)));
+ $$ = new Value(new Expression(&Expression::OpFor, MakeArray($3, $5, aexpr), ascope, DebugInfoRange(@1, @9)));
free($3);
free($5);
}
Expression::Ptr ascope = *$7;
delete $7;
- $$ = new Value(make_shared<Expression>(&Expression::OpFor, MakeArray($3, Empty, aexpr), ascope, DebugInfoRange(@1, @7)));
+ $$ = new Value(new Expression(&Expression::OpFor, MakeArray($3, Empty, aexpr), ascope, DebugInfoRange(@1, @7)));
free($3);
}
;
m_SeenAssign.pop();
- Expression::Ptr rex = make_shared<Expression>(&Expression::OpLogicalNegate, m_Ignore.top(), DebugInfoRange(@2, @5));
+ Expression::Ptr rex = new Expression(&Expression::OpLogicalNegate, m_Ignore.top(), DebugInfoRange(@2, @5));
m_Ignore.pop();
- Expression::Ptr filter = make_shared<Expression>(&Expression::OpLogicalAnd, m_Assign.top(), rex, DebugInfoRange(@2, @5));
+ Expression::Ptr filter = new Expression(&Expression::OpLogicalAnd, m_Assign.top(), rex, DebugInfoRange(@2, @5));
m_Assign.pop();
String fkvar = m_FKVar.top();
Expression::Ptr fterm = m_FTerm.top();
m_FTerm.pop();
- Array::Ptr args = make_shared<Array>();
+ Array::Ptr args = new Array();
args->Add(type);
args->Add(target);
args->Add(aname);
args->Add(fvvar);
args->Add(fterm);
- $$ = new Value(make_shared<Expression>(&Expression::OpApply, args, exprl, DebugInfoRange(@2, @5)));
+ $$ = new Value(new Expression(&Expression::OpApply, args, exprl, DebugInfoRange(@2, @5)));
}
;
if (!*fp)
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open '" + tempFilename + "' file"));
- m_ObjectsFP = make_shared<StdioStream>(fp, true);
+ m_ObjectsFP = new StdioStream(fp, true);
}
void ConfigCompilerContext::WriteObject(const Dictionary::Ptr& object)
dobj->SetTypeName(m_Type);
dobj->SetZone(m_Zone);
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", m_Scope);
m_Scope.reset();
locals->Set("name", m_Name);
String name = m_Name;
- shared_ptr<NameComposer> nc = dynamic_pointer_cast<NameComposer>(type);
+ NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
if (nc) {
name = nc->MakeName(m_Name, dobj);
Dictionary::Ptr attrs = Serialize(dobj, FAConfig);
- Dictionary::Ptr persistentItem = make_shared<Dictionary>();
+ Dictionary::Ptr persistentItem = new Dictionary();
persistentItem->Set("type", GetType());
persistentItem->Set("name", GetName());
*/
void ConfigItem::Register(void)
{
- ConfigItem::Ptr self = GetSelf();
+ Type::Ptr type = Type::GetByName(m_Type);
/* If this is a non-abstract object with a composite name
* we register it in m_UnnamedItems instead of m_Items. */
- if (!m_Abstract && dynamic_pointer_cast<NameComposer>(Type::GetByName(m_Type))) {
+ if (!m_Abstract && dynamic_cast<NameComposer *>(type.get())) {
boost::mutex::scoped_lock lock(m_Mutex);
- m_UnnamedItems.push_back(self);
+ m_UnnamedItems.push_back(this);
} else {
std::pair<String, String> key = std::make_pair(m_Type, m_Name);
boost::mutex::scoped_lock lock(m_Mutex);
- m_Items[key] = self;
+ m_Items[key] = this;
}
}
using namespace icinga;
ConfigItemBuilder::ConfigItemBuilder(void)
- : m_Abstract(false), m_Expressions(make_shared<Array>())
+ : m_Abstract(false), m_Expressions(new Array())
{
m_DebugInfo.FirstLine = 0;
m_DebugInfo.FirstColumn = 0;
}
ConfigItemBuilder::ConfigItemBuilder(const DebugInfo& debugInfo)
- : m_Abstract(false), m_Expressions(make_shared<Array>())
+ : m_Abstract(false), m_Expressions(new Array())
{
m_DebugInfo = debugInfo;
}
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
}
- Array::Ptr exprs = make_shared<Array>();
- Array::Ptr templateArray = make_shared<Array>();
+ Array::Ptr exprs = new Array();
+ Array::Ptr templateArray = new Array();
templateArray->Add(m_Name);
- exprs->Add(make_shared<Expression>(&Expression::OpSet,
+ exprs->Add(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("templates")), OpSetAdd),
- make_shared<Expression>(&Expression::OpLiteral, templateArray, m_DebugInfo),
+ new Expression(&Expression::OpLiteral, templateArray, m_DebugInfo),
m_DebugInfo));
- exprs->Add(make_shared<Expression>(&Expression::OpDict, m_Expressions, true, m_DebugInfo));
+ exprs->Add(new Expression(&Expression::OpDict, m_Expressions, true, m_DebugInfo));
- Expression::Ptr exprl = make_shared<Expression>(&Expression::OpDict, exprs, true, m_DebugInfo);
+ Expression::Ptr exprl = new Expression(&Expression::OpDict, exprs, true, m_DebugInfo);
- return make_shared<ConfigItem>(m_Type, m_Name, m_Abstract, exprl,
+ return new ConfigItem(m_Type, m_Name, m_Abstract, exprl,
m_DebugInfo, m_Scope, m_Zone);
}
using namespace icinga;
ConfigType::ConfigType(const String& name, const DebugInfo& debuginfo)
- : m_Name(name), m_RuleList(make_shared<TypeRuleList>()), m_DebugInfo(debuginfo)
+ : m_Name(name), m_RuleList(new TypeRuleList()), m_DebugInfo(debuginfo)
{ }
String ConfigType::GetName(void) const
locations.push_back(location);
std::vector<TypeRuleList::Ptr> ruleLists;
- AddParentRules(ruleLists, GetSelf());
+ AddParentRules(ruleLists, this);
ruleLists.push_back(m_RuleList);
ValidateDictionary(attrs, ruleLists, locations, utils);
void ConfigType::Register(void)
{
- ConfigTypeRegistry::GetInstance()->Register(GetName(), GetSelf());
+ ConfigTypeRegistry::GetInstance()->Register(GetName(), this);
}
ConfigType::Ptr ConfigType::GetByName(const String& name)
Value Expression::OpArray(const Expression *expr, const Object::Ptr& context, DebugHint *dhint)
{
Array::Ptr arr = expr->m_Operand1;
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
if (arr) {
for (Array::SizeType index = 0; index < arr->GetLength(); index++) {
{
Array::Ptr arr = expr->m_Operand1;
bool in_place = expr->m_Operand2;
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
result->Set("__parent", context);
} else {
parent = object;
- Expression::Ptr eparent = make_shared<Expression>(&Expression::OpLiteral, parent, expr->m_DebugInfo);
- Expression::Ptr eindex = make_shared<Expression>(&Expression::OpLiteral, tempindex, expr->m_DebugInfo);
+ Expression::Ptr eparent = new Expression(&Expression::OpLiteral, parent, expr->m_DebugInfo);
+ Expression::Ptr eindex = new Expression(&Expression::OpLiteral, tempindex, expr->m_DebugInfo);
- Expression::Ptr eip = make_shared<Expression>(&Expression::OpIndexer, eparent, eindex, expr->m_DebugInfo);
+ Expression::Ptr eip = new Expression(&Expression::OpIndexer, eparent, eindex, expr->m_DebugInfo);
object = eip->Evaluate(context, dhint);
}
sdhint = sdhint->GetChild(index);
if (i != indexer->GetLength() - 1 && object.IsEmpty()) {
- object = make_shared<Dictionary>();
+ object = new Dictionary();
SetField(parent, tempindex, object);
}
VERIFY(!"Invalid opcode.");
}
- Expression::Ptr ecp = make_shared<Expression>(op,
- make_shared<Expression>(&Expression::OpLiteral, object, expr->m_DebugInfo),
- make_shared<Expression>(&Expression::OpLiteral, right, expr->m_DebugInfo),
+ Expression::Ptr ecp = new Expression(op,
+ new Expression(&Expression::OpLiteral, object, expr->m_DebugInfo),
+ new Expression(&Expression::OpLiteral, right, expr->m_DebugInfo),
expr->m_DebugInfo);
right = ecp->Evaluate(context, dhint);
if (arguments.size() < funcargs->GetLength())
BOOST_THROW_EXCEPTION(ConfigError("Too few arguments for function"));
- Dictionary::Ptr context = make_shared<Dictionary>();
+ Dictionary::Ptr context = new Dictionary();
context->Set("__parent", scope);
for (std::vector<Value>::size_type i = 0; i < std::min(arguments.size(), funcargs->GetLength()); i++)
String name = left->Get(0);
Array::Ptr funcargs = expr->m_Operand2;
- ScriptFunction::Ptr func = make_shared<ScriptFunction>(boost::bind(&Expression::FunctionWrapper, _1, funcargs, aexpr, context));
+ ScriptFunction::Ptr func = new ScriptFunction(boost::bind(&Expression::FunctionWrapper, _1, funcargs, aexpr, context));
if (!name.IsEmpty())
ScriptFunction::Register(name, func);
String name = aname->Evaluate(context, dhint);
- ConfigItemBuilder::Ptr item = make_shared<ConfigItemBuilder>(expr->m_DebugInfo);
+ ConfigItemBuilder::Ptr item = new ConfigItemBuilder(expr->m_DebugInfo);
String checkName = name;
if (!abstract) {
- shared_ptr<NameComposer> nc = dynamic_pointer_cast<NameComposer>(Type::GetByName(type));
+ Type::Ptr ptype = Type::GetByName(type);
+
+ NameComposer *nc = dynamic_cast<NameComposer *>(ptype.get());
if (nc)
checkName = nc->MakeName(name, Dictionary::Ptr());
ObjectLock olock(arr);
BOOST_FOREACH(const Value& value, arr) {
- Dictionary::Ptr xcontext = make_shared<Dictionary>();
+ Dictionary::Ptr xcontext = new Dictionary();
xcontext->Set("__parent", context);
xcontext->Set(kvar, value);
ObjectLock olock(dict);
BOOST_FOREACH(const Dictionary::Pair& kv, dict) {
- Dictionary::Ptr xcontext = make_shared<Dictionary>();
+ Dictionary::Ptr xcontext = new Dictionary();
xcontext->Set("__parent", context);
xcontext->Set(kvar, kv.first);
xcontext->Set(vvar, kv.second);
Dictionary::Ptr DebugHint::ToDictionary(void) const
{
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
- Array::Ptr messages = make_shared<Array>();
+ Array::Ptr messages = new Array();
typedef std::pair<String, DebugInfo> MessageType;
BOOST_FOREACH(const MessageType& message, Messages) {
- Array::Ptr amsg = make_shared<Array>();
+ Array::Ptr amsg = new Array();
amsg->Add(message.first);
amsg->Add(message.second.Path);
amsg->Add(message.second.FirstLine);
result->Set("messages", messages);
- Dictionary::Ptr properties = make_shared<Dictionary>();
+ Dictionary::Ptr properties = new Dictionary();
typedef std::map<String, DebugHint>::value_type ChildType;
BOOST_FOREACH(const ChildType& kv, Children) {
Expression::Ptr icinga::MakeLiteral(const Value& lit)
{
- return make_shared<Expression>(&Expression::OpLiteral, lit, DebugInfo());
+ return new Expression(&Expression::OpLiteral, lit, DebugInfo());
}
bool Expression::HasField(const Object::Ptr& context, const String& field)
Dictionary::Ptr CommandDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Command::Ptr command = static_pointer_cast<Command>(GetObject());
fields->Set("command_line", CompatUtility::GetCommandLine(command));
public:
DECLARE_PTR_TYPEDEFS(CommandDbObject);
- CommandDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);
+ CommandDbObject(const DbType::Ptr& type, const String& name1, const String& name2);
virtual Dictionary::Ptr GetConfigFields(void) const;
virtual Dictionary::Ptr GetStatusFields(void) const;
Log(LogInformation, "DbConnection")
<< "Resuming IDO connection: " << GetName();
- m_CleanUpTimer = make_shared<Timer>();
+ m_CleanUpTimer = new Timer();
m_CleanUpTimer->SetInterval(60);
m_CleanUpTimer->OnTimerExpired.connect(boost::bind(&DbConnection::CleanUpHandler, this));
m_CleanUpTimer->Start();
void DbConnection::StaticInitialize(void)
{
- m_ProgramStatusTimer = make_shared<Timer>();
+ m_ProgramStatusTimer = new Timer();
m_ProgramStatusTimer->SetInterval(10);
m_ProgramStatusTimer->OnTimerExpired.connect(boost::bind(&DbConnection::ProgramStatusHandler));
m_ProgramStatusTimer->Start();
query.Table = "runtimevariables";
query.Type = DbQueryInsert;
query.Category = DbCatProgramStatus;
- query.Fields = make_shared<Dictionary>();
+ query.Fields = new Dictionary();
query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query.Fields->Set("varname", key);
query.Fields->Set("varvalue", value);
query1.Table = "programstatus";
query1.Type = DbQueryDelete;
query1.Category = DbCatProgramStatus;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbObject::OnQuery(query1);
query2.Type = DbQueryInsert;
query2.Category = DbCatProgramStatus;
- query2.Fields = make_shared<Dictionary>();
+ query2.Fields = new Dictionary();
query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.Fields->Set("program_version", Application::GetVersion());
query2.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
query3.Table = "runtimevariables";
query3.Type = DbQueryDelete;
query3.Category = DbCatProgramStatus;
- query3.WhereCriteria = make_shared<Dictionary>();
+ query3.WhereCriteria = new Dictionary();
query3.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbObject::OnQuery(query3);
Log(LogDebug, "DbConnection")
<< "icinga application customvar key: '" << kv.first << "' value: '" << kv.second << "'";
- Dictionary::Ptr fields4 = make_shared<Dictionary>();
+ Dictionary::Ptr fields4 = new Dictionary();
fields4->Set("varname", Convert::ToString(kv.first));
fields4->Set("varvalue", Convert::ToString(kv.second));
fields4->Set("config_type", 1);
};
[config] Dictionary::Ptr cleanup {
- default {{{ return make_shared<Dictionary>(); }}}
+ default {{{ return new Dictionary(); }}}
};
[config] int categories {
query1.Type = DbQueryUpdate;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("next_check", DbValue::FromTimestamp(nextCheck));
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
if (service)
query1.WhereCriteria->Set("service_object_id", service);
else
query1.Type = DbQueryUpdate;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(checkable));
fields1->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(checkable));
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
if (service)
query1.WhereCriteria->Set("service_object_id", service);
else
query1.Type = DbQueryUpdate;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("last_notification", DbValue::FromTimestamp(now_bag.first));
fields1->Set("next_notification", DbValue::FromTimestamp(time_bag.first));
fields1->Set("current_notification_number", notification->GetNotificationNumber());
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
if (service)
query1.WhereCriteria->Set("service_object_id", service);
else
query1.Type = DbQueryUpdate;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
if (type == EnableActiveChecks) {
fields1->Set("active_checks_enabled", enabled ? 1 : 0);
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
if (service)
query1.WhereCriteria->Set("service_object_id", service);
else
unsigned long entry_time = static_cast<long>(comment->GetEntryTime());
unsigned long entry_time_usec = (comment->GetEntryTime() - entry_time) * 1000 * 1000;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("entry_time", DbValue::FromTimestamp(entry_time));
fields1->Set("entry_time_usec", entry_time_usec);
fields1->Set("entry_type", comment->GetEntryType());
query1.Table = "comments";
query1.Type = DbQueryDelete;
query1.Category = DbCatComment;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
DbObject::OnQuery(query1);
}
query1.Table = "comments";
query1.Type = DbQueryDelete;
query1.Category = DbCatComment;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("internal_comment_id", comment->GetLegacyId());
DbObject::OnQuery(query1);
query2.Type = DbQueryUpdate;
query2.Category = DbCatComment;
- Dictionary::Ptr fields2 = make_shared<Dictionary>();
+ Dictionary::Ptr fields2 = new Dictionary();
fields2->Set("deletion_time", DbValue::FromTimestamp(time_bag.first));
fields2->Set("deletion_time_usec", time_bag.second);
query2.Fields = fields2;
- query2.WhereCriteria = make_shared<Dictionary>();
+ query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("internal_comment_id", comment->GetLegacyId());
query2.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time));
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
void DbEvents::AddDowntimeByType(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical)
{
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
fields1->Set("object_id", checkable);
query1.Table = "scheduleddowntime";
query1.Type = DbQueryDelete;
query1.Category = DbCatDowntime;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
DbObject::OnQuery(query1);
}
query1.Table = "scheduleddowntime";
query1.Type = DbQueryDelete;
query1.Category = DbCatDowntime;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
DbObject::OnQuery(query1);
query3.Type = DbQueryUpdate;
query3.Category = DbCatDowntime;
- Dictionary::Ptr fields3 = make_shared<Dictionary>();
+ Dictionary::Ptr fields3 = new Dictionary();
fields3->Set("was_cancelled", downtime->GetWasCancelled() ? 1 : 0);
fields3->Set("actual_end_time", DbValue::FromTimestamp(time_bag.first));
fields3->Set("actual_end_time_usec", time_bag.second);
query3.Fields = fields3;
- query3.WhereCriteria = make_shared<Dictionary>();
+ query3.WhereCriteria = new Dictionary();
query3.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
query3.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
query3.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
query1.Type = DbQueryUpdate;
query1.Category = DbCatDowntime;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("was_started", 1);
fields1->Set("actual_start_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("actual_start_time_usec", time_bag.second);
fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
query3.Type = DbQueryUpdate;
query3.Category = DbCatDowntime;
- Dictionary::Ptr fields3 = make_shared<Dictionary>();
+ Dictionary::Ptr fields3 = new Dictionary();
fields3->Set("was_started", 1);
fields3->Set("is_in_effect", 1);
fields3->Set("actual_start_time", DbValue::FromTimestamp(time_bag.first));
fields3->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
query3.Fields = fields3;
- query3.WhereCriteria = make_shared<Dictionary>();
+ query3.WhereCriteria = new Dictionary();
query3.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
query3.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
query3.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
query4.Type = DbQueryUpdate;
- Dictionary::Ptr fields4 = make_shared<Dictionary>();
+ Dictionary::Ptr fields4 = new Dictionary();
fields4->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
query4.Fields = fields4;
- query4.WhereCriteria = make_shared<Dictionary>();
+ query4.WhereCriteria = new Dictionary();
if (service)
query4.WhereCriteria->Set("service_object_id", service);
else
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("entry_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("entry_time_usec", time_bag.second);
fields1->Set("acknowledgement_type", type);
query1.Type = DbQueryUpdate;
query1.Category = DbCatAcknowledgement;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("acknowledgement_type", type);
fields1->Set("problem_has_been_acknowledged", add ? 1 : 0);
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
if (service)
query1.WhereCriteria->Set("service_object_id", service);
else
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("notification_type", 1); /* service */
fields1->Set("notification_reason", CompatUtility::MapNotificationReasonType(type));
fields1->Set("object_id", checkable);
Log(LogDebug, "DbEvents")
<< "add contact notification history for service '" << checkable->GetName() << "' and user '" << user->GetName() << "'.";
- Dictionary::Ptr fields2 = make_shared<Dictionary>();
+ Dictionary::Ptr fields2 = new Dictionary();
fields2->Set("contact_object_id", user);
fields2->Set("start_time", DbValue::FromTimestamp(time_bag.first));
fields2->Set("start_time_usec", time_bag.second);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("state_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("state_time_usec", time_bag.second);
fields1->Set("object_id", checkable);
query1.Type = DbQueryInsert;
query1.Category = DbCatLog;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("logentry_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("entry_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("entry_time_usec", time_bag.second);
query1.Type = DbQueryInsert;
query1.Category = DbCatFlapping;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("event_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("event_time_usec", time_bag.second);
query1.Type = DbQueryInsert;
query1.Category = DbCatCheck;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
double execution_time = Service::CalculateExecutionTime(cr);
fields1->Set("check_type", CompatUtility::GetCheckableCheckType(checkable));
query1.Type = DbQueryInsert;
query1.Category = DbCatEventHandler;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
Host::Ptr host;
Service::Ptr service;
query1.Type = DbQueryInsert;
query1.Category = DbCatExternalCommand;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("entry_time", DbValue::FromTimestamp(static_cast<long>(time)));
fields1->Set("command_type", CompatUtility::MapExternalCommandType(command));
INITIALIZE_ONCE(&DbObject::StaticInitialize);
-DbObject::DbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2)
+DbObject::DbObject(const intrusive_ptr<DbType>& type, const String& name1, const String& name2)
: m_Name1(name1), m_Name2(name2), m_Type(type), m_LastConfigUpdate(0), m_LastStatusUpdate(0)
{ }
query.Fields->Set(GetType()->GetIDColumn(), GetObject());
query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query.Fields->Set("config_type", 1);
- query.WhereCriteria = make_shared<Dictionary>();
+ query.WhereCriteria = new Dictionary();
query.WhereCriteria->Set(GetType()->GetIDColumn(), GetObject());
- query.Object = GetSelf();
+ query.Object = this;
query.ConfigUpdate = true;
OnQuery(query);
query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
- query.WhereCriteria = make_shared<Dictionary>();
+ query.WhereCriteria = new Dictionary();
query.WhereCriteria->Set(GetType()->GetIDColumn(), GetObject());
- query.Object = GetSelf();
+ query.Object = this;
query.StatusUpdate = true;
OnQuery(query);
<< "object customvar key: '" << kv.first << "' value: '" << kv.second
<< "' overridden: " << overridden;
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
fields->Set("varname", kv.first);
fields->Set("varvalue", value);
fields->Set("is_json", is_json);
<< "object customvar key: '" << kv.first << "' value: '" << kv.second
<< "' overridden: " << overridden;
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
fields->Set("varname", kv.first);
fields->Set("varvalue", value);
fields->Set("is_json", is_json);
query.Category = DbCatState;
query.Fields = fields;
- query.WhereCriteria = make_shared<Dictionary>();
+ query.WhereCriteria = new Dictionary();
query.WhereCriteria->Set("object_id", obj);
query.WhereCriteria->Set("varname", Convert::ToString(kv.first));
- query.Object = GetSelf();
+ query.Object = this;
OnQuery(query);
}
String GetName1(void) const;
String GetName2(void) const;
- shared_ptr<DbType> GetType(void) const;
+ intrusive_ptr<DbType> GetType(void) const;
virtual Dictionary::Ptr GetConfigFields(void) const = 0;
virtual Dictionary::Ptr GetStatusFields(void) const = 0;
double GetLastStatusUpdate(void) const;
protected:
- DbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);
+ DbObject(const intrusive_ptr<DbType>& type, const String& name1, const String& name2);
virtual bool IsStatusAttribute(const String& attribute) const;
private:
String m_Name1;
String m_Name2;
- shared_ptr<DbType> m_Type;
+ intrusive_ptr<DbType> m_Type;
DynamicObject::Ptr m_Object;
double m_LastConfigUpdate;
double m_LastStatusUpdate;
String IdColumn;
Dictionary::Ptr Fields;
Dictionary::Ptr WhereCriteria;
- shared_ptr<DbObject> Object;
- shared_ptr<CustomVarObject> NotificationObject;
+ intrusive_ptr<DbObject> Object;
+ intrusive_ptr<CustomVarObject> NotificationObject;
bool ConfigUpdate;
bool StatusUpdate;
}
#endif /* DBQUERY_H */
+
+#include "db_ido/dbobject.hpp"
if (it != m_Objects.end())
return it->second;
- DbObject::Ptr dbobj = m_ObjectFactory(GetSelf(), name1, name2);
+ DbObject::Ptr dbobj = m_ObjectFactory(this, name1, name2);
m_Objects[std::make_pair(name1, name2)] = dbobj;
return dbobj;
public:
DECLARE_PTR_TYPEDEFS(DbType);
- typedef boost::function<shared_ptr<DbObject> (const shared_ptr<DbType>&, const String&, const String&)> ObjectFactory;
+ typedef boost::function<intrusive_ptr<DbObject> (const intrusive_ptr<DbType>&, const String&, const String&)> ObjectFactory;
typedef std::map<String, DbType::Ptr> TypeMap;
- typedef std::map<std::pair<String, String>, shared_ptr<DbObject> > ObjectMap;
+ typedef std::map<std::pair<String, String>, intrusive_ptr<DbObject> > ObjectMap;
DbType(const String& table, long tid, const String& idcolumn, const ObjectFactory& factory);
static DbType::Ptr GetByName(const String& name);
static DbType::Ptr GetByID(long tid);
- shared_ptr<DbObject> GetOrCreateObjectByName(const String& name1, const String& name2);
+ intrusive_ptr<DbObject> GetOrCreateObjectByName(const String& name1, const String& name2);
static std::set<DbType::Ptr> GetAllTypes(void);
dbtype = DbType::GetByID(tid);
if (!dbtype)
- dbtype = make_shared<DbType>(table, tid, idcolumn, factory);
+ dbtype = new DbType(table, tid, idcolumn, factory);
DbType::RegisterType(name, dbtype);
}
* @ingroup ido
*/
template<typename T>
-shared_ptr<T> DbObjectFactory(const DbType::Ptr& type, const String& name1, const String& name2)
+intrusive_ptr<T> DbObjectFactory(const DbType::Ptr& type, const String& name1, const String& name2)
{
- return make_shared<T>(type, name1, name2);
+ return new T(type, name1, name2);
}
#define REGISTER_DBTYPE(name, table, tid, idcolumn, type) \
if (ts.IsEmpty() || ts == 0)
return Empty;
- return make_shared<DbValue>(DbValueTimestamp, ts);
+ return new DbValue(DbValueTimestamp, ts);
}
Value DbValue::FromTimestampNow(void)
{
- return make_shared<DbValue>(DbValueTimestampNow, Empty);
+ return new DbValue(DbValueTimestampNow, Empty);
}
Value DbValue::FromValue(const Value& value)
Value DbValue::FromObjectInsertID(const Value& value)
{
- return make_shared<DbValue>(DbValueObjectInsertID, value);
+ return new DbValue(DbValueObjectInsertID, value);
}
bool DbValue::IsTimestamp(const Value& value)
Dictionary::Ptr EndpointDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(GetObject());
fields->Set("identity", endpoint->GetName());
Dictionary::Ptr EndpointDbObject::GetStatusFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(GetObject());
Log(LogDebug, "EndpointDbObject")
query1.Table = "endpointstatus";
query1.Type = DbQueryUpdate;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("is_connected", (connected ? 1 : 0));
fields1->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
query1.Fields = fields1;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("endpoint_object_id", endpoint);
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query1.Table = "endpointstatus";
query1.Type = DbQueryInsert;
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("identity", endpoint->GetName());
fields1->Set("node", IcingaApplication::GetInstance()->GetNodeName());
fields1->Set("is_connected", EndpointIsConnected(endpoint));
public:
DECLARE_PTR_TYPEDEFS(EndpointDbObject);
- EndpointDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);
+ EndpointDbObject(const intrusive_ptr<DbType>& type, const String& name1, const String& name2);
static void StaticInitialize(void);
Dictionary::Ptr HostDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Host::Ptr host = static_pointer_cast<Host>(GetObject());
fields->Set("alias", CompatUtility::GetHostAlias(host));
Dictionary::Ptr HostDbObject::GetStatusFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Host::Ptr host = static_pointer_cast<Host>(GetObject());
CheckResult::Ptr cr = host->GetLastCheckResult();
<< "host parents: " << parent->GetName();
/* parents: host_id, parent_host_object_id */
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set(GetType()->GetTable() + "_id", DbValue::FromObjectInsertID(GetObject()));
fields1->Set("parent_host_object_id", parent);
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
Log(LogDebug, "HostDbObject")
<< "parent host: " << parent->GetName();
- Dictionary::Ptr fields2 = make_shared<Dictionary>();
+ Dictionary::Ptr fields2 = new Dictionary();
fields2->Set("host_object_id", parent);
fields2->Set("dependent_host_object_id", host);
fields2->Set("inherits_parent", 1);
Log(LogDebug, "HostDbObject")
<< "host contacts: " << user->GetName();
- Dictionary::Ptr fields_contact = make_shared<Dictionary>();
+ Dictionary::Ptr fields_contact = new Dictionary();
fields_contact->Set("host_id", DbValue::FromObjectInsertID(host));
fields_contact->Set("contact_object_id", user);
fields_contact->Set("instance_id", 0); /* DbConnection class fills in real ID */
Log(LogDebug, "HostDbObject")
<< "host contactgroups: " << usergroup->GetName();
- Dictionary::Ptr fields_contact = make_shared<Dictionary>();
+ Dictionary::Ptr fields_contact = new Dictionary();
fields_contact->Set("host_id", DbValue::FromObjectInsertID(host));
fields_contact->Set("contactgroup_object_id", usergroup);
fields_contact->Set("instance_id", 0); /* DbConnection class fills in real ID */
Dictionary::Ptr HostGroupDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
HostGroup::Ptr group = static_pointer_cast<HostGroup>(GetObject());
fields->Set("alias", group->GetDisplayName());
query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members";
query1.Type = DbQueryInsert;
query1.Category = DbCatConfig;
- query1.Fields = make_shared<Dictionary>();
+ query1.Fields = new Dictionary();
query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query1.Fields->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
query1.Fields->Set("host_object_id", host);
Dictionary::Ptr ServiceDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Service::Ptr service = static_pointer_cast<Service>(GetObject());
Host::Ptr host = service->GetHost();
Dictionary::Ptr ServiceDbObject::GetStatusFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
Service::Ptr service = static_pointer_cast<Service>(GetObject());
CheckResult::Ptr cr = service->GetLastCheckResult();
int state_filter = dep->GetStateFilter();
/* service dependencies */
- Dictionary::Ptr fields1 = make_shared<Dictionary>();
+ Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("service_object_id", parent);
fields1->Set("dependent_service_object_id", service);
fields1->Set("inherits_parent", 1);
Log(LogDebug, "ServiceDbObject")
<< "service contacts: " << user->GetName();
- Dictionary::Ptr fields_contact = make_shared<Dictionary>();
+ Dictionary::Ptr fields_contact = new Dictionary();
fields_contact->Set("service_id", DbValue::FromObjectInsertID(service));
fields_contact->Set("contact_object_id", user);
fields_contact->Set("instance_id", 0); /* DbConnection class fills in real ID */
Log(LogDebug, "ServiceDbObject")
<< "service contactgroups: " << usergroup->GetName();
- Dictionary::Ptr fields_contact = make_shared<Dictionary>();
+ Dictionary::Ptr fields_contact = new Dictionary();
fields_contact->Set("service_id", DbValue::FromObjectInsertID(service));
fields_contact->Set("contactgroup_object_id", usergroup);
fields_contact->Set("instance_id", 0); /* DbConnection class fills in real ID */
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
fields->Set("alias", group->GetDisplayName());
query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
query1.Type = DbQueryInsert;
query1.Category = DbCatConfig;
- query1.Fields = make_shared<Dictionary>();
+ query1.Fields = new Dictionary();
query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query1.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
query1.Fields->Set("service_object_id", service);
Dictionary::Ptr TimePeriodDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
TimePeriod::Ptr tp = static_pointer_cast<TimePeriod>(GetObject());
fields->Set("alias", tp->GetDisplayName());
query_del1.Table = GetType()->GetTable() + "_timeranges";
query_del1.Type = DbQueryDelete;
query_del1.Category = DbCatConfig;
- query_del1.WhereCriteria = make_shared<Dictionary>();
+ query_del1.WhereCriteria = new Dictionary();
query_del1.WhereCriteria->Set("timeperiod_id", DbValue::FromObjectInsertID(tp));
OnQuery(query_del1);
tm reference = Utility::LocalTime(refts);
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
ObjectLock olock(segments);
query.Table = GetType()->GetTable() + "_timeranges";
query.Type = DbQueryInsert;
query.Category = DbCatConfig;
- query.Fields = make_shared<Dictionary>();
+ query.Fields = new Dictionary();
query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query.Fields->Set("timeperiod_id", DbValue::FromObjectInsertID(tp));
query.Fields->Set("day", wday);
Dictionary::Ptr UserDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
User::Ptr user = static_pointer_cast<User>(GetObject());
fields->Set("alias", user->GetDisplayName());
Dictionary::Ptr UserDbObject::GetStatusFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
User::Ptr user = static_pointer_cast<User>(GetObject());
fields->Set("host_notifications_enabled", user->GetEnableNotifications());
void UserDbObject::OnConfigUpdate(void)
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
User::Ptr user = static_pointer_cast<User>(GetObject());
/* contact addresses */
Dictionary::Ptr UserGroupDbObject::GetConfigFields(void) const
{
- Dictionary::Ptr fields = make_shared<Dictionary>();
+ Dictionary::Ptr fields = new Dictionary();
UserGroup::Ptr group = static_pointer_cast<UserGroup>(GetObject());
fields->Set("alias", group->GetDisplayName());
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query1.Type = DbQueryDelete;
query1.Category = DbCatConfig;
- query1.WhereCriteria = make_shared<Dictionary>();
+ query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("instance_id", 0);
query1.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
OnQuery(query1);
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query2.Type = DbQueryInsert;
query2.Category = DbCatConfig;
- query2.Fields = make_shared<Dictionary>();
+ query2.Fields = new Dictionary();
query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.Fields->Set("contact_object_id", user);
Value IdoMysqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const IdoMysqlConnection::Ptr& idomysqlconnection, DynamicType::GetObjectsByType<IdoMysqlConnection>()) {
size_t items = idomysqlconnection->m_QueryQueue.GetLength();
- Dictionary::Ptr stats = make_shared<Dictionary>();
+ Dictionary::Ptr stats = new Dictionary();
stats->Set("version", SCHEMA_VERSION);
stats->Set("instance_name", idomysqlconnection->GetInstanceName());
stats->Set("query_queue_items", items);
nodes->Set(idomysqlconnection->GetName(), stats);
- perfdata->Add(make_shared<PerfdataValue>("idomysqlconnection_" + idomysqlconnection->GetName() + "_query_queue_items", items));
+ perfdata->Add(new PerfdataValue("idomysqlconnection_" + idomysqlconnection->GetName() + "_query_queue_items", items));
}
status->Set("idomysqlconnection", nodes);
m_QueryQueue.SetExceptionCallback(boost::bind(&IdoMysqlConnection::ExceptionHandler, this, _1));
- m_TxTimer = make_shared<Timer>();
+ m_TxTimer = new Timer();
m_TxTimer->SetInterval(1);
m_TxTimer->OnTimerExpired.connect(boost::bind(&IdoMysqlConnection::TxTimerHandler, this));
m_TxTimer->Start();
- m_ReconnectTimer = make_shared<Timer>();
+ m_ReconnectTimer = new Timer();
m_ReconnectTimer->SetInterval(10);
m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&IdoMysqlConnection::ReconnectTimerHandler, this));
m_ReconnectTimer->Start();
if (!lengths)
return Dictionary::Ptr();
- Dictionary::Ptr dict = make_shared<Dictionary>();
+ Dictionary::Ptr dict = new Dictionary();
mysql_field_seek(result.get(), 0);
for (field = mysql_fetch_field(result.get()), i = 0; field; field = mysql_fetch_field(result.get()), i++)
namespace icinga
{
-typedef shared_ptr<MYSQL_RES> IdoMysqlResult;
+typedef boost::shared_ptr<MYSQL_RES> IdoMysqlResult;
/**
* An IDO MySQL database connection.
Value IdoPgsqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const IdoPgsqlConnection::Ptr& idopgsqlconnection, DynamicType::GetObjectsByType<IdoPgsqlConnection>()) {
size_t items = idopgsqlconnection->m_QueryQueue.GetLength();
- Dictionary::Ptr stats = make_shared<Dictionary>();
+ Dictionary::Ptr stats = new Dictionary();
stats->Set("version", SCHEMA_VERSION);
stats->Set("instance_name", idopgsqlconnection->GetInstanceName());
stats->Set("query_queue_items", items);
nodes->Set(idopgsqlconnection->GetName(), stats);
- perfdata->Add(make_shared<PerfdataValue>("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_query_queue_items", items));
+ perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_query_queue_items", items));
}
status->Set("idopgsqlconnection", nodes);
m_QueryQueue.SetExceptionCallback(boost::bind(&IdoPgsqlConnection::ExceptionHandler, this, _1));
- m_TxTimer = make_shared<Timer>();
+ m_TxTimer = new Timer();
m_TxTimer->SetInterval(1);
m_TxTimer->OnTimerExpired.connect(boost::bind(&IdoPgsqlConnection::TxTimerHandler, this));
m_TxTimer->Start();
- m_ReconnectTimer = make_shared<Timer>();
+ m_ReconnectTimer = new Timer();
m_ReconnectTimer->SetInterval(10);
m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&IdoPgsqlConnection::ReconnectTimerHandler, this));
m_ReconnectTimer->Start();
int columns = PQnfields(result.get());
- Dictionary::Ptr dict = make_shared<Dictionary>();
+ Dictionary::Ptr dict = new Dictionary();
for (int column = 0; column < columns; column++) {
Value value;
namespace icinga
{
-typedef shared_ptr<PGresult> IdoPgsqlResult;
+typedef boost::shared_ptr<PGresult> IdoPgsqlResult;
/**
* An IDO pgSQL database connection.
{
DynamicObject::Start();
- m_DemoTimer = make_shared<Timer>();
+ m_DemoTimer = new Timer();
m_DemoTimer->SetInterval(5);
m_DemoTimer->OnTimerExpired.connect(boost::bind(&Demo::DemoTimerHandler, this));
m_DemoTimer->Start();
*/
void Demo::DemoTimerHandler(void)
{
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("method", "demo::HelloWorld");
ApiListener::Ptr listener = ApiListener::GetInstance();
Checkable::OnAcknowledgementSet.connect(&ApiEvents::AcknowledgementSetHandler);
Checkable::OnAcknowledgementCleared.connect(&ApiEvents::AcknowledgementClearedHandler);
- l_RepositoryTimer = make_shared<Timer>();
+ l_RepositoryTimer = new Timer();
l_RepositoryTimer->SetInterval(30);
l_RepositoryTimer->OnTimerExpired.connect(boost::bind(&ApiEvents::RepositoryTimerHandler));
l_RepositoryTimer->Start();
if (!listener)
return;
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::CheckResult");
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
if (!params)
return Empty;
- CheckResult::Ptr cr = make_shared<CheckResult>();
+ CheckResult::Ptr cr = new CheckResult();
Dictionary::Ptr vcr = params->Get("cr");
Array::Ptr vperf = vcr->Get("performance_data");
Deserialize(cr, params->Get("cr"), true);
- Array::Ptr rperf = make_shared<Array>();
+ Array::Ptr rperf = new Array();
if (vperf) {
ObjectLock olock(vperf);
Value p;
if (vp.IsObjectType<Dictionary>()) {
- PerfdataValue::Ptr val = make_shared<PerfdataValue>();
+ PerfdataValue::Ptr val = new PerfdataValue();
Deserialize(val, vp, true);
rperf->Add(val);
} else
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("next_check", nextCheck);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetNextCheck");
message->Set("params", params);
if (!listener)
return;
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("notification", notification->GetName());
params->Set("next_notification", nextNotification);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetNextNotification");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("forced", forced);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetForceNextCheck");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("forced", forced);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetForceNextNotification");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnableActiveChecks");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnablePassiveChecks");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnableNotifications");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnableFlapping");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnableEventHandler");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnablePerfdata");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("interval", interval);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckInterval");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("interval", interval);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetRetryInterval");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("attempts", attempts);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetMaxCheckAttempts");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("command", command->GetName());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEventCommand");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("command", command->GetName());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckCommand");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("timeperiod", timeperiod->GetName());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckPeriod");
message->Set("params", params);
if (!listener)
return;
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("object", object->GetName());
params->Set("vars", Serialize(vars));
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetVars");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("comment", Serialize(comment));
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::AddComment");
message->Set("params", params);
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
- Comment::Ptr comment = make_shared<Comment>();
+ Comment::Ptr comment = new Comment();
Deserialize(comment, params->Get("comment"), true);
checkable->AddComment(comment->GetEntryType(), comment->GetAuthor(),
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("id", comment->GetId());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::RemoveComment");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("downtime", Serialize(downtime));
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::AddDowntime");
message->Set("params", params);
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
- Downtime::Ptr downtime = make_shared<Downtime>();
+ Downtime::Ptr downtime = new Downtime();
Deserialize(downtime, params->Get("downtime"), true);
checkable->AddDowntime(downtime->GetAuthor(), downtime->GetComment(),
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("id", downtime->GetId());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::RemoveDowntime");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("acktype", type);
params->Set("expiry", expiry);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetAcknowledgement");
message->Set("params", params);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::ClearAcknowledgement");
message->Set("params", params);
if (!listener)
return;
- Dictionary::Ptr repository = make_shared<Dictionary>();
+ Dictionary::Ptr repository = new Dictionary();
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
- Array::Ptr services = make_shared<Array>();
+ Array::Ptr services = new Array();
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
services->Add(service->GetShortName());
Zone::Ptr my_zone = my_endpoint->GetZone();
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("seen", Utility::GetTime());
params->Set("endpoint", my_endpoint->GetName());
params->Set("zone", my_zone->GetName());
params->Set("repository", repository);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::UpdateRepository");
message->Set("params", params);
if (!listener)
return Empty;
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::UpdateRepository");
message->Set("params", params);
{
SetOverrideCheckCommand(command->GetName());
- OnCheckCommandChanged(GetSelf(), command, origin);
+ OnCheckCommandChanged(this, command, origin);
}
TimePeriod::Ptr Checkable::GetCheckPeriod(void) const
{
SetOverrideCheckPeriod(tp->GetName());
- OnCheckPeriodChanged(GetSelf(), tp, origin);
+ OnCheckPeriodChanged(this, tp, origin);
}
double Checkable::GetCheckInterval(void) const
{
SetOverrideCheckInterval(interval);
- OnCheckIntervalChanged(GetSelf(), interval, origin);
+ OnCheckIntervalChanged(this, interval, origin);
}
double Checkable::GetRetryInterval(void) const
{
SetOverrideRetryInterval(interval);
- OnRetryIntervalChanged(GetSelf(), interval, origin);
+ OnRetryIntervalChanged(this, interval, origin);
}
void Checkable::SetSchedulingOffset(long offset)
{
SetNextCheckRaw(nextCheck);
- OnNextCheckChanged(GetSelf(), nextCheck, origin);
+ OnNextCheckChanged(this, nextCheck, origin);
}
double Checkable::GetNextCheck(void)
{
SetOverrideEnableActiveChecks(enabled);
- OnEnableActiveChecksChanged(GetSelf(), enabled, origin);
+ OnEnableActiveChecksChanged(this, enabled, origin);
}
bool Checkable::GetEnablePassiveChecks(void) const
{
SetOverrideEnablePassiveChecks(enabled);
- OnEnablePassiveChecksChanged(GetSelf(), enabled, origin);
+ OnEnablePassiveChecksChanged(this, enabled, origin);
}
bool Checkable::GetForceNextCheck(void) const
{
SetForceNextCheckRaw(forced);
- OnForceNextCheckChanged(GetSelf(), forced, origin);
+ OnForceNextCheckChanged(this, forced, origin);
}
int Checkable::GetMaxCheckAttempts(void) const
{
SetOverrideMaxCheckAttempts(attempts);
- OnMaxCheckAttemptsChanged(GetSelf(), attempts, origin);
+ OnMaxCheckAttemptsChanged(this, attempts, origin);
}
void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin)
Host::Ptr host;
Service::Ptr service;
- tie(host, service) = GetHostService(GetSelf());
+ tie(host, service) = GetHostService(this);
CheckableType checkable_type = CheckableHost;
if (service)
if (remove_acknowledgement_comments)
RemoveCommentsByType(CommentAcknowledgement);
- Dictionary::Ptr vars_after = make_shared<Dictionary>();
+ Dictionary::Ptr vars_after = new Dictionary();
vars_after->Set("state", new_state);
vars_after->Set("state_type", GetStateType());
vars_after->Set("attempt", GetCheckAttempt());
// << " threshold: " << GetFlappingThreshold()
// << "% current: " + GetFlappingCurrent()) << "%.";
- OnNewCheckResult(GetSelf(), cr, origin);
+ OnNewCheckResult(this, cr, origin);
/* signal status updates to for example db_ido */
- OnStateChanged(GetSelf());
+ OnStateChanged(this);
String old_state_str = (service ? Service::StateToString(old_state) : Host::StateToString(Host::CalculateState(old_state)));
String new_state_str = (service ? Service::StateToString(new_state) : Host::StateToString(Host::CalculateState(new_state)));
if (hardChange) {
- OnStateChange(GetSelf(), cr, StateTypeHard, origin);
+ OnStateChange(this, cr, StateTypeHard, origin);
Log(LogNotice, "Checkable")
<< "State Change: Checkable " << GetName() << " hard state change from " << old_state_str << " to " << new_state_str << " detected.";
} else if (stateChange) {
- OnStateChange(GetSelf(), cr, StateTypeSoft, origin);
+ OnStateChange(this, cr, StateTypeSoft, origin);
Log(LogNotice, "Checkable")
<< "State Change: Checkable " << GetName() << " soft state change from " << old_state_str << " to " << new_state_str << " detected.";
}
ExecuteEventHandler();
if (send_downtime_notification)
- OnNotificationsRequested(GetSelf(), in_downtime ? NotificationDowntimeStart : NotificationDowntimeEnd, cr, "", "");
+ OnNotificationsRequested(this, in_downtime ? NotificationDowntimeStart : NotificationDowntimeEnd, cr, "", "");
if (!was_flapping && is_flapping) {
- OnNotificationsRequested(GetSelf(), NotificationFlappingStart, cr, "", "");
+ OnNotificationsRequested(this, NotificationFlappingStart, cr, "", "");
Log(LogNotice, "Checkable")
<< "Flapping: Checkable " << GetName() << " started flapping (" << GetFlappingThreshold() << "% < " << GetFlappingCurrent() << "%).";
- OnFlappingChanged(GetSelf(), FlappingStarted);
+ OnFlappingChanged(this, FlappingStarted);
} else if (was_flapping && !is_flapping) {
- OnNotificationsRequested(GetSelf(), NotificationFlappingEnd, cr, "", "");
+ OnNotificationsRequested(this, NotificationFlappingEnd, cr, "", "");
Log(LogNotice, "Checkable")
<< "Flapping: Checkable " << GetName() << " stopped flapping (" << GetFlappingThreshold() << "% >= " << GetFlappingCurrent() << "%).";
- OnFlappingChanged(GetSelf(), FlappingStopped);
+ OnFlappingChanged(this, FlappingStopped);
} else if (send_notification)
- OnNotificationsRequested(GetSelf(), recovery ? NotificationRecovery : NotificationProblem, cr, "", "");
+ OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", "");
}
bool Checkable::IsCheckPending(void) const
double scheduled_start = GetNextCheck();
double before_check = Utility::GetTime();
- Checkable::Ptr self = GetSelf();
-
- CheckResult::Ptr result = make_shared<CheckResult>();
+ CheckResult::Ptr result = new CheckResult();
result->SetScheduleStart(scheduled_start);
result->SetExecutionStart(before_check);
- GetCheckCommand()->Execute(GetSelf(), result);
+ GetCheckCommand()->Execute(this, result);
}
void Checkable::UpdateStatistics(const CheckResult::Ptr& cr, CheckableType type)
static int l_NextCommentID = 1;
static boost::mutex l_CommentMutex;
static std::map<int, String> l_LegacyCommentsCache;
-static std::map<String, Checkable::WeakPtr> l_CommentsCache;
+static std::map<String, Checkable::Ptr> l_CommentsCache;
static Timer::Ptr l_CommentsExpireTimer;
boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin&)> Checkable::OnCommentAdded;
else
uid = id;
- Comment::Ptr comment = make_shared<Comment>();
+ Comment::Ptr comment = new Comment();
comment->SetId(uid);;
comment->SetEntryTime(Utility::GetTime());
comment->SetEntryType(entryType);
{
boost::mutex::scoped_lock lock(l_CommentMutex);
l_LegacyCommentsCache[legacy_id] = uid;
- l_CommentsCache[uid] = GetSelf();
+ l_CommentsCache[uid] = this;
}
- OnCommentAdded(GetSelf(), comment, origin);
+ OnCommentAdded(this, comment, origin);
return uid;
}
{
boost::mutex::scoped_lock lock(l_CommentMutex);
- return l_CommentsCache[id].lock();
+ return l_CommentsCache[id];
}
Comment::Ptr Checkable::GetCommentByID(const String& id)
l_NextCommentID = legacy_id + 1;
l_LegacyCommentsCache[legacy_id] = kv.first;
- l_CommentsCache[kv.first] = GetSelf();
+ l_CommentsCache[kv.first] = this;
}
}
static int l_NextDowntimeID = 1;
static boost::mutex l_DowntimeMutex;
static std::map<int, String> l_LegacyDowntimesCache;
-static std::map<String, Checkable::WeakPtr> l_DowntimesCache;
+static std::map<String, Checkable::Ptr> l_DowntimesCache;
static Timer::Ptr l_DowntimesExpireTimer;
boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin&)> Checkable::OnDowntimeAdded;
else
uid = id;
- Downtime::Ptr downtime = make_shared<Downtime>();
+ Downtime::Ptr downtime = new Downtime();
downtime->SetId(uid);
downtime->SetEntryTime(Utility::GetTime());
downtime->SetAuthor(author);
{
boost::mutex::scoped_lock lock(l_DowntimeMutex);
l_LegacyDowntimesCache[legacy_id] = uid;
- l_DowntimesCache[uid] = GetSelf();
+ l_DowntimesCache[uid] = this;
}
Log(LogNotice, "Checkable")
<< "' between '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", startTime)
<< "' and '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", endTime) << "'.";
- OnDowntimeAdded(GetSelf(), downtime, origin);
+ OnDowntimeAdded(this, downtime, origin);
return uid;
}
Checkable::Ptr Checkable::GetOwnerByDowntimeID(const String& id)
{
boost::mutex::scoped_lock lock(l_DowntimeMutex);
- return l_DowntimesCache[id].lock();
+ return l_DowntimesCache[id];
}
Downtime::Ptr Checkable::GetDowntimeByID(const String& id)
void Checkable::StartDowntimesExpiredTimer(void)
{
- l_DowntimesExpireTimer = make_shared<Timer>();
+ l_DowntimesExpireTimer = new Timer();
l_DowntimesExpireTimer->SetInterval(60);
l_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Checkable::DowntimesExpireTimerHandler));
l_DowntimesExpireTimer->Start();
l_NextDowntimeID = legacy_id + 1;
l_LegacyDowntimesCache[legacy_id] = kv.first;
- l_DowntimesCache[kv.first] = GetSelf();
+ l_DowntimesCache[kv.first] = this;
}
}
{
SetOverrideEnableEventHandler(enabled);
- OnEnableEventHandlerChanged(GetSelf(), enabled, origin);
+ OnEnableEventHandlerChanged(this, enabled, origin);
}
EventCommand::Ptr Checkable::GetEventCommand(void) const
{
SetOverrideEventCommand(command->GetName());
- OnEventCommandChanged(GetSelf(), command, origin);
+ OnEventCommandChanged(this, command, origin);
}
void Checkable::ExecuteEventHandler(void)
Log(LogNotice, "Checkable")
<< "Executing event handler '" << ec->GetName() << "' for service '" << GetName() << "'";
- ec->Execute(GetSelf());
+ ec->Execute(this);
- OnEventCommandExecuted(GetSelf());
+ OnEventCommandExecuted(this);
}
{
SetOverrideEnableFlapping(enabled);
- OnFlappingChanged(GetSelf(), enabled ? FlappingEnabled : FlappingDisabled);
- OnEnableFlappingChanged(GetSelf(), enabled, origin);
+ OnFlappingChanged(this, enabled ? FlappingEnabled : FlappingDisabled);
+ OnEnableFlappingChanged(this, enabled, origin);
}
void Checkable::UpdateFlappingStatus(bool stateChange)
{
SetOverrideEnableNotifications(enabled);
- OnEnableNotificationsChanged(GetSelf(), enabled, origin);
+ OnEnableNotificationsChanged(this, enabled, origin);
}
bool Checkable::GetForceNextNotification(void) const
{
SetForceNextNotificationRaw(forced);
- OnForceNextNotificationChanged(GetSelf(), forced, origin);
+ OnForceNextNotificationChanged(this, forced, origin);
}
return;
if (!groups)
- groups = make_shared<Array>();
+ groups = new Array();
groups->Add(name);
}
SetAcknowledgementExpiry(expiry);
}
- OnNotificationsRequested(GetSelf(), NotificationAcknowledgement, GetLastCheckResult(), author, comment);
+ OnNotificationsRequested(this, NotificationAcknowledgement, GetLastCheckResult(), author, comment);
- OnAcknowledgementSet(GetSelf(), author, comment, type, expiry, origin);
+ OnAcknowledgementSet(this, author, comment, type, expiry, origin);
}
void Checkable::ClearAcknowledgement(const MessageOrigin& origin)
SetAcknowledgementRaw(AcknowledgementNone);
SetAcknowledgementExpiry(0);
- OnAcknowledgementCleared(GetSelf(), origin);
+ OnAcknowledgementCleared(this, origin);
}
bool Checkable::GetEnablePerfdata(void) const
{
SetOverrideEnablePerfdata(enabled);
- OnEnablePerfdataChanged(GetSelf(), enabled, origin);
+ OnEnablePerfdataChanged(this, enabled, origin);
}
int Checkable::GetModifiedAttributes(void) const
{
if ((flags & ModAttrNotificationsEnabled) == 0) {
SetOverrideEnableNotifications(Empty);
- OnEnableNotificationsChanged(GetSelf(), GetEnableNotifications(), origin);
+ OnEnableNotificationsChanged(this, GetEnableNotifications(), origin);
}
if ((flags & ModAttrActiveChecksEnabled) == 0) {
SetOverrideEnableActiveChecks(Empty);
- OnEnableActiveChecksChanged(GetSelf(), GetEnableActiveChecks(), origin);
+ OnEnableActiveChecksChanged(this, GetEnableActiveChecks(), origin);
}
if ((flags & ModAttrPassiveChecksEnabled) == 0) {
SetOverrideEnablePassiveChecks(Empty);
- OnEnablePassiveChecksChanged(GetSelf(), GetEnablePassiveChecks(), origin);
+ OnEnablePassiveChecksChanged(this, GetEnablePassiveChecks(), origin);
}
if ((flags & ModAttrFlapDetectionEnabled) == 0) {
SetOverrideEnableFlapping(Empty);
- OnEnableFlappingChanged(GetSelf(), GetEnableFlapping(), origin);
+ OnEnableFlappingChanged(this, GetEnableFlapping(), origin);
}
if ((flags & ModAttrEventHandlerEnabled) == 0)
if ((flags & ModAttrPerformanceDataEnabled) == 0) {
SetOverrideEnablePerfdata(Empty);
- OnEnablePerfdataChanged(GetSelf(), GetEnablePerfdata(), origin);
+ OnEnablePerfdataChanged(this, GetEnablePerfdata(), origin);
}
if ((flags & ModAttrNormalCheckInterval) == 0)
if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty);
- OnVarsChanged(GetSelf(), GetVars(), origin);
+ OnVarsChanged(this, GetVars(), origin);
}
}
//bool IsHostCheck(void) const;
- bool IsReachable(DependencyType dt = DependencyState, shared_ptr<Dependency> *failedDependency = NULL, int rstack = 0) const;
+ bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = NULL, int rstack = 0) const;
AcknowledgementType GetAcknowledgement(void);
void ClearAcknowledgement(const MessageOrigin& origin = MessageOrigin());
/* Checks */
- shared_ptr<CheckCommand> GetCheckCommand(void) const;
- void SetCheckCommand(const shared_ptr<CheckCommand>& command, const MessageOrigin& origin = MessageOrigin());
+ intrusive_ptr<CheckCommand> GetCheckCommand(void) const;
+ void SetCheckCommand(const intrusive_ptr<CheckCommand>& command, const MessageOrigin& origin = MessageOrigin());
TimePeriod::Ptr GetCheckPeriod(void) const;
void SetCheckPeriod(const TimePeriod::Ptr& tp, const MessageOrigin& origin = MessageOrigin());
static boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> OnCheckIntervalChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> OnRetryIntervalChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, int, const MessageOrigin&)> OnMaxCheckAttemptsChanged;
- static boost::signals2::signal<void (const Checkable::Ptr&, const shared_ptr<EventCommand>&, const MessageOrigin&)> OnEventCommandChanged;
- static boost::signals2::signal<void (const Checkable::Ptr&, const shared_ptr<CheckCommand>&, const MessageOrigin&)> OnCheckCommandChanged;
+ static boost::signals2::signal<void (const Checkable::Ptr&, const intrusive_ptr<EventCommand>&, const MessageOrigin&)> OnEventCommandChanged;
+ static boost::signals2::signal<void (const Checkable::Ptr&, const intrusive_ptr<CheckCommand>&, const MessageOrigin&)> OnCheckCommandChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const TimePeriod::Ptr&, const MessageOrigin&)> OnCheckPeriodChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin&)> OnNewCheckResult;
/* Event Handler */
void ExecuteEventHandler(void);
- shared_ptr<EventCommand> GetEventCommand(void) const;
- void SetEventCommand(const shared_ptr<EventCommand>& command, const MessageOrigin& origin = MessageOrigin());
+ intrusive_ptr<EventCommand> GetEventCommand(void) const;
+ void SetEventCommand(const intrusive_ptr<EventCommand>& command, const MessageOrigin& origin = MessageOrigin());
bool GetEnableEventHandler(void) const;
void SetEnableEventHandler(bool enabled, const MessageOrigin& origin = MessageOrigin());
void SetEnablePerfdata(bool enabled, const MessageOrigin& origin = MessageOrigin());
/* Dependencies */
- void AddDependency(const shared_ptr<Dependency>& dep);
- void RemoveDependency(const shared_ptr<Dependency>& dep);
- std::set<shared_ptr<Dependency> > GetDependencies(void) const;
+ void AddDependency(const intrusive_ptr<Dependency>& dep);
+ void RemoveDependency(const intrusive_ptr<Dependency>& dep);
+ std::set<intrusive_ptr<Dependency> > GetDependencies(void) const;
- void AddReverseDependency(const shared_ptr<Dependency>& dep);
- void RemoveReverseDependency(const shared_ptr<Dependency>& dep);
- std::set<shared_ptr<Dependency> > GetReverseDependencies(void) const;
+ void AddReverseDependency(const intrusive_ptr<Dependency>& dep);
+ void RemoveReverseDependency(const intrusive_ptr<Dependency>& dep);
+ std::set<intrusive_ptr<Dependency> > GetReverseDependencies(void) const;
protected:
virtual void Start(void);
/* Dependencies */
mutable boost::mutex m_DependencyMutex;
- std::set<shared_ptr<Dependency> > m_Dependencies;
- std::set<shared_ptr<Dependency> > m_ReverseDependencies;
+ std::set<intrusive_ptr<Dependency> > m_Dependencies;
+ std::set<intrusive_ptr<Dependency> > m_ReverseDependencies;
};
}
#endif /* CHECKABLE_H */
+
+#include "icinga/dependency.hpp"
abstract class Checkable : CustomVarObject
{
[config] Array::Ptr groups {
- default {{{ return make_shared<Array>(); }}}
+ default {{{ return new Array(); }}}
};
[config, protected] String check_command (CheckCommandRaw);
[config] int max_check_attempts (MaxCheckAttemptsRaw) {
};
[state] double acknowledgement_expiry;
[state] Dictionary::Ptr comments {
- default {{{ return make_shared<Dictionary>(); }}}
+ default {{{ return new Dictionary(); }}}
};
[state] Dictionary::Ptr downtimes {
- default {{{ return make_shared<Dictionary>(); }}}
+ default {{{ return new Dictionary(); }}}
};
[state] bool force_next_notification (ForceNextNotificationRaw);
[state] int flapping_positive;
*/
std::pair<Dictionary::Ptr, Array::Ptr> CIB::GetFeatureStats(void)
{
- Dictionary::Ptr status = make_shared<Dictionary>();
- Array::Ptr perfdata = make_shared<Array>();
+ Dictionary::Ptr status = new Dictionary();
+ Array::Ptr perfdata = new Array();
String name;
Value ret;
{
if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty);
- OnVarsChanged(GetSelf(), GetVars(), origin);
+ OnVarsChanged(this, GetVars(), origin);
}
}
{
CheckCommand::Ptr command = checkable->GetCheckCommand();
- Dictionary::Ptr args = make_shared<Dictionary>();
+ Dictionary::Ptr args = new Dictionary();
if (command) {
Host::Ptr host;
{
Dictionary::Ptr vars = object->GetVars();
- Dictionary::Ptr varsvars = make_shared<Dictionary>();
+ Dictionary::Ptr varsvars = new Dictionary();
if (!vars)
return Dictionary::Ptr();
Array::Ptr CompatUtility::GetModifiedAttributesList(const CustomVarObject::Ptr& object)
{
- Array::Ptr mod_attr_list = make_shared<Array>();
+ Array::Ptr mod_attr_list = new Array();
if (object->GetType() != DynamicType::GetByName("Host") &&
object->GetType() != DynamicType::GetByName("Service") &&
{
SetOverrideVars(vars);
- OnVarsChanged(GetSelf(), vars, origin);
+ OnVarsChanged(this, vars, origin);
}
int CustomVarObject::GetModifiedAttributes(void) const
Log(LogDebug, "Dependency")
<< "Applying dependency '" << name << "' to object '" << checkable->GetName() << "' for rule " << di;
- ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
+ ConfigItemBuilder::Ptr builder = new ConfigItemBuilder(di);
builder->SetType("Dependency");
builder->SetName(name);
builder->SetScope(locals);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("parent_host_name")), OpSetLiteral),
MakeLiteral(host->GetName()),
di));
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("child_host_name")), OpSetLiteral),
MakeLiteral(host->GetName()),
di));
if (service) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("child_service_name")), OpSetLiteral),
MakeLiteral(service->GetShortName()),
di));
String zone = checkable->GetZone();
if (!zone.IsEmpty()) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("zone")), OpSetLiteral),
MakeLiteral(zone),
di));
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
if (service)
if (rule.GetFTerm()) {
vinstances = rule.GetFTerm()->Evaluate(locals);
} else {
- Array::Ptr instances = make_shared<Array>();
+ Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
Log(LogWarning, "Dependency")
<< "Dependency '" << GetName() << "' references an invalid child object and will be ignored.";
else
- m_Child->AddDependency(GetSelf());
+ m_Child->AddDependency(this);
Host::Ptr parentHost = Host::GetByName(GetParentHostName());
Log(LogWarning, "Dependency")
<< "Dependency '" << GetName() << "' references an invalid parent object and will always fail.";
else
- m_Parent->AddReverseDependency(GetSelf());
+ m_Parent->AddReverseDependency(this);
}
void Dependency::Stop(void)
DynamicObject::Stop();
if (GetChild())
- GetChild()->RemoveDependency(GetSelf());
+ GetChild()->RemoveDependency(this);
if (GetParent())
- GetParent()->RemoveReverseDependency(GetSelf());
+ GetParent()->RemoveReverseDependency(this);
}
bool Dependency::IsAvailable(DependencyType dt) const
DECLARE_OBJECT(Dependency);
DECLARE_OBJECTNAME(Dependency);
- shared_ptr<Checkable> GetParent(void) const;
- shared_ptr<Checkable> GetChild(void) const;
+ intrusive_ptr<Checkable> GetParent(void) const;
+ intrusive_ptr<Checkable> GetChild(void) const;
TimePeriod::Ptr GetPeriod(void) const;
[state] String triggered_by;
[state] String scheduled_by;
[state] Dictionary::Ptr triggers {
- default {{{ return make_shared<Dictionary>(); }}}
+ default {{{ return new Dictionary(); }}}
};
[state] int legacy_id;
[state] bool was_cancelled;
eci.MaxArgs = (maxArgs == UINT_MAX) ? minArgs : maxArgs;
GetCommands()[command] = eci;
- ApiFunction::Ptr afunc = make_shared<ApiFunction>(boost::bind(&ExternalCommandAPIWrapper, command, _2));
+ ApiFunction::Ptr afunc = new ApiFunction(boost::bind(&ExternalCommandAPIWrapper, command, _2));
ApiFunction::Register("extcmd::" + command, afunc);
}
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
int exitStatus = Convert::ToDouble(arguments[1]);
- CheckResult::Ptr result = make_shared<CheckResult>();
+ CheckResult::Ptr result = new CheckResult();
std::pair<String, String> co = PluginUtility::ParseCheckOutput(arguments[2]);
result->SetOutput(co.first);
result->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
int exitStatus = Convert::ToDouble(arguments[2]);
- CheckResult::Ptr result = make_shared<CheckResult>();
+ CheckResult::Ptr result = new CheckResult();
std::pair<String, String> co = PluginUtility::ParseCheckOutput(arguments[3]);
result->SetOutput(co.first);
result->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
HostGroup::Ptr hg = HostGroup::GetByName(name);
if (hg)
- hg->ResolveGroupMembership(GetSelf(), true);
+ hg->ResolveGroupMembership(this, true);
}
}
}
HostGroup::Ptr hg = HostGroup::GetByName(name);
if (hg)
- hg->ResolveGroupMembership(GetSelf(), false);
+ hg->ResolveGroupMembership(this, false);
}
}
DECLARE_OBJECT(Host);
DECLARE_OBJECTNAME(Host);
- shared_ptr<Service> GetServiceByShortName(const Value& name);
+ intrusive_ptr<Service> GetServiceByShortName(const Value& name);
- std::set<shared_ptr<Service> > GetServices(void) const;
- void AddService(const shared_ptr<Service>& service);
- void RemoveService(const shared_ptr<Service>& service);
+ std::set<intrusive_ptr<Service> > GetServices(void) const;
+ void AddService(const intrusive_ptr<Service>& service);
+ void RemoveService(const intrusive_ptr<Service>& service);
int GetTotalServices(void) const;
private:
mutable boost::mutex m_ServicesMutex;
- std::map<String, shared_ptr<Service> > m_Services;
+ std::map<String, intrusive_ptr<Service> > m_Services;
static void RefreshServicesCache(void);
};
}
#endif /* HOST_H */
+
+#include "icinga/service.hpp"
msgbuf << "Evaluating 'object' rule (" << di << ")";
CONTEXT(msgbuf.str());
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
Value IcingaApplication::StatsFunc(Dictionary::Ptr& status, Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const IcingaApplication::Ptr& icingaapplication, DynamicType::GetObjectsByType<IcingaApplication>()) {
- Dictionary::Ptr stats = make_shared<Dictionary>();
+ Dictionary::Ptr stats = new Dictionary();
stats->Set("node_name", icingaapplication->GetNodeName());
stats->Set("enable_notifications", icingaapplication->GetEnableNotifications());
stats->Set("enable_event_handlers", icingaapplication->GetEnableEventHandlers());
Log(LogDebug, "IcingaApplication", "In IcingaApplication::Main()");
/* periodically dump the program state */
- l_RetentionTimer = make_shared<Timer>();
+ l_RetentionTimer = new Timer();
l_RetentionTimer->SetInterval(300);
l_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this));
l_RetentionTimer->Start();
Value IcingaStatusWriter::StatsFunc(Dictionary::Ptr& status, Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const IcingaStatusWriter::Ptr& icingastatuswriter, DynamicType::GetObjectsByType<IcingaStatusWriter>()) {
nodes->Set(icingastatuswriter->GetName(), 1); //add more stats
{
DynamicObject::Start();
- m_StatusTimer = make_shared<Timer>();
+ m_StatusTimer = new Timer();
m_StatusTimer->SetInterval(GetUpdateInterval());
m_StatusTimer->OnTimerExpired.connect(boost::bind(&IcingaStatusWriter::StatusTimerHandler, this));
m_StatusTimer->Start();
Dictionary::Ptr IcingaStatusWriter::GetStatusData(void)
{
- Dictionary::Ptr bag = make_shared<Dictionary>();
+ Dictionary::Ptr bag = new Dictionary();
/* features */
std::pair<Dictionary::Ptr, Array::Ptr> stats = CIB::GetFeatureStats();
bag->Set("feature_perfdata", stats.second);
/* icinga stats */
- Dictionary::Ptr icinga_stats = make_shared<Dictionary>();
+ Dictionary::Ptr icinga_stats = new Dictionary();
double interval = Utility::GetTime() - Application::GetStartTime();
{
tm begin, end;
ProcessTimeRangeRaw(timestamp, reference, &begin, &end);
- Dictionary::Ptr segment = make_shared<Dictionary>();
+ Dictionary::Ptr segment = new Dictionary();
segment->Set("begin", (long)mktime(&begin));
segment->Set("end", (long)mktime(&end));
return segment;
do {
if (IsInTimeRange(&begin, &end, stride, &iter)) {
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
ProcessTimeRanges(timeranges, &iter, segments);
Dictionary::Ptr bestSegment;
Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin, double end)
{
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
Dictionary::Ptr ranges = tp->GetRanges();
if (str.IsScalar()) {
result = InternalResolveMacros(str, resolvers, cr, missingMacro, escapeFn);
} else if (str.IsObjectType<Array>()) {
- Array::Ptr resultArr = make_shared<Array>();
+ Array::Ptr resultArr = new Array();
Array::Ptr arr = str;
ObjectLock olock(arr);
}
}
- MacroResolver::Ptr mresolver = dynamic_pointer_cast<MacroResolver>(resolver.second);
+ MacroResolver *mresolver = dynamic_cast<MacroResolver *>(resolver.second.get());
if (mresolver && mresolver->ResolveMacro(boost::algorithm::join(tokens, "."), cr, result))
return true;
Log(LogDebug, "Notification")
<< "Applying notification '" << name << "' to object '" << checkable->GetName() << "' for rule " << di;
- ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
+ ConfigItemBuilder::Ptr builder = new ConfigItemBuilder(di);
builder->SetType("Notification");
builder->SetName(name);
builder->SetScope(locals);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("host_name")), OpSetLiteral),
MakeLiteral(host->GetName()),
di));
if (service) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("service_name")), OpSetLiteral),
MakeLiteral(service->GetShortName()),
di));
String zone = checkable->GetZone();
if (!zone.IsEmpty()) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("zone")), OpSetLiteral),
MakeLiteral(zone),
di));
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
if (service)
if (rule.GetFTerm()) {
vinstances = rule.GetFTerm()->Evaluate(locals);
} else {
- Array::Ptr instances = make_shared<Array>();
+ Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
Checkable::Ptr obj = GetCheckable();
if (obj)
- obj->AddNotification(GetSelf());
+ obj->AddNotification(this);
}
void Notification::Start(void)
Checkable::Ptr obj = GetCheckable();
if (obj)
- obj->AddNotification(GetSelf());
+ obj->AddNotification(this);
}
void Notification::Stop(void)
Checkable::Ptr obj = GetCheckable();
if (obj)
- obj->RemoveNotification(GetSelf());
+ obj->RemoveNotification(this);
}
Checkable::Ptr Notification::GetCheckable(void) const
{
SetNextNotificationRaw(time);
- OnNextNotificationChanged(GetSelf(), time, origin);
+ OnNextNotificationChanged(this, time, origin);
}
void Notification::UpdateNotificationNumber(void)
std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
}
- Service::OnNotificationSendStart(GetSelf(), checkable, allUsers, type, cr, author, text);
+ Service::OnNotificationSendStart(this, checkable, allUsers, type, cr, author, text);
std::set<User::Ptr> allNotifiedUsers;
BOOST_FOREACH(const User::Ptr& user, allUsers) {
}
/* used in db_ido for notification history */
- Service::OnNotificationSentToAllUsers(GetSelf(), checkable, allNotifiedUsers, type, cr, author, text);
+ Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text);
}
bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force)
return;
}
- command->Execute(GetSelf(), user, cr, type, author, text);
+ command->Execute(this, user, cr, type, author, text);
{
ObjectLock olock(this);
}
/* required by compatlogger */
- Service::OnNotificationSentToUser(GetSelf(), GetCheckable(), user, type, cr, author, text, command->GetName());
+ Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, command->GetName());
Log(LogInformation, "Notification")
<< "Completed sending notification for object '" << GetCheckable()->GetName() << "'";
static void StaticInitialize(void);
- shared_ptr<Checkable> GetCheckable(void) const;
- shared_ptr<NotificationCommand> GetCommand(void) const;
+ intrusive_ptr<Checkable> GetCheckable(void) const;
+ intrusive_ptr<NotificationCommand> GetCommand(void) const;
TimePeriod::Ptr GetPeriod(void) const;
std::set<User::Ptr> GetUsers(void) const;
std::set<UserGroup::Ptr> GetUserGroups(void) const;
private:
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
- static void EvaluateApplyRuleOneInstance(const shared_ptr<Checkable>& checkable, const String& name, const Dictionary::Ptr& locals, const ApplyRule& rule);
- static bool EvaluateApplyRuleOne(const shared_ptr<Checkable>& checkable, const ApplyRule& rule);
+ static void EvaluateApplyRuleOneInstance(const intrusive_ptr<Checkable>& checkable, const String& name, const Dictionary::Ptr& locals, const ApplyRule& rule);
+ static bool EvaluateApplyRuleOne(const intrusive_ptr<Checkable>& checkable, const ApplyRule& rule);
static void EvaluateApplyRule(const ApplyRule& rule);
static void EvaluateApplyRules(const std::vector<ApplyRule>& rules);
};
DECLARE_OBJECT(NotificationCommand);
DECLARE_OBJECTNAME(NotificationCommand);
- virtual Dictionary::Ptr Execute(const shared_ptr<Notification>& notification,
+ virtual Dictionary::Ptr Execute(const intrusive_ptr<Notification>& notification,
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
const String& author, const String& comment);
};
if (!max.IsEmpty())
max = max * base;
- return make_shared<PerfdataValue>(label, value, counter, unit, warn, crit, min, max);
+ return new PerfdataValue(label, value, counter, unit, warn, crit, min, max);
}
String PerfdataValue::Format(void) const
if (!raw_arguments || raw_command.IsObjectType<Array>())
command = MacroProcessor::ResolveMacros(raw_command, macroResolvers, cr, NULL, Utility::EscapeShellArg);
else {
- Array::Ptr arr = make_shared<Array>();
+ Array::Ptr arr = new Array();
arr->Add(raw_command);
command = arr;
}
}
}
- Dictionary::Ptr envMacros = make_shared<Dictionary>();
+ Dictionary::Ptr envMacros = new Dictionary();
Dictionary::Ptr env = commandObj->GetEnv();
}
}
- Process::Ptr process = make_shared<Process>(Process::PrepareCommand(command), envMacros);
+ Process::Ptr process = new Process(Process::PrepareCommand(command), envMacros);
process->SetTimeout(commandObj->GetTimeout());
process->Run(boost::bind(callback, command, _1));
}
Array::Ptr PluginUtility::SplitPerfdata(const String& perfdata)
{
- Array::Ptr result = make_shared<Array>();
+ Array::Ptr result = new Array();
size_t begin = 0;
String multi_prefix;
Log(LogDebug, "ScheduledDowntime")
<< "Applying scheduled downtime '" << rule.GetName() << "' to object '" << checkable->GetName() << "' for rule " << di;
- ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
+ ConfigItemBuilder::Ptr builder = new ConfigItemBuilder(di);
builder->SetType("ScheduledDowntime");
builder->SetName(name);
builder->SetScope(locals);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("host_name")), OpSetLiteral),
MakeLiteral(host->GetName()),
di));
if (service) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("service_name")), OpSetLiteral),
MakeLiteral(service->GetShortName()),
di));
String zone = checkable->GetZone();
if (!zone.IsEmpty()) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("zone")), OpSetLiteral),
MakeLiteral(zone),
di));
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
if (service)
if (rule.GetFTerm()) {
vinstances = rule.GetFTerm()->Evaluate(locals);
} else {
- Array::Ptr instances = make_shared<Array>();
+ Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
void ScheduledDowntime::StaticInitialize(void)
{
- l_Timer = make_shared<Timer>();
+ l_Timer = new Timer();
l_Timer->SetInterval(60);
l_Timer->OnTimerExpired.connect(boost::bind(&ScheduledDowntime::TimerProc));
l_Timer->Start();
Dictionary::Ptr ranges = GetRanges();
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
Dictionary::Ptr bestSegment;
double bestBegin;
Log(LogDebug, "Service")
<< "Applying service '" << name << "' to host '" << host->GetName() << "' for rule " << di;
- ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
+ ConfigItemBuilder::Ptr builder = new ConfigItemBuilder(di);
builder->SetType("Service");
builder->SetName(name);
builder->SetScope(locals);
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("host_name")), OpSetLiteral),
MakeLiteral(host->GetName()),
di));
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("name")), OpSetLiteral),
MakeLiteral(name),
di));
String zone = host->GetZone();
if (!zone.IsEmpty()) {
- builder->AddExpression(make_shared<Expression>(&Expression::OpSet,
+ builder->AddExpression(new Expression(&Expression::OpSet,
MakeArray(MakeArray(MakeLiteral("zone")), OpSetLiteral),
MakeLiteral(zone),
di));
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
if (rule.GetFTerm()) {
vinstances = rule.GetFTerm()->Evaluate(locals);
} else {
- Array::Ptr instances = make_shared<Array>();
+ Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
if (sg)
- sg->ResolveGroupMembership(GetSelf(), true);
+ sg->ResolveGroupMembership(this, true);
}
}
m_Host = Host::GetByName(GetHostName());
if (m_Host)
- m_Host->AddService(GetSelf());
+ m_Host->AddService(this);
SetSchedulingOffset(Utility::Random());
Host::Ptr host = service->GetHost();
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
locals->Set("service", service);
void TimePeriod::StaticInitialize(void)
{
- l_UpdateTimer = make_shared<Timer>();
+ l_UpdateTimer = new Timer();
l_UpdateTimer->SetInterval(300);
l_UpdateTimer->OnTimerExpired.connect(boost::bind(&TimePeriod::UpdateTimerHandler));
l_UpdateTimer->Start();
}
/* Create new segment if we weren't able to merge this into an existing segment. */
- Dictionary::Ptr segment = make_shared<Dictionary>();
+ Dictionary::Ptr segment = new Dictionary();
segment->Set("begin", begin);
segment->Set("end", end);
if (!segments) {
- segments = make_shared<Array>();
+ segments = new Array();
SetSegments(segments);
}
if (!segments)
return;
- Array::Ptr newSegments = make_shared<Array>();
+ Array::Ptr newSegments = new Array();
/* Try to split or adjust an existing segment. */
ObjectLock dlock(segments);
if (!segments)
return;
- Array::Ptr newSegments = make_shared<Array>();
+ Array::Ptr newSegments = new Array();
/* Remove old segments. */
ObjectLock dlock(segments);
return;
}
- TimePeriod::Ptr self = GetSelf();
-
std::vector<Value> arguments;
- arguments.push_back(self);
+ arguments.push_back(this);
arguments.push_back(begin);
arguments.push_back(end);
UserGroup::Ptr ug = UserGroup::GetByName(name);
if (ug)
- ug->ResolveGroupMembership(GetSelf(), true);
+ ug->ResolveGroupMembership(this, true);
}
}
}
UserGroup::Ptr ug = UserGroup::GetByName(name);
if (ug)
- ug->ResolveGroupMembership(GetSelf(), false);
+ ug->ResolveGroupMembership(this, false);
}
}
}
return;
if (!groups)
- groups = make_shared<Array>();
+ groups = new Array();
groups->Add(name);
}
{
if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty);
- OnVarsChanged(GetSelf(), GetVars(), origin);
+ OnVarsChanged(this, GetVars(), origin);
}
}
{
SetOverrideEnableNotifications(enabled);
- OnEnableNotificationsChanged(GetSelf(), enabled, origin);
+ OnEnableNotificationsChanged(this, enabled, origin);
}
}}}
};
[config] Array::Ptr groups {
- default {{{ return make_shared<Array>(); }}}
+ default {{{ return new Array(); }}}
};
[config] String period (PeriodRaw);
[config] Array::Ptr types;
msgbuf << "Evaluating 'object' rule (" << di << ")";
CONTEXT(msgbuf.str());
- Dictionary::Ptr locals = make_shared<Dictionary>();
+ Dictionary::Ptr locals = new Dictionary();
locals->Set("__parent", rule.GetScope());
locals->Set("user", user);
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
BOOST_FOREACH(tie(key, value), vars) {
- Array::Ptr key_val = make_shared<Array>();
+ Array::Ptr key_val = new Array();
key_val->Add(key);
key_val->Add(value);
cv->Add(key_val);
if(!user_group)
return Empty;
- Array::Ptr members = make_shared<Array>();
+ Array::Ptr members = new Array();
BOOST_FOREACH(const User::Ptr& user, user_group->GetMembers()) {
members->Add(user->GetName());
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
- Array::Ptr key_val = make_shared<Array>();
+ Array::Ptr key_val = new Array();
key_val->Add(kv.first);
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
Value HostGroupsTable::MembersAccessor(const Value& row)
{
- Array::Ptr members = make_shared<Array>();
+ Array::Ptr members = new Array();
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
members->Add(host->GetName());
Value HostGroupsTable::MembersWithStateAccessor(const Value& row)
{
- Array::Ptr members = make_shared<Array>();
+ Array::Ptr members = new Array();
BOOST_FOREACH(const Host::Ptr& host, static_cast<HostGroup::Ptr>(row)->GetMembers()) {
- Array::Ptr member_state = make_shared<Array>();
+ Array::Ptr member_state = new Array();
member_state->Add(host->GetName());
member_state->Add(host->GetState());
members->Add(member_state);
if (!host)
return Empty;
- Array::Ptr contact_names = make_shared<Array>();
+ Array::Ptr contact_names = new Array();
BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(host)) {
contact_names->Add(user->GetName());
Dictionary::Ptr downtimes = host->GetDowntimes();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(downtimes);
Dictionary::Ptr downtimes = host->GetDowntimes();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(downtimes);
if (downtime->IsExpired())
continue;
- Array::Ptr downtime_info = make_shared<Array>();
+ Array::Ptr downtime_info = new Array();
downtime_info->Add(downtime->GetLegacyId());
downtime_info->Add(downtime->GetAuthor());
downtime_info->Add(downtime->GetComment());
Dictionary::Ptr comments = host->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
Dictionary::Ptr comments = host->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
if (comment->IsExpired())
continue;
- Array::Ptr comment_info = make_shared<Array>();
+ Array::Ptr comment_info = new Array();
comment_info->Add(comment->GetLegacyId());
comment_info->Add(comment->GetAuthor());
comment_info->Add(comment->GetText());
Dictionary::Ptr comments = host->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
if (comment->IsExpired())
continue;
- Array::Ptr comment_info = make_shared<Array>();
+ Array::Ptr comment_info = new Array();
comment_info->Add(comment->GetLegacyId());
comment_info->Add(comment->GetAuthor());
comment_info->Add(comment->GetText());
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
- Array::Ptr key_val = make_shared<Array>();
+ Array::Ptr key_val = new Array();
key_val->Add(kv.first);
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
if (!host)
return Empty;
- Array::Ptr parents = make_shared<Array>();
+ Array::Ptr parents = new Array();
BOOST_FOREACH(const Checkable::Ptr& parent, host->GetParents()) {
Host::Ptr parent_host = dynamic_pointer_cast<Host>(parent);
if (!host)
return Empty;
- Array::Ptr childs = make_shared<Array>();
+ Array::Ptr childs = new Array();
BOOST_FOREACH(const Checkable::Ptr& child, host->GetChildren()) {
Host::Ptr child_host = dynamic_pointer_cast<Host>(child);
if (!host)
return Empty;
- Array::Ptr contactgroup_names = make_shared<Array>();
+ Array::Ptr contactgroup_names = new Array();
BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(host)) {
contactgroup_names->Add(usergroup->GetName());
if (!host)
return Empty;
- Array::Ptr services = make_shared<Array>();
+ Array::Ptr services = new Array();
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
services->Add(service->GetShortName());
if (!host)
return Empty;
- Array::Ptr services = make_shared<Array>();
+ Array::Ptr services = new Array();
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
- Array::Ptr svc_add = make_shared<Array>();
+ Array::Ptr svc_add = new Array();
svc_add->Add(service->GetShortName());
svc_add->Add(service->GetState());
if (!host)
return Empty;
- Array::Ptr services = make_shared<Array>();
+ Array::Ptr services = new Array();
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
- Array::Ptr svc_add = make_shared<Array>();
+ Array::Ptr svc_add = new Array();
svc_add->Add(service->GetShortName());
svc_add->Add(service->GetState());
Value LivestatusListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const LivestatusListener::Ptr& livestatuslistener, DynamicType::GetObjectsByType<LivestatusListener>()) {
- Dictionary::Ptr stats = make_shared<Dictionary>();
+ Dictionary::Ptr stats = new Dictionary();
stats->Set("connections", l_Connections);
nodes->Set(livestatuslistener->GetName(), stats);
- perfdata->Add(make_shared<PerfdataValue>("livestatuslistener_" + livestatuslistener->GetName() + "_connections", l_Connections));
+ perfdata->Add(new PerfdataValue("livestatuslistener_" + livestatuslistener->GetName() + "_connections", l_Connections));
}
status->Set("livestatuslistener", nodes);
DynamicObject::Start();
if (GetSocketType() == "tcp") {
- TcpSocket::Ptr socket = make_shared<TcpSocket>();
+ TcpSocket::Ptr socket = new TcpSocket();
try {
socket->Bind(GetBindHost(), GetBindPort(), AF_UNSPEC);
} catch (std::exception&) {
}
else if (GetSocketType() == "unix") {
#ifndef _WIN32
- UnixSocket::Ptr socket = make_shared<UnixSocket>();
+ UnixSocket::Ptr socket = new UnixSocket();
try {
socket->Bind(GetSocketPath());
} catch (std::exception&) {
l_Connections++;
}
- Stream::Ptr stream = make_shared<NetworkStream>(client);
+ Stream::Ptr stream = new NetworkStream(client);
for (;;) {
String line;
if (lines.empty())
break;
- LivestatusQuery::Ptr query = make_shared<LivestatusQuery>(lines, GetCompatLogPath());
+ LivestatusQuery::Ptr query = new LivestatusQuery(lines, GetCompatLogPath());
if (!query->Execute(stream))
break;
}
Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
{
- Dictionary::Ptr bag = make_shared<Dictionary>();
+ Dictionary::Ptr bag = new Dictionary();
/*
* [1379025342] SERVICE NOTIFICATION: contactname;hostname;servicedesc;WARNING;true;foo output
Filter::Ptr filter;
if (aggregate_arg == "sum") {
- aggregator = make_shared<SumAggregator>(aggregate_attr);
+ aggregator = new SumAggregator(aggregate_attr);
} else if (aggregate_arg == "min") {
- aggregator = make_shared<MinAggregator>(aggregate_attr);
+ aggregator = new MinAggregator(aggregate_attr);
} else if (aggregate_arg == "max") {
- aggregator = make_shared<MaxAggregator>(aggregate_attr);
+ aggregator = new MaxAggregator(aggregate_attr);
} else if (aggregate_arg == "avg") {
- aggregator = make_shared<AvgAggregator>(aggregate_attr);
+ aggregator = new AvgAggregator(aggregate_attr);
} else if (aggregate_arg == "std") {
- aggregator = make_shared<StdAggregator>(aggregate_attr);
+ aggregator = new StdAggregator(aggregate_attr);
} else if (aggregate_arg == "suminv") {
- aggregator = make_shared<InvSumAggregator>(aggregate_attr);
+ aggregator = new InvSumAggregator(aggregate_attr);
} else if (aggregate_arg == "avginv") {
- aggregator = make_shared<InvAvgAggregator>(aggregate_attr);
+ aggregator = new InvAvgAggregator(aggregate_attr);
} else {
filter = ParseFilter(params, m_LogTimeFrom, m_LogTimeUntil);
return;
}
- aggregator = make_shared<CountAggregator>();
+ aggregator = new CountAggregator();
}
aggregator->SetFilter(filter);
CombinerFilter::Ptr filter;
if (header == "Or" || header == "StatsOr") {
- filter = make_shared<OrFilter>();
+ filter = new OrFilter();
Log(LogDebug, "LivestatusQuery")
<< "Add OR filter for " << params << " column(s). " << deq.size() << " filters available.";
} else {
- filter = make_shared<AndFilter>();
+ filter = new AndFilter();
Log(LogDebug, "LivestatusQuery")
<< "Add AND filter for " << params << " column(s). " << deq.size() << " filters available.";
}
deq.push_back(filter);
if (&deq == &stats) {
- Aggregator::Ptr aggregator = make_shared<CountAggregator>();
+ Aggregator::Ptr aggregator = new CountAggregator();
aggregator->SetFilter(filter);
aggregators.push_back(aggregator);
}
return;
}
- deq.push_back(make_shared<NegateFilter>(filter));
+ deq.push_back(new NegateFilter(filter));
if (deq == stats) {
Aggregator::Ptr aggregator = aggregators.back();
}
/* Combine all top-level filters into a single filter. */
- AndFilter::Ptr top_filter = make_shared<AndFilter>();
+ AndFilter::Ptr top_filter = new AndFilter();
BOOST_FOREACH(const Filter::Ptr& filter, filters) {
top_filter->AddSubFilter(filter);
negate = true;
}
- Filter::Ptr filter = make_shared<AttributeFilter>(attr, op, val);
+ Filter::Ptr filter = new AttributeFilter(attr, op, val);
if (negate)
- filter = make_shared<NegateFilter>(filter);
+ filter = new NegateFilter(filter);
/* pre-filter log time duration */
if (attr == "time") {
else
columns = table->GetColumnNames();
- Array::Ptr rs = make_shared<Array>();
+ Array::Ptr rs = new Array();
if (m_Aggregators.empty()) {
- Array::Ptr header = make_shared<Array>();
+ Array::Ptr header = new Array();
BOOST_FOREACH(const Value& object, objects) {
- Array::Ptr row = make_shared<Array>();
+ Array::Ptr row = new Array();
BOOST_FOREACH(const String& columnName, columns) {
Column column = table->GetColumn(columnName);
/* add column headers both for raw and aggregated data */
if (m_ColumnHeaders) {
- Array::Ptr header = make_shared<Array>();
+ Array::Ptr header = new Array();
BOOST_FOREACH(const String& columnName, m_Columns) {
header->Add(columnName);
rs->Add(header);
}
- Array::Ptr row = make_shared<Array>();
+ Array::Ptr row = new Array();
/*
* add selected columns next to stats
Value ServiceGroupsTable::MembersAccessor(const Value& row)
{
- Array::Ptr members = make_shared<Array>();
+ Array::Ptr members = new Array();
BOOST_FOREACH(const Service::Ptr& service, static_cast<ServiceGroup::Ptr>(row)->GetMembers()) {
- Array::Ptr host_svc = make_shared<Array>();
+ Array::Ptr host_svc = new Array();
host_svc->Add(service->GetHost()->GetName());
host_svc->Add(service->GetShortName());
members->Add(host_svc);
Value ServiceGroupsTable::MembersWithStateAccessor(const Value& row)
{
- Array::Ptr members = make_shared<Array>();
+ Array::Ptr members = new Array();
BOOST_FOREACH(const Service::Ptr& service, static_cast<ServiceGroup::Ptr>(row)->GetMembers()) {
- Array::Ptr host_svc = make_shared<Array>();
+ Array::Ptr host_svc = new Array();
host_svc->Add(service->GetHost()->GetName());
host_svc->Add(service->GetShortName());
host_svc->Add(service->GetHost()->GetState());
if (!service)
return Empty;
- Array::Ptr contact_names = make_shared<Array>();
+ Array::Ptr contact_names = new Array();
BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
contact_names->Add(user->GetName());
Dictionary::Ptr downtimes = service->GetDowntimes();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(downtimes);
Dictionary::Ptr downtimes = service->GetDowntimes();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(downtimes);
if (downtime->IsExpired())
continue;
- Array::Ptr downtime_info = make_shared<Array>();
+ Array::Ptr downtime_info = new Array();
downtime_info->Add(downtime->GetLegacyId());
downtime_info->Add(downtime->GetAuthor());
downtime_info->Add(downtime->GetComment());
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
if (comment->IsExpired())
continue;
- Array::Ptr comment_info = make_shared<Array>();
+ Array::Ptr comment_info = new Array();
comment_info->Add(comment->GetLegacyId());
comment_info->Add(comment->GetAuthor());
comment_info->Add(comment->GetText());
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = make_shared<Array>();
+ Array::Ptr ids = new Array();
ObjectLock olock(comments);
if (comment->IsExpired())
continue;
- Array::Ptr comment_info = make_shared<Array>();
+ Array::Ptr comment_info = new Array();
comment_info->Add(comment->GetLegacyId());
comment_info->Add(comment->GetAuthor());
comment_info->Add(comment->GetText());
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
- Array::Ptr key_val = make_shared<Array>();
+ Array::Ptr key_val = new Array();
key_val->Add(kv.first);
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
if (!service)
return Empty;
- Array::Ptr contactgroup_names = make_shared<Array>();
+ Array::Ptr contactgroup_names = new Array();
BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
contactgroup_names->Add(usergroup->GetName());
if (m_CheckablesCache.find(checkable) == m_CheckablesCache.end()) {
/* create new values */
- state_hist_service_states = make_shared<Array>();
- state_hist_bag = make_shared<Dictionary>();
+ state_hist_service_states = new Array();
+ state_hist_bag = new Dictionary();
Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
Host::Ptr host;
state_hist_bag->Set("until", time); /* add until record for duration calculation */
/* 2. add new state_hist_bag */
- Dictionary::Ptr state_hist_bag_new = make_shared<Dictionary>();
+ Dictionary::Ptr state_hist_bag_new = new Dictionary();
state_hist_bag_new->Set("host_name", state_hist_bag->Get("host_name"));
state_hist_bag_new->Set("service_description", state_hist_bag->Get("service_description"));
void StatusTable::FetchRows(const AddRowFunction& addRowFn)
{
- Object::Ptr obj = make_shared<Object>();
+ Object::Ptr obj = new Object();
/* Return a fake row. */
addRowFn(obj);
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
if (!vars)
return Empty;
- Array::Ptr cv = make_shared<Array>();
+ Array::Ptr cv = new Array();
String key;
Value value;
BOOST_FOREACH(tie(key, value), vars) {
- Array::Ptr key_val = make_shared<Array>();
+ Array::Ptr key_val = new Array();
key_val->Add(key);
key_val->Add(value);
cv->Add(key_val);
Table::Ptr Table::GetByName(const String& name, const String& compat_log_path, const unsigned long& from, const unsigned long& until)
{
if (name == "status")
- return make_shared<StatusTable>();
+ return new StatusTable();
else if (name == "contactgroups")
- return make_shared<ContactGroupsTable>();
+ return new ContactGroupsTable();
else if (name == "contacts")
- return make_shared<ContactsTable>();
+ return new ContactsTable();
else if (name == "hostgroups")
- return make_shared<HostGroupsTable>();
+ return new HostGroupsTable();
else if (name == "hosts")
- return make_shared<HostsTable>();
+ return new HostsTable();
else if (name == "servicegroups")
- return make_shared<ServiceGroupsTable>();
+ return new ServiceGroupsTable();
else if (name == "services")
- return make_shared<ServicesTable>();
+ return new ServicesTable();
else if (name == "commands")
- return make_shared<CommandsTable>();
+ return new CommandsTable();
else if (name == "comments")
- return make_shared<CommentsTable>();
+ return new CommentsTable();
else if (name == "downtimes")
- return make_shared<DowntimesTable>();
+ return new DowntimesTable();
else if (name == "timeperiods")
- return make_shared<TimePeriodsTable>();
+ return new TimePeriodsTable();
else if (name == "log")
- return make_shared<LogTable>(compat_log_path, from, until);
+ return new LogTable(compat_log_path, from, until);
else if (name == "statehist")
- return make_shared<StateHistTable>(compat_log_path, from, until);
+ return new StateHistTable(compat_log_path, from, until);
else if (name == "endpoints")
- return make_shared<EndpointsTable>();
+ return new EndpointsTable();
return Table::Ptr();
}
void Table::FilteredAddRow(std::vector<Value>& rs, const Filter::Ptr& filter, const Value& row)
{
- if (!filter || filter->Apply(GetSelf(), row))
+ if (!filter || filter->Apply(this, row))
rs.push_back(row);
}
Value Table::EmptyArrayAccessor(const Value&)
{
- return make_shared<Array>();
+ return new Array();
}
Value Table::EmptyDictionaryAccessor(const Value&)
{
- return make_shared<Dictionary>();
+ return new Dictionary();
}
virtual String GetName(void) const = 0;
virtual String GetPrefix(void) const = 0;
- std::vector<Value> FilterRows(const shared_ptr<Filter>& filter);
+ std::vector<Value> FilterRows(const intrusive_ptr<Filter>& filter);
void AddColumn(const String& name, const Column& column);
Column GetColumn(const String& name) const;
private:
std::map<String, Column> m_Columns;
- void FilteredAddRow(std::vector<Value>& rs, const shared_ptr<Filter>& filter, const Value& row);
+ void FilteredAddRow(std::vector<Value>& rs, const intrusive_ptr<Filter>& filter, const Value& row);
};
}
#endif /* TABLE_H */
+
+#include "livestatus/filter.hpp"
resolvers.push_back(std::make_pair("command", commandObj));
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- Dictionary::Ptr envMacros = make_shared<Dictionary>();
+ Dictionary::Ptr envMacros = new Dictionary();
Dictionary::Ptr env = commandObj->GetEnv();
if (interval > 60)
interval = 60;
- Array::Ptr perfdata = make_shared<Array>();
-
- perfdata->Add(make_shared<PerfdataValue>("active_host_checks", CIB::GetActiveHostChecksStatistics(interval) / interval));
- perfdata->Add(make_shared<PerfdataValue>("passive_host_checks", CIB::GetPassiveHostChecksStatistics(interval) / interval));
- perfdata->Add(make_shared<PerfdataValue>("active_host_checks_1min", CIB::GetActiveHostChecksStatistics(60)));
- perfdata->Add(make_shared<PerfdataValue>("passive_host_checks_1min", CIB::GetPassiveHostChecksStatistics(60)));
- perfdata->Add(make_shared<PerfdataValue>("active_host_checks_5min", CIB::GetActiveHostChecksStatistics(60 * 5)));
- perfdata->Add(make_shared<PerfdataValue>("passive_host_checks_5min", CIB::GetPassiveHostChecksStatistics(60 * 5)));
- perfdata->Add(make_shared<PerfdataValue>("active_host_checks_15min", CIB::GetActiveHostChecksStatistics(60 * 15)));
- perfdata->Add(make_shared<PerfdataValue>("passive_host_checks_15min", CIB::GetPassiveHostChecksStatistics(60 * 15)));
-
- perfdata->Add(make_shared<PerfdataValue>("active_service_checks", CIB::GetActiveServiceChecksStatistics(interval) / interval));
- perfdata->Add(make_shared<PerfdataValue>("passive_service_checks", CIB::GetPassiveServiceChecksStatistics(interval) / interval));
- perfdata->Add(make_shared<PerfdataValue>("active_service_checks_1min", CIB::GetActiveServiceChecksStatistics(60)));
- perfdata->Add(make_shared<PerfdataValue>("passive_service_checks_1min", CIB::GetPassiveServiceChecksStatistics(60)));
- perfdata->Add(make_shared<PerfdataValue>("active_service_checks_5min", CIB::GetActiveServiceChecksStatistics(60 * 5)));
- perfdata->Add(make_shared<PerfdataValue>("passive_service_checks_5min", CIB::GetPassiveServiceChecksStatistics(60 * 5)));
- perfdata->Add(make_shared<PerfdataValue>("active_service_checks_15min", CIB::GetActiveServiceChecksStatistics(60 * 15)));
- perfdata->Add(make_shared<PerfdataValue>("passive_service_checks_15min", CIB::GetPassiveServiceChecksStatistics(60 * 15)));
+ Array::Ptr perfdata = new Array();
+
+ perfdata->Add(new PerfdataValue("active_host_checks", CIB::GetActiveHostChecksStatistics(interval) / interval));
+ perfdata->Add(new PerfdataValue("passive_host_checks", CIB::GetPassiveHostChecksStatistics(interval) / interval));
+ perfdata->Add(new PerfdataValue("active_host_checks_1min", CIB::GetActiveHostChecksStatistics(60)));
+ perfdata->Add(new PerfdataValue("passive_host_checks_1min", CIB::GetPassiveHostChecksStatistics(60)));
+ perfdata->Add(new PerfdataValue("active_host_checks_5min", CIB::GetActiveHostChecksStatistics(60 * 5)));
+ perfdata->Add(new PerfdataValue("passive_host_checks_5min", CIB::GetPassiveHostChecksStatistics(60 * 5)));
+ perfdata->Add(new PerfdataValue("active_host_checks_15min", CIB::GetActiveHostChecksStatistics(60 * 15)));
+ perfdata->Add(new PerfdataValue("passive_host_checks_15min", CIB::GetPassiveHostChecksStatistics(60 * 15)));
+
+ perfdata->Add(new PerfdataValue("active_service_checks", CIB::GetActiveServiceChecksStatistics(interval) / interval));
+ perfdata->Add(new PerfdataValue("passive_service_checks", CIB::GetPassiveServiceChecksStatistics(interval) / interval));
+ perfdata->Add(new PerfdataValue("active_service_checks_1min", CIB::GetActiveServiceChecksStatistics(60)));
+ perfdata->Add(new PerfdataValue("passive_service_checks_1min", CIB::GetPassiveServiceChecksStatistics(60)));
+ perfdata->Add(new PerfdataValue("active_service_checks_5min", CIB::GetActiveServiceChecksStatistics(60 * 5)));
+ perfdata->Add(new PerfdataValue("passive_service_checks_5min", CIB::GetPassiveServiceChecksStatistics(60 * 5)));
+ perfdata->Add(new PerfdataValue("active_service_checks_15min", CIB::GetActiveServiceChecksStatistics(60 * 15)));
+ perfdata->Add(new PerfdataValue("passive_service_checks_15min", CIB::GetPassiveServiceChecksStatistics(60 * 15)));
CheckableCheckStatistics scs = CIB::CalculateServiceCheckStats();
- perfdata->Add(make_shared<PerfdataValue>("min_latency", scs.min_latency));
- perfdata->Add(make_shared<PerfdataValue>("max_latency", scs.max_latency));
- perfdata->Add(make_shared<PerfdataValue>("avg_latency", scs.avg_latency));
- perfdata->Add(make_shared<PerfdataValue>("min_execution_time", scs.min_latency));
- perfdata->Add(make_shared<PerfdataValue>("max_execution_time", scs.max_latency));
- perfdata->Add(make_shared<PerfdataValue>("avg_execution_time", scs.avg_execution_time));
+ perfdata->Add(new PerfdataValue("min_latency", scs.min_latency));
+ perfdata->Add(new PerfdataValue("max_latency", scs.max_latency));
+ perfdata->Add(new PerfdataValue("avg_latency", scs.avg_latency));
+ perfdata->Add(new PerfdataValue("min_execution_time", scs.min_latency));
+ perfdata->Add(new PerfdataValue("max_execution_time", scs.max_latency));
+ perfdata->Add(new PerfdataValue("avg_execution_time", scs.avg_execution_time));
ServiceStatistics ss = CIB::CalculateServiceStats();
- perfdata->Add(make_shared<PerfdataValue>("num_services_ok", ss.services_ok));
- perfdata->Add(make_shared<PerfdataValue>("num_services_warning", ss.services_warning));
- perfdata->Add(make_shared<PerfdataValue>("num_services_critical", ss.services_critical));
- perfdata->Add(make_shared<PerfdataValue>("num_services_unknown", ss.services_unknown));
- perfdata->Add(make_shared<PerfdataValue>("num_services_pending", ss.services_pending));
- perfdata->Add(make_shared<PerfdataValue>("num_services_unreachable", ss.services_unreachable));
- perfdata->Add(make_shared<PerfdataValue>("num_services_flapping", ss.services_flapping));
- perfdata->Add(make_shared<PerfdataValue>("num_services_in_downtime", ss.services_in_downtime));
- perfdata->Add(make_shared<PerfdataValue>("num_services_acknowledged", ss.services_acknowledged));
+ perfdata->Add(new PerfdataValue("num_services_ok", ss.services_ok));
+ perfdata->Add(new PerfdataValue("num_services_warning", ss.services_warning));
+ perfdata->Add(new PerfdataValue("num_services_critical", ss.services_critical));
+ perfdata->Add(new PerfdataValue("num_services_unknown", ss.services_unknown));
+ perfdata->Add(new PerfdataValue("num_services_pending", ss.services_pending));
+ perfdata->Add(new PerfdataValue("num_services_unreachable", ss.services_unreachable));
+ perfdata->Add(new PerfdataValue("num_services_flapping", ss.services_flapping));
+ perfdata->Add(new PerfdataValue("num_services_in_downtime", ss.services_in_downtime));
+ perfdata->Add(new PerfdataValue("num_services_acknowledged", ss.services_acknowledged));
double uptime = Utility::GetTime() - Application::GetStartTime();
- perfdata->Add(make_shared<PerfdataValue>("uptime", uptime));
+ perfdata->Add(new PerfdataValue("uptime", uptime));
HostStatistics hs = CIB::CalculateHostStats();
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_up", hs.hosts_up));
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_down", hs.hosts_down));
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_unreachable", hs.hosts_unreachable));
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_flapping", hs.hosts_flapping));
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_in_downtime", hs.hosts_in_downtime));
- perfdata->Add(make_shared<PerfdataValue>("num_hosts_acknowledged", hs.hosts_acknowledged));
+ perfdata->Add(new PerfdataValue("num_hosts_up", hs.hosts_up));
+ perfdata->Add(new PerfdataValue("num_hosts_down", hs.hosts_down));
+ perfdata->Add(new PerfdataValue("num_hosts_unreachable", hs.hosts_unreachable));
+ perfdata->Add(new PerfdataValue("num_hosts_flapping", hs.hosts_flapping));
+ perfdata->Add(new PerfdataValue("num_hosts_in_downtime", hs.hosts_in_downtime));
+ perfdata->Add(new PerfdataValue("num_hosts_acknowledged", hs.hosts_acknowledged));
cr->SetOutput("Icinga 2 has been running for " + Utility::FormatDuration(uptime) +
". Version: " + Application::GetVersion());
String output = "Hello from ";
output += Utility::GetFQDN();
- Array::Ptr perfdata = make_shared<Array>();
- perfdata->Add(make_shared<PerfdataValue>("time", Convert::ToDouble(Utility::GetTime())));
+ Array::Ptr perfdata = new Array();
+ perfdata->Add(new PerfdataValue("time", Convert::ToDouble(Utility::GetTime())));
cr->SetOutput(output);
cr->SetPerformanceData(perfdata);
Checkable::Ptr checkable = notification->GetCheckable();
- Dictionary::Ptr notificationExtra = make_shared<Dictionary>();
+ Dictionary::Ptr notificationExtra = new Dictionary();
notificationExtra->Set("type", Notification::NotificationTypeToString(type));
notificationExtra->Set("author", author);
notificationExtra->Set("comment", comment);
String output = "Hello from ";
output += Utility::GetFQDN();
- Array::Ptr perfdata = make_shared<Array>();
- perfdata->Add(make_shared<PerfdataValue>("time", Convert::ToDouble(Utility::GetTime())));
+ Array::Ptr perfdata = new Array();
+ perfdata->Add(new PerfdataValue("time", Convert::ToDouble(Utility::GetTime())));
cr->SetOutput(output);
cr->SetPerformanceData(perfdata);
Array::Ptr TimePeriodTask::EmptyTimePeriodUpdate(const TimePeriod::Ptr&, double, double)
{
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
return segments;
}
Array::Ptr TimePeriodTask::EvenMinutesTimePeriodUpdate(const TimePeriod::Ptr&, double begin, double end)
{
- Array::Ptr segments = make_shared<Array>();
+ Array::Ptr segments = new Array();
for (long t = begin / 60 - 1; t * 60 < end; t++) {
if ((t % 2) == 0) {
- Dictionary::Ptr segment = make_shared<Dictionary>();
+ Dictionary::Ptr segment = new Dictionary();
segment->Set("begin", t * 60);
segment->Set("end", (t + 1) * 60);
Value NotificationComponent::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const NotificationComponent::Ptr& notification_component, DynamicType::GetObjectsByType<NotificationComponent>()) {
nodes->Set(notification_component->GetName(), 1); //add more stats
Checkable::OnNotificationsRequested.connect(boost::bind(&NotificationComponent::SendNotificationsHandler, this, _1,
_2, _3, _4, _5));
- m_NotificationTimer = make_shared<Timer>();
+ m_NotificationTimer = new Timer();
m_NotificationTimer->SetInterval(5);
m_NotificationTimer->OnTimerExpired.connect(boost::bind(&NotificationComponent::NotificationTimerHandler, this));
m_NotificationTimer->Start();
Value GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const GraphiteWriter::Ptr& graphitewriter, DynamicType::GetObjectsByType<GraphiteWriter>()) {
nodes->Set(graphitewriter->GetName(), 1); //add more stats
{
DynamicObject::Start();
- m_ReconnectTimer = make_shared<Timer>();
+ m_ReconnectTimer = new Timer();
m_ReconnectTimer->SetInterval(10);
m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&GraphiteWriter::ReconnectTimerHandler, this));
m_ReconnectTimer->Start();
if (m_Stream)
return;
- TcpSocket::Ptr socket = make_shared<TcpSocket>();
+ TcpSocket::Ptr socket = new TcpSocket();
Log(LogNotice, "GraphiteWriter")
<< "Reconnecting to Graphite on host '" << GetHost() << "' port '" << GetPort() << "'.";
return;
}
- m_Stream = make_shared<NetworkStream>(socket);
+ m_Stream = new NetworkStream(socket);
}
void GraphiteWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
Value PerfdataWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const PerfdataWriter::Ptr& perfdatawriter, DynamicType::GetObjectsByType<PerfdataWriter>()) {
nodes->Set(perfdatawriter->GetName(), 1); //add more stats
Checkable::OnNewCheckResult.connect(boost::bind(&PerfdataWriter::CheckResultHandler, this, _1, _2));
- m_RotationTimer = make_shared<Timer>();
+ m_RotationTimer = new Timer();
m_RotationTimer->OnTimerExpired.connect(boost::bind(&PerfdataWriter::RotationTimerHandler, this));
m_RotationTimer->SetInterval(GetRotationInterval());
m_RotationTimer->Start();
void ApiClient::Start(void)
{
- boost::thread thread(boost::bind(&ApiClient::MessageThreadProc, static_cast<ApiClient::Ptr>(GetSelf())));
+ boost::thread thread(boost::bind(&ApiClient::MessageThreadProc, ApiClient::Ptr(this)));
thread.detach();
}
return;
}
- m_WriteQueue.Enqueue(boost::bind(&ApiClient::SendMessageSync, static_cast<ApiClient::Ptr>(GetSelf()), message));
+ m_WriteQueue.Enqueue(boost::bind(&ApiClient::SendMessageSync, ApiClient::Ptr(this), message));
}
void ApiClient::SendMessageSync(const Dictionary::Ptr& message)
void ApiClient::Disconnect(void)
{
- Utility::QueueAsyncCallback(boost::bind(&ApiClient::DisconnectSync, static_cast<ApiClient::Ptr>(GetSelf())));
+ Utility::QueueAsyncCallback(boost::bind(&ApiClient::DisconnectSync, ApiClient::Ptr(this)));
}
void ApiClient::DisconnectSync(void)
<< "API client disconnected for identity '" << m_Identity << "'";
if (m_Endpoint)
- m_Endpoint->RemoveClient(GetSelf());
+ m_Endpoint->RemoveClient(this);
else {
ApiListener::Ptr listener = ApiListener::GetInstance();
- listener->RemoveAnonymousClient(GetSelf());
+ listener->RemoveAnonymousClient(this);
}
m_Stream->Close();
}
MessageOrigin origin;
- origin.FromClient = GetSelf();
+ origin.FromClient = this;
if (m_Endpoint) {
if (m_Endpoint->GetZone() != Zone::GetLocalZone())
Log(LogNotice, "ApiClient")
<< "Received '" << method << "' message from '" << m_Identity << "'";
- Dictionary::Ptr resultMessage = make_shared<Dictionary>();
+ Dictionary::Ptr resultMessage = new Dictionary();
try {
ApiFunction::Ptr afunc = ApiFunction::GetByName(method);
ApiListener::Ptr listener = ApiListener::GetInstance();
String salt = listener->GetTicketSalt();
- Dictionary::Ptr result = make_shared<Dictionary>();
+ Dictionary::Ptr result = new Dictionary();
if (salt.IsEmpty()) {
result->Set("error", "Ticket salt is not configured.");
return result;
}
- shared_ptr<X509> cert = origin.FromClient->GetStream()->GetPeerCertificate();
+ boost::shared_ptr<X509> cert = origin.FromClient->GetStream()->GetPeerCertificate();
EVP_PKEY *pubkey = X509_get_pubkey(cert.get());
X509_NAME *subject = X509_get_subject_name(cert.get());
- shared_ptr<X509> newcert = CreateCertIcingaCA(pubkey, subject);
+ boost::shared_ptr<X509> newcert = CreateCertIcingaCA(pubkey, subject);
result->Set("cert", CertificateToString(newcert));
String cacertfile = GetIcingaCADir() + "/ca.crt";
- shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
+ boost::shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
result->Set("ca", CertificateToString(cacert));
return result;
RegisterApiFunctionHelper::RegisterApiFunctionHelper(const String& name, const ApiFunction::Callback& function)
{
- ApiFunction::Ptr func = make_shared<ApiFunction>(function);
+ ApiFunction::Ptr func = new ApiFunction(function);
ApiFunctionRegistry::GetInstance()->Register(name, func);
}
Dictionary::Ptr ApiListener::LoadConfigDir(const String& dir)
{
- Dictionary::Ptr config = make_shared<Dictionary>();
+ Dictionary::Ptr config = new Dictionary();
Utility::GlobRecursive(dir, "*.conf", boost::bind(&ApiListener::ConfigGlobHandler, boost::ref(config), dir, _1), GlobFile);
return config;
}
if (!azone->IsChildOf(lzone))
return;
- Dictionary::Ptr configUpdate = make_shared<Dictionary>();
+ Dictionary::Ptr configUpdate = new Dictionary();
String zonesDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
configUpdate->Set(zone->GetName(), LoadConfigDir(zonesDir + "/" + zone->GetName()));
}
- Dictionary::Ptr params = make_shared<Dictionary>();
+ Dictionary::Ptr params = new Dictionary();
params->Set("update", configUpdate);
- Dictionary::Ptr message = make_shared<Dictionary>();
+ Dictionary::Ptr message = new Dictionary();
message->Set("jsonrpc", "2.0");
message->Set("method", "config::Update");
message->Set("params", params);
void ApiListener::OnConfigLoaded(void)
{
/* set up SSL context */
- shared_ptr<X509> cert;
+ boost::shared_ptr<X509> cert;
try {
cert = GetX509Certificate(GetCertPath());
} catch (const std::exception&) {
Application::Exit(EXIT_FAILURE);
}
- m_Timer = make_shared<Timer>();
+ m_Timer = new Timer();
m_Timer->OnTimerExpired.connect(boost::bind(&ApiListener::ApiTimerHandler, this));
m_Timer->SetInterval(5);
m_Timer->Start();
return ApiListener::Ptr();
}
-shared_ptr<SSL_CTX> ApiListener::GetSSLContext(void) const
+boost::shared_ptr<SSL_CTX> ApiListener::GetSSLContext(void) const
{
return m_SSLContext;
}
{
ObjectLock olock(this);
- shared_ptr<SSL_CTX> sslContext = m_SSLContext;
+ boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddListener()");
Log(LogInformation, "ApiListener")
<< "Adding new listener on port '" << service << "'";
- TcpSocket::Ptr server = make_shared<TcpSocket>();
+ TcpSocket::Ptr server = new TcpSocket();
try {
server->Bind(node, service, AF_UNSPEC);
{
ObjectLock olock(this);
- shared_ptr<SSL_CTX> sslContext = m_SSLContext;
+ boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()");
Log(LogInformation, "ApiClient")
<< "Reconnecting to API endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
- TcpSocket::Ptr client = make_shared<TcpSocket>();
+ TcpSocket::Ptr client = new TcpSocket();
try {
endpoint->SetConnecting(true);
{
ObjectLock olock(this);
try {
- tlsStream = make_shared<TlsStream>(client, role, m_SSLContext);
+ tlsStream = new TlsStream(client, role, m_SSLContext);
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot create TLS stream from client connection.");
return;
return;
}
- shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
+ boost::shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
String identity;
try {
if (endpoint)
need_sync = !endpoint->IsConnected();
- ApiClient::Ptr aclient = make_shared<ApiClient>(identity, verify_ok, tlsStream, role);
+ ApiClient::Ptr aclient = new ApiClient(identity, verify_ok, tlsStream, role);
aclient->Start();
if (endpoint) {
if (ts == 0)
continue;
- Dictionary::Ptr lparams = make_shared<Dictionary>();
+ Dictionary::Ptr lparams = new Dictionary();
lparams->Set("log_position", ts);
- Dictionary::Ptr lmessage = make_shared<Dictionary>();
+ Dictionary::Ptr lmessage = new Dictionary();
lmessage->Set("jsonrpc", "2.0");
lmessage->Set("method", "log::SetLogPosition");
lmessage->Set("params", lparams);
ASSERT(ts != 0);
- Dictionary::Ptr pmessage = make_shared<Dictionary>();
+ Dictionary::Ptr pmessage = new Dictionary();
pmessage->Set("timestamp", ts);
pmessage->Set("message", JsonEncode(message));
- Dictionary::Ptr secname = make_shared<Dictionary>();
+ Dictionary::Ptr secname = new Dictionary();
secname->Set("type", secobj->GetType()->GetName());
secname->Set("name", secobj->GetName());
pmessage->Set("secobj", secname);
return;
}
- m_LogFile = make_shared<StdioStream>(fp, true);
+ m_LogFile = new StdioStream(fp, true);
m_LogMessageCount = 0;
SetLogMessageTimestamp(Utility::GetTime());
}
<< "Replaying log: " << path;
std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in);
- StdioStream::Ptr logStream = make_shared<StdioStream>(fp, true);
+ StdioStream::Ptr logStream = new StdioStream(fp, true);
String message;
while (true) {
Value ApiListener::StatsFunc(Dictionary::Ptr& status, Array::Ptr& perfdata)
{
- Dictionary::Ptr nodes = make_shared<Dictionary>();
+ Dictionary::Ptr nodes = new Dictionary();
std::pair<Dictionary::Ptr, Dictionary::Ptr> stats;
ApiListener::Ptr listener = ApiListener::GetInstance();
std::pair<Dictionary::Ptr, Dictionary::Ptr> ApiListener::GetStatus(void)
{
- Dictionary::Ptr status = make_shared<Dictionary>();
- Dictionary::Ptr perfdata = make_shared<Dictionary>();
+ Dictionary::Ptr status = new Dictionary();
+ Dictionary::Ptr perfdata = new Dictionary();
/* cluster stats */
status->Set("identity", GetIdentity());
double count_endpoints = 0;
- Array::Ptr not_connected_endpoints = make_shared<Array>();
- Array::Ptr connected_endpoints = make_shared<Array>();
+ Array::Ptr not_connected_endpoints = new Array();
+ Array::Ptr connected_endpoints = new Array();
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
if (endpoint->GetName() == GetIdentity())
static ApiListener::Ptr GetInstance(void);
- shared_ptr<SSL_CTX> GetSSLContext(void) const;
+ boost::shared_ptr<SSL_CTX> GetSSLContext(void) const;
Endpoint::Ptr GetMaster(void) const;
bool IsMaster(void) const;
virtual void Start(void);
private:
- shared_ptr<SSL_CTX> m_SSLContext;
+ boost::shared_ptr<SSL_CTX> m_SSLContext;
std::set<TcpSocket::Ptr> m_Servers;
std::set<ApiClient::Ptr> m_AnonymousClients;
Timer::Ptr m_Timer;
static void StaticInitialize(void)
{
- l_AuthorityTimer = make_shared<Timer>();
+ l_AuthorityTimer = new Timer();
l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&AuthorityTimerHandler));
l_AuthorityTimer->SetInterval(30);
l_AuthorityTimer->Start();
if (members.empty())
continue;
- if (members.find(GetSelf()) != members.end()) {
+ if (members.find(this) != members.end()) {
if (m_Zone)
BOOST_THROW_EXCEPTION(std::runtime_error("Endpoint '" + GetName() + "' is in more than one zone."));
if (was_master != is_master)
ApiListener::OnMasterChanged(is_master);
- OnConnected(GetSelf(), client);
+ OnConnected(this, client);
}
void Endpoint::RemoveClient(const ApiClient::Ptr& client)
if (was_master != is_master)
ApiListener::OnMasterChanged(is_master);
- OnDisconnected(GetSelf(), client);
+ OnDisconnected(this, client);
}
std::set<ApiClient::Ptr> Endpoint::GetClients(void) const
DECLARE_OBJECT(Endpoint);
DECLARE_OBJECTNAME(Endpoint);
- static boost::signals2::signal<void(const Endpoint::Ptr&, const shared_ptr<ApiClient>&)> OnConnected;
- static boost::signals2::signal<void(const Endpoint::Ptr&, const shared_ptr<ApiClient>&)> OnDisconnected;
+ static boost::signals2::signal<void(const Endpoint::Ptr&, const intrusive_ptr<ApiClient>&)> OnConnected;
+ static boost::signals2::signal<void(const Endpoint::Ptr&, const intrusive_ptr<ApiClient>&)> OnDisconnected;
- void AddClient(const shared_ptr<ApiClient>& client);
- void RemoveClient(const shared_ptr<ApiClient>& client);
- std::set<shared_ptr<ApiClient> > GetClients(void) const;
+ void AddClient(const intrusive_ptr<ApiClient>& client);
+ void RemoveClient(const intrusive_ptr<ApiClient>& client);
+ std::set<intrusive_ptr<ApiClient> > GetClients(void) const;
- shared_ptr<Zone> GetZone(void) const;
+ intrusive_ptr<Zone> GetZone(void) const;
bool IsConnected(void) const;
private:
mutable boost::mutex m_ClientsLock;
- std::set<shared_ptr<ApiClient> > m_Clients;
- shared_ptr<Zone> m_Zone;
+ std::set<intrusive_ptr<ApiClient> > m_Clients;
+ intrusive_ptr<Zone> m_Zone;
};
}
******************************************************************************/
#include "remote/zone.hpp"
+#include "remote/apiclient.hpp"
#include "base/objectlock.hpp"
#include <boost/foreach.hpp>
if (!object_zone)
object_zone = Zone::GetLocalZone();
- return object_zone->IsChildOf(GetSelf());
+ return object_zone->IsChildOf(this);
}
bool Zone::IsChildOf(const Zone::Ptr& zone)
{
- Zone::Ptr azone = GetSelf();
+ Zone::Ptr azone = this;
while (azone) {
if (azone == zone)
return false;
}
-bool Zone::IsGlobal(void)
+bool Zone::IsGlobal(void) const
{
return GetGlobal();
}
bool CanAccessObject(const DynamicObject::Ptr& object);
bool IsChildOf(const Zone::Ptr& zone);
- bool IsGlobal(void);
+ bool IsGlobal(void) const;
static Zone::Ptr GetLocalZone(void);
};
base_netstring/netstring
base_object/construct
base_object/getself
- base_object/weak
base_serialize/scalar
base_serialize/array
base_serialize/dictionary
BOOST_AUTO_TEST_CASE(construct)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
BOOST_CHECK(array);
BOOST_CHECK(array->GetLength() == 0);
}
BOOST_AUTO_TEST_CASE(getset)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(2);
array->Add(5);
BOOST_AUTO_TEST_CASE(insert)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Insert(0, 11);
array->Insert(1, 22);
BOOST_AUTO_TEST_CASE(remove)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(2);
array->Add(5);
BOOST_AUTO_TEST_CASE(foreach)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(2);
array->Add(5);
BOOST_AUTO_TEST_CASE(clone)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(2);
array->Add(5);
BOOST_AUTO_TEST_CASE(json)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(2);
array->Add(5);
BOOST_AUTO_TEST_CASE(construct)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
BOOST_CHECK(dictionary);
}
BOOST_AUTO_TEST_CASE(get1)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
BOOST_AUTO_TEST_CASE(get2)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
- Dictionary::Ptr other = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
+ Dictionary::Ptr other = new Dictionary();
dictionary->Set("test1", other);
BOOST_AUTO_TEST_CASE(foreach)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
BOOST_AUTO_TEST_CASE(remove)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
BOOST_AUTO_TEST_CASE(clone)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
BOOST_AUTO_TEST_CASE(json)
{
- Dictionary::Ptr dictionary = make_shared<Dictionary>();
+ Dictionary::Ptr dictionary = new Dictionary();
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
BOOST_AUTO_TEST_CASE(construct)
{
- FIFO::Ptr fifo = make_shared<FIFO>();
+ FIFO::Ptr fifo = new FIFO();
BOOST_CHECK(fifo);
BOOST_CHECK(fifo->GetAvailableBytes() == 0);
BOOST_AUTO_TEST_CASE(io)
{
- FIFO::Ptr fifo = make_shared<FIFO>();
+ FIFO::Ptr fifo = new FIFO();
fifo->Write("hello", 5);
BOOST_CHECK(fifo->GetAvailableBytes() == 5);
BOOST_AUTO_TEST_CASE(netstring)
{
- FIFO::Ptr fifo = make_shared<FIFO>();
+ FIFO::Ptr fifo = new FIFO();
NetString::WriteStringToStream(fifo, "hello");
TestObject::Ptr GetTestRef(void)
{
- return GetSelf();
+ return this;
}
};
BOOST_AUTO_TEST_CASE(construct)
{
- Object::Ptr tobject = make_shared<TestObject>();
+ Object::Ptr tobject = new TestObject();
BOOST_CHECK(tobject);
}
BOOST_AUTO_TEST_CASE(getself)
{
- TestObject::Ptr tobject = make_shared<TestObject>();
+ TestObject::Ptr tobject = new TestObject();
TestObject::Ptr tobject_self = tobject->GetTestRef();
BOOST_CHECK(tobject == tobject_self);
BOOST_CHECK(vobject.IsObjectType<TestObject>());
}
-BOOST_AUTO_TEST_CASE(weak)
-{
- TestObject::Ptr tobject = make_shared<TestObject>();
- TestObject::WeakPtr wtobject = tobject;
- tobject.reset();
- BOOST_CHECK(!tobject);
- BOOST_CHECK(!wtobject.lock());
-}
-
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(array)
{
- Array::Ptr array = make_shared<Array>();
+ Array::Ptr array = new Array();
array->Add(7);
array->Add(7.3);
array->Add(Empty);
BOOST_AUTO_TEST_CASE(dictionary)
{
- Dictionary::Ptr dict = make_shared<Dictionary>();
+ Dictionary::Ptr dict = new Dictionary();
dict->Set("k1", 7);
dict->Set("k2", 7.3);
dict->Set("k3", Empty);
BOOST_AUTO_TEST_CASE(object)
{
- PerfdataValue::Ptr pdv = make_shared<PerfdataValue>("size", 100, true, "bytes");
+ PerfdataValue::Ptr pdv = new PerfdataValue("size", 100, true, "bytes");
PerfdataValue::Ptr result = Deserialize(Serialize(pdv));
std::stringstream msgbuf;
msgbuf << "Hello\nWorld\n\n";
- StdioStream::Ptr stdstream = make_shared<StdioStream>(&msgbuf, false);
+ StdioStream::Ptr stdstream = new StdioStream(&msgbuf, false);
ReadLineContext rlc;
BOOST_AUTO_TEST_CASE(construct)
{
- Timer::Ptr timer = make_shared<Timer>();
+ Timer::Ptr timer = new Timer();
BOOST_CHECK(timer);
}
BOOST_AUTO_TEST_CASE(interval)
{
- Timer::Ptr timer = make_shared<Timer>();
+ Timer::Ptr timer = new Timer();
timer->SetInterval(1.5);
BOOST_CHECK(timer->GetInterval() == 1.5);
}
BOOST_AUTO_TEST_CASE(invoke)
{
int counter;
- Timer::Ptr timer = make_shared<Timer>();
+ Timer::Ptr timer = new Timer();
timer->OnTimerExpired.connect(boost::bind(&Callback, &counter));
timer->SetInterval(1);
BOOST_AUTO_TEST_CASE(scope)
{
int counter;
- Timer::Ptr timer = make_shared<Timer>();
+ Timer::Ptr timer = new Timer();
timer->OnTimerExpired.connect(boost::bind(&Callback, &counter));
timer->SetInterval(1);