Implement modified attributes v2

refs #9081
refs #9093
This commit is contained in:
Michael Friedrich 2015-08-04 14:47:44 +02:00 committed by Gunnar Beutner
parent 80584f81f1
commit d7970f5bb1
112 changed files with 1218 additions and 1526 deletions

View File

@ -23,15 +23,19 @@ mkclass_target(streamlogger.ti streamlogger.tcpp streamlogger.thpp)
mkclass_target(sysloglogger.ti sysloglogger.tcpp sysloglogger.thpp) mkclass_target(sysloglogger.ti sysloglogger.tcpp sysloglogger.thpp)
set(base_SOURCES set(base_SOURCES
application.cpp application.thpp application-version.cpp array.cpp array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp application.cpp application.thpp application-version.cpp array.cpp
convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp object-script.cpp primitivetype.cpp process.cpp dynamicobject.cpp dynamicobject.thpp dynamicobject-script.cpp dynamictype.cpp
ringbuffer.cpp scriptframe.cpp function.cpp function-script.cpp functionwrapper.cpp scriptglobal.cpp exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp
json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp
object-script.cpp primitivetype.cpp process.cpp ringbuffer.cpp scriptframe.cpp
function.cpp function-script.cpp functionwrapper.cpp scriptglobal.cpp
scriptutils.cpp serializer.cpp socket.cpp socketevents.cpp stacktrace.cpp scriptutils.cpp serializer.cpp socket.cpp socketevents.cpp stacktrace.cpp
statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp
sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp
tlsstream.cpp tlsutility.cpp type.cpp unixsocket.cpp utility.cpp value.cpp tlsstream.cpp tlsutility.cpp type.cpp typetype-script.cpp unixsocket.cpp utility.cpp value.cpp
value-operators.cpp workqueue.cpp value-operators.cpp workqueue.cpp
) )

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library base;
namespace icinga namespace icinga
{ {

View File

@ -0,0 +1,54 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2015 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/dynamicobject.hpp"
#include "base/dictionary.hpp"
#include "base/function.hpp"
#include "base/functionwrapper.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static void DynamicObjectModifyAttribute(const String& attr, const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
DynamicObject::Ptr self = vframe->Self;
return self->ModifyAttribute(attr, value);
}
static void DynamicObjectRestoreAttribute(const String& attr)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
DynamicObject::Ptr self = vframe->Self;
return self->RestoreAttribute(attr);
}
Object::Ptr DynamicObject::GetPrototype(void)
{
static Dictionary::Ptr prototype;
if (!prototype) {
prototype = new Dictionary();
prototype->Set("modify_attribute", new Function(WrapFunction(DynamicObjectModifyAttribute), false));
prototype->Set("restore_attribute", new Function(WrapFunction(DynamicObjectRestoreAttribute), false));
}
return prototype;
}

View File

@ -41,12 +41,8 @@
using namespace icinga; using namespace icinga;
REGISTER_TYPE(DynamicObject); REGISTER_TYPE_WITH_PROTOTYPE(DynamicObject, DynamicObject::GetPrototype());
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStarted;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStopped;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnPaused;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnResumed;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStateChanged; boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStateChanged;
DynamicObject::DynamicObject(void) DynamicObject::DynamicObject(void)
@ -99,6 +95,59 @@ void DynamicObject::ClearExtension(const String& key)
extensions->Remove(key); extensions->Remove(key);
} }
void DynamicObject::ModifyAttribute(const String& attr, const Value& value)
{
Dictionary::Ptr original_attributes = GetOriginalAttributes();
bool updated_original_attributes = false;
Type::Ptr type = GetReflectionType();
int fid = type->GetFieldId(attr);
Field field = type->GetFieldInfo(fid);
if (field.Attributes & FAConfig) {
if (!original_attributes) {
original_attributes = new Dictionary();
SetOriginalAttributes(original_attributes, true);
}
Value attrVal = GetField(fid);
if (!original_attributes->Contains(attr)) {
updated_original_attributes = true;
original_attributes->Set(attr, attrVal);
}
}
//TODO: validation, vars.os
SetField(fid, value);
if (updated_original_attributes)
NotifyOriginalAttributes();
}
void DynamicObject::RestoreAttribute(const String& attr)
{
Dictionary::Ptr original_attributes = GetOriginalAttributes();
if (!original_attributes || !original_attributes->Contains(attr))
return;
Value attrVal = original_attributes->Get(attr);
SetField(GetReflectionType()->GetFieldId(attr), attrVal);
original_attributes->Remove(attr);
}
bool DynamicObject::IsAttributeModified(const String& attr) const
{
Dictionary::Ptr original_attributes = GetOriginalAttributes();
if (!original_attributes)
return false;
return original_attributes->Contains(attr);
}
void DynamicObject::Register(void) void DynamicObject::Register(void)
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
@ -128,12 +177,12 @@ void DynamicObject::Activate(void)
{ {
ObjectLock olock(this); ObjectLock olock(this);
ASSERT(!IsActive()); ASSERT(!IsActive());
SetActive(true); SetActive(true, true);
} }
OnStarted(this);
SetAuthority(true); SetAuthority(true);
NotifyActive();
} }
void DynamicObject::Stop(void) void DynamicObject::Stop(void)
@ -158,14 +207,14 @@ void DynamicObject::Deactivate(void)
if (!IsActive()) if (!IsActive())
return; return;
SetActive(false); SetActive(false, true);
} }
Stop(); Stop();
ASSERT(GetStopCalled()); ASSERT(GetStopCalled());
OnStopped(this); NotifyActive();
} }
void DynamicObject::OnConfigLoaded(void) void DynamicObject::OnConfigLoaded(void)
@ -205,13 +254,11 @@ void DynamicObject::SetAuthority(bool authority)
Resume(); Resume();
ASSERT(GetResumeCalled()); ASSERT(GetResumeCalled());
SetPaused(false); SetPaused(false);
OnResumed(this);
} else if (!authority && !GetPaused()) { } else if (!authority && !GetPaused()) {
SetPauseCalled(false); SetPauseCalled(false);
Pause(); Pause();
ASSERT(GetPauseCalled()); ASSERT(GetPauseCalled());
SetPaused(true); SetPaused(true);
OnPaused(this);
} }
} }

View File

@ -42,10 +42,6 @@ class I2_BASE_API DynamicObject : public ObjectImpl<DynamicObject>
public: public:
DECLARE_OBJECT(DynamicObject); DECLARE_OBJECT(DynamicObject);
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnPaused;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnResumed;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged; static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged;
intrusive_ptr<DynamicType> GetType(void) const; intrusive_ptr<DynamicType> GetType(void) const;
@ -57,6 +53,10 @@ public:
Value GetExtension(const String& key); Value GetExtension(const String& key);
void ClearExtension(const String& key); void ClearExtension(const String& key);
void ModifyAttribute(const String& attr, const Value& value);
void RestoreAttribute(const String& attr);
bool IsAttributeModified(const String& attr) const;
void Register(void); void Register(void);
void Activate(void); void Activate(void);
@ -86,6 +86,8 @@ public:
static void RestoreObjects(const String& filename, int attributeTypes = FAState); static void RestoreObjects(const String& filename, int attributeTypes = FAState);
static void StopObjects(void); static void StopObjects(void);
static Object::Ptr GetPrototype(void);
protected: protected:
explicit DynamicObject(void); explicit DynamicObject(void);

View File

@ -19,6 +19,8 @@
#include "base/debuginfo.hpp" #include "base/debuginfo.hpp"
library base;
namespace icinga namespace icinga
{ {
@ -75,14 +77,15 @@ abstract class DynamicObject : DynamicObjectBase
[get_protected] bool paused { [get_protected] bool paused {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[get_protected] bool start_called; [get_protected, internal] bool start_called;
[get_protected] bool stop_called; [get_protected, internal] bool stop_called;
[get_protected] bool pause_called; [get_protected, internal] bool pause_called;
[get_protected] bool resume_called; [get_protected, internal] bool resume_called;
[enum] HAMode ha_mode (HAMode); [enum] HAMode ha_mode (HAMode);
[protected] Dictionary::Ptr extensions; [protected] Dictionary::Ptr extensions;
[protected] bool state_loaded; [protected] bool state_loaded;
Dictionary::Ptr original_attributes;
}; };
} }

View File

@ -19,6 +19,8 @@
#include "base/streamlogger.hpp" #include "base/streamlogger.hpp"
library base;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library base;
namespace icinga namespace icinga
{ {

View File

@ -32,6 +32,13 @@ static String ObjectToString(void)
return self->ToString(); return self->ToString();
} }
static void ObjectNotifyAttribute(const String& attribute)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
self->NotifyField(self->GetReflectionType()->GetFieldId(attribute));
}
Object::Ptr Object::GetPrototype(void) Object::Ptr Object::GetPrototype(void)
{ {
static Dictionary::Ptr prototype; static Dictionary::Ptr prototype;
@ -39,6 +46,7 @@ Object::Ptr Object::GetPrototype(void)
if (!prototype) { if (!prototype) {
prototype = new Dictionary(); prototype = new Dictionary();
prototype->Set("to_string", new Function(WrapFunction(ObjectToString), true)); prototype->Set("to_string", new Function(WrapFunction(ObjectToString), true));
prototype->Set("notify_attribute", new Function(WrapFunction(ObjectNotifyAttribute), false));
} }
return prototype; return prototype;

View File

@ -76,7 +76,7 @@ void Object::InflateMutex(void)
m_Mutex.Inflate(); m_Mutex.Inflate();
} }
void Object::SetField(int id, const Value&) void Object::SetField(int id, const Value&, bool, const Value&)
{ {
if (id == 0) if (id == 0)
BOOST_THROW_EXCEPTION(std::runtime_error("Prototype field cannot be set.")); BOOST_THROW_EXCEPTION(std::runtime_error("Prototype field cannot be set."));
@ -92,3 +92,7 @@ Value Object::GetField(int id) const
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID.")); BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
} }
void Object::NotifyField(int id, const Value& cookie)
{
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
}

View File

@ -49,6 +49,8 @@ class Object;
class Type; class Type;
class String; class String;
extern I2_BASE_API Value Empty;
#define DECLARE_PTR_TYPEDEFS(klass) \ #define DECLARE_PTR_TYPEDEFS(klass) \
typedef intrusive_ptr<klass> Ptr typedef intrusive_ptr<klass> Ptr
@ -96,8 +98,9 @@ public:
virtual String ToString(void) const; virtual String ToString(void) const;
virtual void SetField(int id, const Value& value); virtual void SetField(int id, const Value& value, bool suppress_events = false, const Value& cookie = Empty);
virtual Value GetField(int id) const; virtual Value GetField(int id) const;
virtual void NotifyField(int id, const Value& cookie = Empty);
#ifdef I2_DEBUG #ifdef I2_DEBUG
bool OwnsLock(void) const; bool OwnsLock(void) const;

View File

@ -19,6 +19,8 @@
#include "base/logger.hpp" #include "base/logger.hpp"
library base;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "base/logger.hpp" #include "base/logger.hpp"
library base;
namespace icinga namespace icinga
{ {

View File

@ -22,9 +22,12 @@
using namespace icinga; using namespace icinga;
Type::Ptr Type::TypeInstance;
static void RegisterTypeType(void) static void RegisterTypeType(void)
{ {
Type::Ptr type = new TypeType(); Type::Ptr type = new TypeType();
type->SetPrototype(TypeType::GetPrototype());
Type::TypeInstance = type; Type::TypeInstance = type;
Type::Register(type); Type::Register(type);
} }
@ -111,6 +114,11 @@ std::vector<String> Type::GetLoadDependencies(void) const
return std::vector<String>(); return std::vector<String>();
} }
void Type::RegisterAttributeHandler(int fieldId, const AttributeHandler& callback)
{
throw std::runtime_error("Invalid field ID.");
}
String TypeType::GetName(void) const String TypeType::GetName(void) const
{ {
return "Type"; return "Type";

View File

@ -24,6 +24,7 @@
#include "base/string.hpp" #include "base/string.hpp"
#include "base/object.hpp" #include "base/object.hpp"
#include "base/initialize.hpp" #include "base/initialize.hpp"
#include <boost/function.hpp>
#include <vector> #include <vector>
namespace icinga namespace icinga
@ -68,7 +69,7 @@ public:
class I2_BASE_API Type : public Object class I2_BASE_API Type : public Object
{ {
public: public:
DECLARE_PTR_TYPEDEFS(Type); DECLARE_OBJECT(Type);
virtual String ToString(void) const; virtual String ToString(void) const;
@ -96,6 +97,9 @@ public:
virtual std::vector<String> GetLoadDependencies(void) const; virtual std::vector<String> GetLoadDependencies(void) const;
typedef boost::function<void (const Object::Ptr&, const Value&)> AttributeHandler;
virtual void RegisterAttributeHandler(int fieldId, const AttributeHandler& callback);
protected: protected:
virtual ObjectFactory GetFactory(void) const = 0; virtual ObjectFactory GetFactory(void) const = 0;
@ -115,6 +119,8 @@ public:
virtual Field GetFieldInfo(int id) const; virtual Field GetFieldInfo(int id) const;
virtual int GetFieldCount(void) const; virtual int GetFieldCount(void) const;
static Object::Ptr GetPrototype(void);
protected: protected:
virtual ObjectFactory GetFactory(void) const; virtual ObjectFactory GetFactory(void) const;
}; };
@ -137,6 +143,20 @@ class TypeImpl
} } \ } } \
DEFINE_TYPE_INSTANCE(type) DEFINE_TYPE_INSTANCE(type)
#define REGISTER_TYPE_WITH_PROTOTYPE(type, prototype) \
namespace { namespace UNIQUE_NAME(rt) { \
void RegisterType ## type(void) \
{ \
icinga::Type::Ptr t = new TypeImpl<type>(); \
t->SetPrototype(prototype); \
type::TypeInstance = t; \
icinga::Type::Register(t); \
} \
\
INITIALIZE_ONCE_WITH_PRIORITY(RegisterType ## type, 10); \
} } \
DEFINE_TYPE_INSTANCE(type)
#define DEFINE_TYPE_INSTANCE(type) \ #define DEFINE_TYPE_INSTANCE(type) \
Type::Ptr type::TypeInstance Type::Ptr type::TypeInstance

View File

@ -0,0 +1,58 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2015 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/type.hpp"
#include "base/dictionary.hpp"
#include "base/function.hpp"
#include "base/functionwrapper.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static void InvokeAttributeHandlerHelper(const Function::Ptr& callback,
const Object::Ptr& object, const Value& cookie)
{
std::vector<Value> arguments;
arguments.push_back(object);
ScriptFrame frame;
callback->Invoke(arguments);
}
static void TypeRegisterAttributeHandler(const String& fieldName, const Function::Ptr& callback)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Type::Ptr self = static_cast<Type::Ptr>(vframe->Self);
int fid = self->GetFieldId(fieldName);
self->RegisterAttributeHandler(fid, boost::bind(&InvokeAttributeHandlerHelper, callback, _1, _2));
}
Object::Ptr TypeType::GetPrototype(void)
{
static Dictionary::Ptr prototype;
if (!prototype) {
prototype = new Dictionary();
prototype->Set("register_attribute_handler", new Function(WrapFunction(TypeRegisterAttributeHandler), false));
}
return prototype;
}

View File

@ -24,7 +24,7 @@
using namespace icinga; using namespace icinga;
Value Empty; Value icinga::Empty;
bool Value::ToBool(void) const bool Value::ToBool(void) const
{ {

View File

@ -245,7 +245,7 @@ private:
} }
}; };
static Value Empty; extern I2_BASE_API Value Empty;
I2_BASE_API Value operator+(const Value& lhs, const char *rhs); I2_BASE_API Value operator+(const Value& lhs, const char *rhs);
I2_BASE_API Value operator+(const char *lhs, const Value& rhs); I2_BASE_API Value operator+(const char *lhs, const Value& rhs);

View File

@ -32,6 +32,7 @@ target_link_libraries(checker ${Boost_LIBRARIES} base config icinga remote)
set_target_properties ( set_target_properties (
checker PROPERTIES checker PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_CHECKER_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -66,10 +66,8 @@ CheckerComponent::CheckerComponent(void)
void CheckerComponent::OnConfigLoaded(void) void CheckerComponent::OnConfigLoaded(void)
{ {
DynamicObject::OnStarted.connect(bind(&CheckerComponent::ObjectHandler, this, _1)); DynamicObject::OnActiveChanged.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
DynamicObject::OnStopped.connect(bind(&CheckerComponent::ObjectHandler, this, _1)); DynamicObject::OnPausedChanged.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
DynamicObject::OnPaused.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
DynamicObject::OnResumed.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
Checkable::OnNextCheckChanged.connect(bind(&CheckerComponent::NextCheckChangedHandler, this, _1)); Checkable::OnNextCheckChanged.connect(bind(&CheckerComponent::NextCheckChangedHandler, this, _1));
} }

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library checker;
namespace icinga namespace icinga
{ {

View File

@ -37,6 +37,7 @@ target_link_libraries(compat ${Boost_LIBRARIES} base config icinga)
set_target_properties ( set_target_properties (
compat PROPERTIES compat PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_COMPAT_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library compat;
namespace icinga namespace icinga
{ {

View File

@ -63,10 +63,13 @@ void CompatLogger::Start(void)
Checkable::OnNewCheckResult.connect(bind(&CompatLogger::CheckResultHandler, this, _1, _2)); Checkable::OnNewCheckResult.connect(bind(&CompatLogger::CheckResultHandler, this, _1, _2));
Checkable::OnNotificationSentToUser.connect(bind(&CompatLogger::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6, _7, _8)); Checkable::OnNotificationSentToUser.connect(bind(&CompatLogger::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6, _7, _8));
Checkable::OnFlappingChanged.connect(bind(&CompatLogger::FlappingHandler, this, _1, _2));
Checkable::OnDowntimeTriggered.connect(boost::bind(&CompatLogger::TriggerDowntimeHandler, this, _1, _2)); Checkable::OnDowntimeTriggered.connect(boost::bind(&CompatLogger::TriggerDowntimeHandler, this, _1, _2));
Checkable::OnDowntimeRemoved.connect(boost::bind(&CompatLogger::RemoveDowntimeHandler, this, _1, _2)); Checkable::OnDowntimeRemoved.connect(boost::bind(&CompatLogger::RemoveDowntimeHandler, this, _1, _2));
Checkable::OnEventCommandExecuted.connect(bind(&CompatLogger::EventCommandHandler, this, _1)); Checkable::OnEventCommandExecuted.connect(bind(&CompatLogger::EventCommandHandler, this, _1));
Checkable::OnFlappingChanged.connect(boost::bind(&CompatLogger::FlappingChangedHandler, this, _1));
Checkable::OnEnableFlappingChanged.connect(boost::bind(&CompatLogger::EnableFlappingChangedHandler, this, _1));
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3)); ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
m_RotationTimer = new Timer(); m_RotationTimer = new Timer();
@ -294,7 +297,7 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
/** /**
* @threadsafety Always. * @threadsafety Always.
*/ */
void CompatLogger::FlappingHandler(const Checkable::Ptr& checkable, FlappingState flapping_state) void CompatLogger::FlappingChangedHandler(const Checkable::Ptr& checkable)
{ {
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;
@ -303,23 +306,12 @@ void CompatLogger::FlappingHandler(const Checkable::Ptr& checkable, FlappingStat
String flapping_state_str; String flapping_state_str;
String flapping_output; String flapping_output;
switch (flapping_state) { if (checkable->IsFlapping()) {
case FlappingStarted:
flapping_output = "Checkable appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)"; flapping_output = "Checkable appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)";
flapping_state_str = "STARTED"; flapping_state_str = "STARTED";
break; } else {
case FlappingStopped:
flapping_output = "Checkable appears to have stopped flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change < " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)"; flapping_output = "Checkable appears to have stopped flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change < " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)";
flapping_state_str = "STOPPED"; flapping_state_str = "STOPPED";
break;
case FlappingDisabled:
flapping_output = "Flap detection has been disabled";
flapping_state_str = "DISABLED";
break;
default:
Log(LogCritical, "CompatLogger")
<< "Unknown flapping state: " << flapping_state;
return;
} }
std::ostringstream msgbuf; std::ostringstream msgbuf;
@ -346,6 +338,42 @@ void CompatLogger::FlappingHandler(const Checkable::Ptr& checkable, FlappingStat
} }
} }
void CompatLogger::EnableFlappingChangedHandler(const Checkable::Ptr& checkable)
{
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
if (checkable->GetEnableFlapping())
return;
String flapping_output = "Flap detection has been disabled";
String flapping_state_str = "DISABLED";
std::ostringstream msgbuf;
if (service) {
msgbuf << "SERVICE FLAPPING ALERT: "
<< host->GetName() << ";"
<< service->GetShortName() << ";"
<< flapping_state_str << "; "
<< flapping_output
<< "";
} else {
msgbuf << "HOST FLAPPING ALERT: "
<< host->GetName() << ";"
<< flapping_state_str << "; "
<< flapping_output
<< "";
}
{
ObjectLock oLock(this);
WriteLine(msgbuf.str());
Flush();
}
}
void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments) void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
{ {
std::ostringstream msgbuf; std::ostringstream msgbuf;

View File

@ -54,7 +54,8 @@ private:
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service, void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr, const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
const String& author, const String& comment_text, const String& command_name); const String& author, const String& comment_text, const String& command_name);
void FlappingHandler(const Checkable::Ptr& service, FlappingState flapping_state); void FlappingChangedHandler(const Checkable::Ptr& checkable);
void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
void TriggerDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime); void TriggerDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
void RemoveDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime); void RemoveDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments); void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library compat;
namespace icinga namespace icinga
{ {

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library compat;
namespace icinga namespace icinga
{ {

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library compat;
namespace icinga namespace icinga
{ {

View File

@ -23,6 +23,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <set>
#include <iterator> #include <iterator>
using namespace icinga; using namespace icinga;

View File

@ -25,7 +25,6 @@
#include "base/array.hpp" #include "base/array.hpp"
#include "base/dictionary.hpp" #include "base/dictionary.hpp"
#include <fstream> #include <fstream>
#include <set>
namespace icinga namespace icinga
{ {

View File

@ -61,6 +61,7 @@ void DbConnection::Start(void)
DynamicObject::Start(); DynamicObject::Start();
DbObject::OnQuery.connect(boost::bind(&DbConnection::ExecuteQuery, this, _1)); DbObject::OnQuery.connect(boost::bind(&DbConnection::ExecuteQuery, this, _1));
DynamicObject::OnActiveChanged.connect(boost::bind(&DbConnection::UpdateObject, this, _1));
} }
void DbConnection::Resume(void) void DbConnection::Resume(void)
@ -377,20 +378,32 @@ void DbConnection::ExecuteQuery(const DbQuery&)
/* Default handler does nothing. */ /* Default handler does nothing. */
} }
void DbConnection::UpdateObject(const DynamicObject::Ptr& object)
{
if (!GetConnected())
return;
DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object);
if (dbobj) {
bool active = object->IsActive();
if (active) {
ActivateObject(dbobj);
dbobj->SendConfigUpdate();
dbobj->SendStatusUpdate();
} else
DeactivateObject(dbobj);
}
}
void DbConnection::UpdateAllObjects(void) void DbConnection::UpdateAllObjects(void)
{ {
DynamicType::Ptr type; DynamicType::Ptr type;
BOOST_FOREACH(const DynamicType::Ptr& dt, DynamicType::GetTypes()) { BOOST_FOREACH(const DynamicType::Ptr& dt, DynamicType::GetTypes()) {
BOOST_FOREACH(const DynamicObject::Ptr& object, dt->GetObjects()) { BOOST_FOREACH(const DynamicObject::Ptr& object, dt->GetObjects()) {
DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); UpdateObject(object);
if (dbobj) {
if (!GetObjectActive(dbobj))
ActivateObject(dbobj);
dbobj->SendConfigUpdate();
dbobj->SendStatusUpdate();
}
} }
} }
} }

View File

@ -90,6 +90,7 @@ protected:
virtual void FillIDCache(const DbType::Ptr& type) = 0; virtual void FillIDCache(const DbType::Ptr& type) = 0;
virtual void NewTransaction(void) = 0; virtual void NewTransaction(void) = 0;
void UpdateObject(const DynamicObject::Ptr& object);
void UpdateAllObjects(void); void UpdateAllObjects(void);
void PrepareDatabase(void); void PrepareDatabase(void);

View File

@ -20,6 +20,8 @@
#include "db_ido/dbquery.hpp" #include "db_ido/dbquery.hpp"
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library db_ido;
namespace icinga namespace icinga
{ {

View File

@ -51,15 +51,15 @@ void DbEvents::StaticInitialize(void)
Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4)); Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4));
Checkable::OnAcknowledgementCleared.connect(boost::bind(&DbEvents::RemoveAcknowledgement, _1)); Checkable::OnAcknowledgementCleared.connect(boost::bind(&DbEvents::RemoveAcknowledgement, _1));
Checkable::OnNextCheckChanged.connect(boost::bind(&DbEvents::NextCheckChangedHandler, _1, _2)); Checkable::OnNextCheckChanged.connect(boost::bind(&DbEvents::NextCheckChangedHandler, _1));
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::FlappingChangedHandler, _1, _2)); Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::FlappingChangedHandler, _1));
Checkable::OnNotificationSentToAllUsers.connect(boost::bind(&DbEvents::LastNotificationChangedHandler, _1, _2)); Checkable::OnNotificationSentToAllUsers.connect(boost::bind(&DbEvents::LastNotificationChangedHandler, _1, _2));
Checkable::OnEnableActiveChecksChanged.connect(boost::bind(&DbEvents::EnableActiveChecksChangedHandler, _1, _2)); Checkable::OnEnableActiveChecksChanged.connect(boost::bind(&DbEvents::EnableActiveChecksChangedHandler, _1));
Checkable::OnEnablePassiveChecksChanged.connect(boost::bind(&DbEvents::EnablePassiveChecksChangedHandler, _1, _2)); Checkable::OnEnablePassiveChecksChanged.connect(boost::bind(&DbEvents::EnablePassiveChecksChangedHandler, _1));
Checkable::OnEnableNotificationsChanged.connect(boost::bind(&DbEvents::EnableNotificationsChangedHandler, _1, _2)); Checkable::OnEnableNotificationsChanged.connect(boost::bind(&DbEvents::EnableNotificationsChangedHandler, _1));
Checkable::OnEnablePerfdataChanged.connect(boost::bind(&DbEvents::EnablePerfdataChangedHandler, _1, _2)); Checkable::OnEnablePerfdataChanged.connect(boost::bind(&DbEvents::EnablePerfdataChangedHandler, _1));
Checkable::OnEnableFlappingChanged.connect(boost::bind(&DbEvents::EnableFlappingChangedHandler, _1, _2)); Checkable::OnEnableFlappingChanged.connect(boost::bind(&DbEvents::EnableFlappingChangedHandler, _1));
Checkable::OnReachabilityChanged.connect(boost::bind(&DbEvents::ReachabilityChangedHandler, _1, _2, _3)); Checkable::OnReachabilityChanged.connect(boost::bind(&DbEvents::ReachabilityChangedHandler, _1, _2, _3));
@ -74,11 +74,13 @@ void DbEvents::StaticInitialize(void)
Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddCheckResultLogHistory, _1, _2)); Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
Checkable::OnNotificationSentToUser.connect(boost::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7)); Checkable::OnNotificationSentToUser.connect(boost::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7));
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingLogHistory, _1, _2)); Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingChangedLogHistory, _1));
Checkable::OnEnableFlappingChanged.connect(boost::bind(&DbEvents::AddEnableFlappingChangedLogHistory, _1));
Checkable::OnDowntimeTriggered.connect(boost::bind(&DbEvents::AddTriggerDowntimeLogHistory, _1, _2)); Checkable::OnDowntimeTriggered.connect(boost::bind(&DbEvents::AddTriggerDowntimeLogHistory, _1, _2));
Checkable::OnDowntimeRemoved.connect(boost::bind(&DbEvents::AddRemoveDowntimeLogHistory, _1, _2)); Checkable::OnDowntimeRemoved.connect(boost::bind(&DbEvents::AddRemoveDowntimeLogHistory, _1, _2));
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingHistory, _1, _2)); Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingChangedHistory, _1));
Checkable::OnEnableFlappingChanged.connect(boost::bind(&DbEvents::AddEnableFlappingChangedHistory, _1));
Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddCheckableCheckHistory, _1, _2)); Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddCheckableCheckHistory, _1, _2));
Checkable::OnEventCommandExecuted.connect(boost::bind(&DbEvents::AddEventHandlerHistory, _1)); Checkable::OnEventCommandExecuted.connect(boost::bind(&DbEvents::AddEventHandlerHistory, _1));
@ -87,7 +89,7 @@ void DbEvents::StaticInitialize(void)
} }
/* check events */ /* check events */
void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck) void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable)
{ {
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;
@ -105,7 +107,7 @@ void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable, double n
query1.Object = DbObject::GetOrCreateByObject(checkable); query1.Object = DbObject::GetOrCreateByObject(checkable);
Dictionary::Ptr fields1 = new Dictionary(); Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("next_check", DbValue::FromTimestamp(nextCheck)); fields1->Set("next_check", DbValue::FromTimestamp(checkable->GetNextCheck()));
query1.Fields = fields1; query1.Fields = fields1;
@ -120,7 +122,7 @@ void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable, double n
DbObject::OnQuery(query1); DbObject::OnQuery(query1);
} }
void DbEvents::FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state) void DbEvents::FlappingChangedHandler(const Checkable::Ptr& checkable)
{ {
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;
@ -240,32 +242,32 @@ void DbEvents::ReachabilityChangedHandler(const Checkable::Ptr& checkable, const
} }
/* enable changed events */ /* enable changed events */
void DbEvents::EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled) void DbEvents::EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable)
{ {
EnableChangedHandlerInternal(checkable, enabled, EnableActiveChecks); EnableChangedHandlerInternal(checkable, "active_checks_enabled", checkable->GetEnableActiveChecks());
} }
void DbEvents::EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled) void DbEvents::EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable)
{ {
EnableChangedHandlerInternal(checkable, enabled, EnablePassiveChecks); EnableChangedHandlerInternal(checkable, "passive_checks_enabled", checkable->GetEnablePassiveChecks());
} }
void DbEvents::EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled) void DbEvents::EnableNotificationsChangedHandler(const Checkable::Ptr& checkable)
{ {
EnableChangedHandlerInternal(checkable, enabled, EnableNotifications); EnableChangedHandlerInternal(checkable, "notifications_enabled", checkable->GetEnableNotifications());
} }
void DbEvents::EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled) void DbEvents::EnablePerfdataChangedHandler(const Checkable::Ptr& checkable)
{ {
EnableChangedHandlerInternal(checkable, enabled, EnablePerfdata); EnableChangedHandlerInternal(checkable, "process_performance_data", checkable->GetEnablePerfdata());
} }
void DbEvents::EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled) void DbEvents::EnableFlappingChangedHandler(const Checkable::Ptr& checkable)
{ {
EnableChangedHandlerInternal(checkable, enabled, EnableFlapping); EnableChangedHandlerInternal(checkable, "flap_detection_enabled", checkable->GetEnableFlapping());
} }
void DbEvents::EnableChangedHandlerInternal(const Checkable::Ptr& checkable, bool enabled, EnableType type) void DbEvents::EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled)
{ {
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;
@ -283,19 +285,7 @@ void DbEvents::EnableChangedHandlerInternal(const Checkable::Ptr& checkable, boo
query1.Object = DbObject::GetOrCreateByObject(checkable); query1.Object = DbObject::GetOrCreateByObject(checkable);
Dictionary::Ptr fields1 = new Dictionary(); Dictionary::Ptr fields1 = new Dictionary();
fields1->Set(fieldName, enabled);
if (type == EnableActiveChecks) {
fields1->Set("active_checks_enabled", enabled ? 1 : 0);
} else if (type == EnablePassiveChecks) {
fields1->Set("passive_checks_enabled", enabled ? 1 : 0);
} else if (type == EnableNotifications) {
fields1->Set("notifications_enabled", enabled ? 1 : 0);
} else if (type == EnablePerfdata) {
fields1->Set("process_performance_data", enabled ? 1 : 0);
} else if (type == EnableFlapping) {
fields1->Set("flap_detection_enabled", enabled ? 1 : 0);
}
query1.Fields = fields1; query1.Fields = fields1;
query1.WhereCriteria = new Dictionary(); query1.WhereCriteria = new Dictionary();
@ -309,6 +299,7 @@ void DbEvents::EnableChangedHandlerInternal(const Checkable::Ptr& checkable, boo
DbObject::OnQuery(query1); DbObject::OnQuery(query1);
} }
/* comments */ /* comments */
void DbEvents::AddComments(const Checkable::Ptr& checkable) void DbEvents::AddComments(const Checkable::Ptr& checkable)
{ {
@ -1174,28 +1165,17 @@ void DbEvents::AddNotificationSentLogHistory(const Notification::Ptr& notificati
AddLogHistory(checkable, msgbuf.str(), LogEntryTypeHostNotification); AddLogHistory(checkable, msgbuf.str(), LogEntryTypeHostNotification);
} }
void DbEvents::AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingState flapping_state) void DbEvents::AddFlappingChangedLogHistory(const Checkable::Ptr& checkable)
{ {
String flapping_state_str; String flapping_state_str;
String flapping_output; String flapping_output;
switch (flapping_state) { if (checkable->IsFlapping()) {
case FlappingStarted:
flapping_output = "Service appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)"; flapping_output = "Service appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)";
flapping_state_str = "STARTED"; flapping_state_str = "STARTED";
break; } else {
case FlappingStopped:
flapping_output = "Service appears to have stopped flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change < " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)"; flapping_output = "Service appears to have stopped flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change < " + Convert::ToString(checkable->GetFlappingThreshold()) + "% threshold)";
flapping_state_str = "STOPPED"; flapping_state_str = "STOPPED";
break;
case FlappingDisabled:
flapping_output = "Flap detection has been disabled";
flapping_state_str = "DISABLED";
break;
default:
Log(LogCritical, "DbEvents")
<< "Unknown flapping state: " << flapping_state;
return;
} }
Host::Ptr host; Host::Ptr host;
@ -1222,6 +1202,38 @@ void DbEvents::AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingSt
AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage); AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage);
} }
void DbEvents::AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable)
{
if (!checkable->GetEnableFlapping())
return;
String flapping_output = "Flap detection has been disabled";
String flapping_state_str = "DISABLED";
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
std::ostringstream msgbuf;
if (service) {
msgbuf << "SERVICE FLAPPING ALERT: "
<< host->GetName() << ";"
<< service->GetShortName() << ";"
<< flapping_state_str << "; "
<< flapping_output
<< "";
} else {
msgbuf << "HOST FLAPPING ALERT: "
<< host->GetName() << ";"
<< flapping_state_str << "; "
<< flapping_output
<< "";
}
AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage);
}
void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type) void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type)
{ {
Log(LogDebug, "DbEvents") Log(LogDebug, "DbEvents")
@ -1256,7 +1268,7 @@ void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, String buffer, Log
} }
/* flappinghistory */ /* flappinghistory */
void DbEvents::AddFlappingHistory(const Checkable::Ptr& checkable, FlappingState flapping_state) void DbEvents::AddFlappingChangedHistory(const Checkable::Ptr& checkable)
{ {
Log(LogDebug, "DbEvents") Log(LogDebug, "DbEvents")
<< "add flapping history for '" << checkable->GetName() << "'"; << "add flapping history for '" << checkable->GetName() << "'";
@ -1274,23 +1286,58 @@ void DbEvents::AddFlappingHistory(const Checkable::Ptr& checkable, FlappingState
fields1->Set("event_time", DbValue::FromTimestamp(time_bag.first)); fields1->Set("event_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("event_time_usec", time_bag.second); fields1->Set("event_time_usec", time_bag.second);
switch (flapping_state) { if (checkable->IsFlapping())
case FlappingStarted:
fields1->Set("event_type", 1000); fields1->Set("event_type", 1000);
break; else {
case FlappingStopped:
fields1->Set("event_type", 1001); fields1->Set("event_type", 1001);
fields1->Set("reason_type", 1); fields1->Set("reason_type", 1);
break; }
case FlappingDisabled:
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
fields1->Set("flapping_type", service ? 1 : 0);
fields1->Set("object_id", checkable);
fields1->Set("percent_state_change", checkable->GetFlappingCurrent());
fields1->Set("low_threshold", checkable->GetFlappingThreshold());
fields1->Set("high_threshold", checkable->GetFlappingThreshold());
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
String node = IcingaApplication::GetInstance()->GetNodeName();
Endpoint::Ptr endpoint = Endpoint::GetByName(node);
if (endpoint)
fields1->Set("endpoint_object_id", endpoint);
query1.Fields = fields1;
DbObject::OnQuery(query1);
}
void DbEvents::AddEnableFlappingChangedHistory(const Checkable::Ptr& checkable)
{
Log(LogDebug, "DbEvents")
<< "add flapping history for '" << checkable->GetName() << "'";
double now = Utility::GetTime();
std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "flappinghistory";
query1.Type = DbQueryInsert;
query1.Category = DbCatFlapping;
Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("event_time", DbValue::FromTimestamp(time_bag.first));
fields1->Set("event_time_usec", time_bag.second);
if (!checkable->GetEnableFlapping())
return;
fields1->Set("event_type", 1001); fields1->Set("event_type", 1001);
fields1->Set("reason_type", 2); fields1->Set("reason_type", 2);
break;
default:
Log(LogDebug, "DbEvents")
<< "Unhandled flapping state: " << flapping_state;
return;
}
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;

View File

@ -51,15 +51,6 @@ enum LogEntryType
LogEntryTypeServiceNotification = 1048576 LogEntryTypeServiceNotification = 1048576
}; };
enum EnableType
{
EnableActiveChecks = 1,
EnablePassiveChecks = 2,
EnableNotifications = 3,
EnablePerfdata = 4,
EnableFlapping = 5
};
/** /**
* IDO events * IDO events
* *
@ -81,15 +72,15 @@ public:
static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type); static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type);
/* Status */ /* Status */
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck); static void NextCheckChangedHandler(const Checkable::Ptr& checkable);
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state); static void FlappingChangedHandler(const Checkable::Ptr& checkable);
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable); static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled); static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable);
static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled); static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable);
static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled); static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable);
static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled); static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable);
static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled); static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment); static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment); static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
@ -125,10 +116,13 @@ public:
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable, static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author, const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
const String& comment_text); const String& comment_text);
static void AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingState flapping_state);
static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
/* other history */ /* other history */
static void AddFlappingHistory(const Checkable::Ptr& checkable, FlappingState flapping_state); static void AddFlappingChangedHistory(const Checkable::Ptr& checkable);
static void AddEnableFlappingChangedHistory(const Checkable::Ptr& checkable);
static void AddCheckableCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr); static void AddCheckableCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
static void AddEventHandlerHistory(const Checkable::Ptr& checkable); static void AddEventHandlerHistory(const Checkable::Ptr& checkable);
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments); static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
@ -138,7 +132,7 @@ private:
static void AddCommentInternal(const Checkable::Ptr& checkable, const Comment::Ptr& comment, bool historical); static void AddCommentInternal(const Checkable::Ptr& checkable, const Comment::Ptr& comment, bool historical);
static void AddDowntimeInternal(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical); static void AddDowntimeInternal(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical);
static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, bool enabled, EnableType type); static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled);
}; };
} }

View File

@ -36,6 +36,7 @@ if(MYSQL_FOUND)
set_target_properties ( set_target_properties (
db_ido_mysql PROPERTIES db_ido_mysql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_DB_IDO_MYSQL_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -19,6 +19,8 @@
#include "db_ido/dbconnection.hpp" #include "db_ido/dbconnection.hpp"
library db_ido_mysql;
namespace icinga namespace icinga
{ {

View File

@ -38,6 +38,7 @@ if(PostgreSQL_FOUND)
set_target_properties ( set_target_properties (
db_ido_pgsql PROPERTIES db_ido_pgsql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_DB_IDO_PGSQL_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -19,6 +19,8 @@
#include "db_ido/dbconnection.hpp" #include "db_ido/dbconnection.hpp"
library db_ido_pgsql;
namespace icinga namespace icinga
{ {

View File

@ -32,6 +32,7 @@ target_link_libraries(demo ${Boost_LIBRARIES} base config icinga remote)
set_target_properties ( set_target_properties (
demo PROPERTIES demo PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_DEMO_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -53,7 +53,8 @@ void Demo::DemoTimerHandler(void)
ApiListener::Ptr listener = ApiListener::GetInstance(); ApiListener::Ptr listener = ApiListener::GetInstance();
if (listener) { if (listener) {
listener->RelayMessage(MessageOrigin(), DynamicObject::Ptr(), message, true); MessageOrigin::Ptr origin = new MessageOrigin();
listener->RelayMessage(origin, DynamicObject::Ptr(), message, true);
Log(LogInformation, "Demo", "Sent demo::HelloWorld message"); Log(LogInformation, "Demo", "Sent demo::HelloWorld message");
} }
} }

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library demo;
namespace icinga namespace icinga
{ {

View File

@ -34,6 +34,7 @@ target_link_libraries(hello ${Boost_LIBRARIES} base config)
set_target_properties ( set_target_properties (
hello PROPERTIES hello PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_HELLO_BUILD
FOLDER Lib FOLDER Lib
) )

View File

@ -19,6 +19,8 @@
#include "base/application.hpp" #include "base/application.hpp"
library hello;
namespace icinga namespace icinga
{ {

File diff suppressed because it is too large Load Diff

View File

@ -37,84 +37,84 @@ class I2_ICINGA_API ApiEvents
public: public:
static void StaticInitialize(void); static void StaticInitialize(void);
static void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const MessageOrigin& origin); static void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin);
static Value CheckResultAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CheckResultAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck, const MessageOrigin& origin); static void NextCheckChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value NextCheckChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value NextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const MessageOrigin& origin); static void NextNotificationChangedHandler(const Notification::Ptr& notification, const MessageOrigin::Ptr& origin);
static Value NextNotificationChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value NextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void ForceNextCheckChangedHandler(const Checkable::Ptr& checkable, bool forced, const MessageOrigin& origin); static void ForceNextCheckChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value ForceNextCheckChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value ForceNextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void ForceNextNotificationChangedHandler(const Checkable::Ptr& checkable, bool forced, const MessageOrigin& origin); static void ForceNextNotificationChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value ForceNextNotificationChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value ForceNextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnableActiveChecksChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnableActiveChecksChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnablePassiveChecksChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnablePassiveChecksChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnableNotificationsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnableNotificationsChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnableFlappingChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnableFlappingChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnableEventHandlerChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnableEventHandlerChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnableEventHandlerChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnableEventHandlerChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EnablePerfdataChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnablePerfdataChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void CheckIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin); static void CheckIntervalChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value CheckIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CheckIntervalChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void RetryIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin); static void RetryIntervalChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value RetryIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value RetryIntervalChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void MaxCheckAttemptsChangedHandler(const Checkable::Ptr& checkable, int attempts, const MessageOrigin& origin); static void MaxCheckAttemptsChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value MaxCheckAttemptsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value MaxCheckAttemptsChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void EventCommandChangedHandler(const Checkable::Ptr& checkable, const EventCommand::Ptr& command, const MessageOrigin& origin); static void EventCommandChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value EventCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EventCommandChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void CheckCommandChangedHandler(const Checkable::Ptr& checkable, const CheckCommand::Ptr& command, const MessageOrigin& origin); static void CheckCommandChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value CheckCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CheckCommandChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void CheckPeriodChangedHandler(const Checkable::Ptr& checkable, const TimePeriod::Ptr& timeperiod, const MessageOrigin& origin); static void CheckPeriodChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value CheckPeriodChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CheckPeriodChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void VarsChangedHandler(const CustomVarObject::Ptr& object, const Dictionary::Ptr& vars, const MessageOrigin& origin); static void VarsChangedHandler(const CustomVarObject::Ptr& object, const MessageOrigin::Ptr& origin);
static Value VarsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value VarsChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void CommentAddedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin& origin); static void CommentAddedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin::Ptr& origin);
static Value CommentAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CommentAddedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void CommentRemovedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin& origin); static void CommentRemovedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin::Ptr& origin);
static Value CommentRemovedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CommentRemovedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void DowntimeAddedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const MessageOrigin& origin); static void DowntimeAddedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const MessageOrigin::Ptr& origin);
static Value DowntimeAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value DowntimeAddedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void DowntimeRemovedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const MessageOrigin& origin); static void DowntimeRemovedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const MessageOrigin::Ptr& origin);
static Value DowntimeRemovedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value DowntimeRemovedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type,
bool notify, double expiry, const MessageOrigin& origin); bool notify, double expiry, const MessageOrigin::Ptr& origin);
static Value AcknowledgementSetAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin& origin); static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
static Value AcknowledgementClearedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static Value ExecuteCommandAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static String GetRepositoryDir(void); static String GetRepositoryDir(void);
static void RepositoryTimerHandler(void); static void RepositoryTimerHandler(void);
static Value UpdateRepositoryAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value UpdateRepositoryAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static Dictionary::Ptr MakeCheckResultMessage(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr); static Dictionary::Ptr MakeCheckResultMessage(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
}; };

View File

@ -35,90 +35,19 @@
using namespace icinga; using namespace icinga;
boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin&)> Checkable::OnNewCheckResult; boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnNewCheckResult;
boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin&)> Checkable::OnStateChange; boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin::Ptr&)> Checkable::OnStateChange;
boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin&)> Checkable::OnReachabilityChanged; boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin::Ptr&)> Checkable::OnReachabilityChanged;
boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, const String&, const String&)> Checkable::OnNotificationsRequested; boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, const String&, const String&)> Checkable::OnNotificationsRequested;
boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> Checkable::OnNextCheckChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnForceNextCheckChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnForceNextNotificationChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnableActiveChecksChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePassiveChecksChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnableNotificationsChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnableFlappingChanged;
boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> Checkable::OnCheckIntervalChanged;
boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> Checkable::OnRetryIntervalChanged;
boost::signals2::signal<void (const Checkable::Ptr&, const CheckCommand::Ptr&, const MessageOrigin&)> Checkable::OnCheckCommandChanged;
boost::signals2::signal<void (const Checkable::Ptr&, int, const MessageOrigin&)> Checkable::OnMaxCheckAttemptsChanged;
boost::signals2::signal<void (const Checkable::Ptr&, const TimePeriod::Ptr&, const MessageOrigin&)> Checkable::OnCheckPeriodChanged;
boost::signals2::signal<void (const Checkable::Ptr&, FlappingState)> Checkable::OnFlappingChanged;
CheckCommand::Ptr Checkable::GetCheckCommand(void) const CheckCommand::Ptr Checkable::GetCheckCommand(void) const
{ {
String command; return CheckCommand::GetByName(GetCheckCommandRaw());
if (!GetOverrideCheckCommand().IsEmpty())
command = GetOverrideCheckCommand();
else
command = GetCheckCommandRaw();
return CheckCommand::GetByName(command);
}
void Checkable::SetCheckCommand(const CheckCommand::Ptr& command, const MessageOrigin& origin)
{
SetOverrideCheckCommand(command->GetName());
OnCheckCommandChanged(this, command, origin);
} }
TimePeriod::Ptr Checkable::GetCheckPeriod(void) const TimePeriod::Ptr Checkable::GetCheckPeriod(void) const
{ {
String tp; return TimePeriod::GetByName(GetCheckPeriodRaw());
if (!GetOverrideCheckPeriod().IsEmpty())
tp = GetOverrideCheckPeriod();
else
tp = GetCheckPeriodRaw();
return TimePeriod::GetByName(tp);
}
void Checkable::SetCheckPeriod(const TimePeriod::Ptr& tp, const MessageOrigin& origin)
{
SetOverrideCheckPeriod(tp->GetName());
OnCheckPeriodChanged(this, tp, origin);
}
double Checkable::GetCheckInterval(void) const
{
if (!GetOverrideCheckInterval().IsEmpty())
return GetOverrideCheckInterval();
else
return GetCheckIntervalRaw();
}
void Checkable::SetCheckInterval(double interval, const MessageOrigin& origin)
{
SetOverrideCheckInterval(interval);
OnCheckIntervalChanged(this, interval, origin);
}
double Checkable::GetRetryInterval(void) const
{
if (!GetOverrideRetryInterval().IsEmpty())
return GetOverrideRetryInterval();
else
return GetRetryIntervalRaw();
}
void Checkable::SetRetryInterval(double interval, const MessageOrigin& origin)
{
SetOverrideRetryInterval(interval);
OnRetryIntervalChanged(this, interval, origin);
} }
void Checkable::SetSchedulingOffset(long offset) void Checkable::SetSchedulingOffset(long offset)
@ -131,18 +60,6 @@ long Checkable::GetSchedulingOffset(void)
return m_SchedulingOffset; return m_SchedulingOffset;
} }
void Checkable::SetNextCheck(double nextCheck, const MessageOrigin& origin)
{
SetNextCheckRaw(nextCheck);
OnNextCheckChanged(this, nextCheck, origin);
}
double Checkable::GetNextCheck(void)
{
return GetNextCheckRaw();
}
void Checkable::UpdateNextCheck(void) void Checkable::UpdateNextCheck(void)
{ {
double interval; double interval;
@ -177,64 +94,7 @@ double Checkable::GetLastCheck(void) const
return schedule_end; return schedule_end;
} }
bool Checkable::GetEnableActiveChecks(void) const void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin)
{
if (!GetOverrideEnableActiveChecks().IsEmpty())
return GetOverrideEnableActiveChecks();
else
return GetEnableActiveChecksRaw();
}
void Checkable::SetEnableActiveChecks(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnableActiveChecks(enabled);
OnEnableActiveChecksChanged(this, enabled, origin);
}
bool Checkable::GetEnablePassiveChecks(void) const
{
if (!GetOverrideEnablePassiveChecks().IsEmpty())
return GetOverrideEnablePassiveChecks();
else
return GetEnablePassiveChecksRaw();
}
void Checkable::SetEnablePassiveChecks(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnablePassiveChecks(enabled);
OnEnablePassiveChecksChanged(this, enabled, origin);
}
bool Checkable::GetForceNextCheck(void) const
{
return GetForceNextCheckRaw();
}
void Checkable::SetForceNextCheck(bool forced, const MessageOrigin& origin)
{
SetForceNextCheckRaw(forced);
OnForceNextCheckChanged(this, forced, origin);
}
int Checkable::GetMaxCheckAttempts(void) const
{
if (!GetOverrideMaxCheckAttempts().IsEmpty())
return GetOverrideMaxCheckAttempts();
else
return GetMaxCheckAttemptsRaw();
}
void Checkable::SetMaxCheckAttempts(int attempts, const MessageOrigin& origin)
{
SetOverrideMaxCheckAttempts(attempts);
OnMaxCheckAttemptsChanged(this, attempts, origin);
}
void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin)
{ {
{ {
ObjectLock olock(this); ObjectLock olock(this);
@ -255,7 +115,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
if (cr->GetExecutionEnd() == 0) if (cr->GetExecutionEnd() == 0)
cr->SetExecutionEnd(now); cr->SetExecutionEnd(now);
if (origin.IsLocal()) if (!origin || origin->IsLocal())
cr->SetCheckSource(IcingaApplication::GetInstance()->GetNodeName()); cr->SetCheckSource(IcingaApplication::GetInstance()->GetNodeName());
Endpoint::Ptr command_endpoint = GetCommandEndpoint(); Endpoint::Ptr command_endpoint = GetCommandEndpoint();
@ -487,13 +347,15 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
Log(LogNotice, "Checkable") Log(LogNotice, "Checkable")
<< "Flapping: Checkable " << GetName() << " started flapping (" << GetFlappingThreshold() << "% < " << GetFlappingCurrent() << "%)."; << "Flapping: Checkable " << GetName() << " started flapping (" << GetFlappingThreshold() << "% < " << GetFlappingCurrent() << "%).";
OnFlappingChanged(this, FlappingStarted);
NotifyFlapping(origin);
} else if (was_flapping && !is_flapping) { } else if (was_flapping && !is_flapping) {
OnNotificationsRequested(this, NotificationFlappingEnd, cr, "", ""); OnNotificationsRequested(this, NotificationFlappingEnd, cr, "", "");
Log(LogNotice, "Checkable") Log(LogNotice, "Checkable")
<< "Flapping: Checkable " << GetName() << " stopped flapping (" << GetFlappingThreshold() << "% >= " << GetFlappingCurrent() << "%)."; << "Flapping: Checkable " << GetName() << " stopped flapping (" << GetFlappingThreshold() << "% >= " << GetFlappingCurrent() << "%).";
OnFlappingChanged(this, FlappingStopped);
NotifyFlapping(origin);
} else if (send_notification) } else if (send_notification)
OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", ""); OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", "");
} }

View File

@ -33,8 +33,8 @@ static std::map<int, String> l_LegacyCommentsCache;
static std::map<String, Checkable::Ptr> l_CommentsCache; static std::map<String, Checkable::Ptr> l_CommentsCache;
static Timer::Ptr l_CommentsExpireTimer; static Timer::Ptr l_CommentsExpireTimer;
boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin&)> Checkable::OnCommentAdded; boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnCommentAdded;
boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin&)> Checkable::OnCommentRemoved; boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnCommentRemoved;
int Checkable::GetNextCommentID(void) int Checkable::GetNextCommentID(void)
{ {
@ -44,7 +44,7 @@ int Checkable::GetNextCommentID(void)
} }
String Checkable::AddComment(CommentType entryType, const String& author, String Checkable::AddComment(CommentType entryType, const String& author,
const String& text, double expireTime, const String& id, const MessageOrigin& origin) const String& text, double expireTime, const String& id, const MessageOrigin::Ptr& origin)
{ {
String uid; String uid;
@ -100,7 +100,7 @@ void Checkable::RemoveAllComments(void)
} }
} }
void Checkable::RemoveComment(const String& id, const MessageOrigin& origin) void Checkable::RemoveComment(const String& id, const MessageOrigin::Ptr& origin)
{ {
Checkable::Ptr owner = GetOwnerByCommentID(id); Checkable::Ptr owner = GetOwnerByCommentID(id);

View File

@ -34,8 +34,8 @@ static std::map<int, String> l_LegacyDowntimesCache;
static std::map<String, Checkable::Ptr> l_DowntimesCache; static std::map<String, Checkable::Ptr> l_DowntimesCache;
static Timer::Ptr l_DowntimesExpireTimer; static Timer::Ptr l_DowntimesExpireTimer;
boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin&)> Checkable::OnDowntimeAdded; boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnDowntimeAdded;
boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin&)> Checkable::OnDowntimeRemoved; boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnDowntimeRemoved;
boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&)> Checkable::OnDowntimeTriggered; boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&)> Checkable::OnDowntimeTriggered;
INITIALIZE_ONCE(&Checkable::StartDowntimesExpiredTimer); INITIALIZE_ONCE(&Checkable::StartDowntimesExpiredTimer);
@ -50,7 +50,7 @@ int Checkable::GetNextDowntimeID(void)
String Checkable::AddDowntime(const String& author, const String& comment, String Checkable::AddDowntime(const String& author, const String& comment,
double startTime, double endTime, bool fixed, double startTime, double endTime, bool fixed,
const String& triggeredBy, double duration, const String& scheduledBy, const String& triggeredBy, double duration, const String& scheduledBy,
const String& id, const MessageOrigin& origin) const String& id, const MessageOrigin::Ptr& origin)
{ {
String uid; String uid;
@ -125,7 +125,7 @@ String Checkable::AddDowntime(const String& author, const String& comment,
return uid; return uid;
} }
void Checkable::RemoveDowntime(const String& id, bool cancelled, const MessageOrigin& origin) void Checkable::RemoveDowntime(const String& id, bool cancelled, const MessageOrigin::Ptr& origin)
{ {
Checkable::Ptr owner = GetOwnerByDowntimeID(id); Checkable::Ptr owner = GetOwnerByDowntimeID(id);

View File

@ -28,41 +28,10 @@
using namespace icinga; using namespace icinga;
boost::signals2::signal<void (const Checkable::Ptr&)> Checkable::OnEventCommandExecuted; boost::signals2::signal<void (const Checkable::Ptr&)> Checkable::OnEventCommandExecuted;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnableEventHandlerChanged;
boost::signals2::signal<void (const Checkable::Ptr&, const EventCommand::Ptr&, const MessageOrigin&)> Checkable::OnEventCommandChanged;
bool Checkable::GetEnableEventHandler(void) const
{
if (!GetOverrideEnableEventHandler().IsEmpty())
return GetOverrideEnableEventHandler();
else
return GetEnableEventHandlerRaw();
}
void Checkable::SetEnableEventHandler(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnableEventHandler(enabled);
OnEnableEventHandlerChanged(this, enabled, origin);
}
EventCommand::Ptr Checkable::GetEventCommand(void) const EventCommand::Ptr Checkable::GetEventCommand(void) const
{ {
String command; return EventCommand::GetByName(GetEventCommandRaw());
if (!GetOverrideEventCommand().IsEmpty())
command = GetOverrideEventCommand();
else
command = GetEventCommandRaw();
return EventCommand::GetByName(command);
}
void Checkable::SetEventCommand(const EventCommand::Ptr& command, const MessageOrigin& origin)
{
SetOverrideEventCommand(command->GetName());
OnEventCommandChanged(this, command, origin);
} }
void Checkable::ExecuteEventHandler(const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros) void Checkable::ExecuteEventHandler(const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -34,22 +34,6 @@ double Checkable::GetFlappingCurrent(void) const
return 100 * GetFlappingPositive() / (GetFlappingPositive() + GetFlappingNegative()); return 100 * GetFlappingPositive() / (GetFlappingPositive() + GetFlappingNegative());
} }
bool Checkable::GetEnableFlapping(void) const
{
if (!GetOverrideEnableFlapping().IsEmpty())
return GetOverrideEnableFlapping();
else
return GetEnableFlappingRaw();
}
void Checkable::SetEnableFlapping(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnableFlapping(enabled);
OnFlappingChanged(this, enabled ? FlappingEnabled : FlappingDisabled);
OnEnableFlappingChanged(this, enabled, origin);
}
void Checkable::UpdateFlappingStatus(bool stateChange) void Checkable::UpdateFlappingStatus(bool stateChange)
{ {
double ts, now; double ts, now;

View File

@ -99,30 +99,3 @@ void Checkable::RemoveNotification(const Notification::Ptr& notification)
boost::mutex::scoped_lock lock(m_NotificationMutex); boost::mutex::scoped_lock lock(m_NotificationMutex);
m_Notifications.erase(notification); m_Notifications.erase(notification);
} }
bool Checkable::GetEnableNotifications(void) const
{
if (!GetOverrideEnableNotifications().IsEmpty())
return GetOverrideEnableNotifications();
else
return GetEnableNotificationsRaw();
}
void Checkable::SetEnableNotifications(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnableNotifications(enabled);
OnEnableNotificationsChanged(this, enabled, origin);
}
bool Checkable::GetForceNextNotification(void) const
{
return GetForceNextNotificationRaw();
}
void Checkable::SetForceNextNotification(bool forced, const MessageOrigin& origin)
{
SetForceNextNotificationRaw(forced);
OnForceNextNotificationChanged(this, forced, origin);
}

View File

@ -31,9 +31,8 @@ using namespace icinga;
REGISTER_TYPE(Checkable); REGISTER_TYPE(Checkable);
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePerfdataChanged; boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet; boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> Checkable::OnAcknowledgementCleared;
Checkable::Checkable(void) Checkable::Checkable(void)
: m_CheckRunning(false) : m_CheckRunning(false)
@ -121,7 +120,7 @@ bool Checkable::IsAcknowledged(void)
return GetAcknowledgement() != AcknowledgementNone; return GetAcknowledgement() != AcknowledgementNone;
} }
void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, double expiry, const MessageOrigin& origin) void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, double expiry, const MessageOrigin::Ptr& origin)
{ {
SetAcknowledgementRaw(type); SetAcknowledgementRaw(type);
SetAcknowledgementExpiry(expiry); SetAcknowledgementExpiry(expiry);
@ -132,7 +131,7 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
OnAcknowledgementSet(this, author, comment, type, notify, expiry, origin); OnAcknowledgementSet(this, author, comment, type, notify, expiry, origin);
} }
void Checkable::ClearAcknowledgement(const MessageOrigin& origin) void Checkable::ClearAcknowledgement(const MessageOrigin::Ptr& origin)
{ {
SetAcknowledgementRaw(AcknowledgementNone); SetAcknowledgementRaw(AcknowledgementNone);
SetAcknowledgementExpiry(0); SetAcknowledgementExpiry(0);
@ -140,121 +139,16 @@ void Checkable::ClearAcknowledgement(const MessageOrigin& origin)
OnAcknowledgementCleared(this, origin); OnAcknowledgementCleared(this, origin);
} }
bool Checkable::GetEnablePerfdata(void) const
{
if (!GetOverrideEnablePerfdata().IsEmpty())
return GetOverrideEnablePerfdata();
else
return GetEnablePerfdataRaw();
}
void Checkable::SetEnablePerfdata(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnablePerfdata(enabled);
OnEnablePerfdataChanged(this, enabled, origin);
}
int Checkable::GetModifiedAttributes(void) const int Checkable::GetModifiedAttributes(void) const
{ {
int attrs = 0; //TODO-MA
return 0;
if (!GetOverrideEnableNotifications().IsEmpty())
attrs |= ModAttrNotificationsEnabled;
if (!GetOverrideEnableActiveChecks().IsEmpty())
attrs |= ModAttrActiveChecksEnabled;
if (!GetOverrideEnablePassiveChecks().IsEmpty())
attrs |= ModAttrPassiveChecksEnabled;
if (!GetOverrideEnableFlapping().IsEmpty())
attrs |= ModAttrFlapDetectionEnabled;
if (!GetOverrideEnableEventHandler().IsEmpty())
attrs |= ModAttrEventHandlerEnabled;
if (!GetOverrideEnablePerfdata().IsEmpty())
attrs |= ModAttrPerformanceDataEnabled;
if (!GetOverrideCheckInterval().IsEmpty())
attrs |= ModAttrNormalCheckInterval;
if (!GetOverrideRetryInterval().IsEmpty())
attrs |= ModAttrRetryCheckInterval;
if (!GetOverrideEventCommand().IsEmpty())
attrs |= ModAttrEventHandlerCommand;
if (!GetOverrideCheckCommand().IsEmpty())
attrs |= ModAttrCheckCommand;
if (!GetOverrideMaxCheckAttempts().IsEmpty())
attrs |= ModAttrMaxCheckAttempts;
if (!GetOverrideCheckPeriod().IsEmpty())
attrs |= ModAttrCheckTimeperiod;
if (GetOverrideVars())
attrs |= ModAttrCustomVariable;
// TODO: finish
return attrs;
} }
void Checkable::SetModifiedAttributes(int flags, const MessageOrigin& origin) void Checkable::SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin)
{ {
if ((flags & ModAttrNotificationsEnabled) == 0) { //TODO-MA
SetOverrideEnableNotifications(Empty); return;
OnEnableNotificationsChanged(this, GetEnableNotifications(), origin);
}
if ((flags & ModAttrActiveChecksEnabled) == 0) {
SetOverrideEnableActiveChecks(Empty);
OnEnableActiveChecksChanged(this, GetEnableActiveChecks(), origin);
}
if ((flags & ModAttrPassiveChecksEnabled) == 0) {
SetOverrideEnablePassiveChecks(Empty);
OnEnablePassiveChecksChanged(this, GetEnablePassiveChecks(), origin);
}
if ((flags & ModAttrFlapDetectionEnabled) == 0) {
SetOverrideEnableFlapping(Empty);
OnEnableFlappingChanged(this, GetEnableFlapping(), origin);
}
if ((flags & ModAttrEventHandlerEnabled) == 0)
SetOverrideEnableEventHandler(Empty);
if ((flags & ModAttrPerformanceDataEnabled) == 0) {
SetOverrideEnablePerfdata(Empty);
OnEnablePerfdataChanged(this, GetEnablePerfdata(), origin);
}
if ((flags & ModAttrNormalCheckInterval) == 0)
SetOverrideCheckInterval(Empty);
if ((flags & ModAttrRetryCheckInterval) == 0)
SetOverrideRetryInterval(Empty);
if ((flags & ModAttrEventHandlerCommand) == 0)
SetOverrideEventCommand(Empty);
if ((flags & ModAttrCheckCommand) == 0)
SetOverrideCheckCommand(Empty);
if ((flags & ModAttrMaxCheckAttempts) == 0)
SetOverrideMaxCheckAttempts(Empty);
if ((flags & ModAttrCheckTimeperiod) == 0)
SetOverrideCheckPeriod(Empty);
if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty);
OnVarsChanged(this, GetVars(), origin);
}
} }
Endpoint::Ptr Checkable::GetCommandEndpoint(void) const Endpoint::Ptr Checkable::GetCommandEndpoint(void) const
@ -262,9 +156,9 @@ Endpoint::Ptr Checkable::GetCommandEndpoint(void) const
return Endpoint::GetByName(GetCommandEndpointRaw()); return Endpoint::GetByName(GetCommandEndpointRaw());
} }
void Checkable::ValidateCheckIntervalRaw(double value, const ValidationUtils& utils) void Checkable::ValidateCheckInterval(double value, const ValidationUtils& utils)
{ {
ObjectImpl<Checkable>::ValidateCheckIntervalRaw(value, utils); ObjectImpl<Checkable>::ValidateCheckInterval(value, utils);
if (value <= 0) if (value <= 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("check_interval"), "Interval must be greater than 0.")); BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("check_interval"), "Interval must be greater than 0."));

View File

@ -32,19 +32,6 @@
namespace icinga namespace icinga
{ {
/**
* The state of service flapping.
*
* @ingroup icinga
*/
enum FlappingState
{
FlappingStarted = 0,
FlappingDisabled = 1,
FlappingStopped = 2,
FlappingEnabled = 3
};
/** /**
* @ingroup icinga * @ingroup icinga
*/ */
@ -94,53 +81,30 @@ public:
AcknowledgementType GetAcknowledgement(void); AcknowledgementType GetAcknowledgement(void);
void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, double expiry = 0, const MessageOrigin& origin = MessageOrigin()); void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, double expiry = 0, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void ClearAcknowledgement(const MessageOrigin& origin = MessageOrigin()); void ClearAcknowledgement(const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
/* Checks */ /* Checks */
intrusive_ptr<CheckCommand> GetCheckCommand(void) const; intrusive_ptr<CheckCommand> GetCheckCommand(void) const;
void SetCheckCommand(const intrusive_ptr<CheckCommand>& command, const MessageOrigin& origin = MessageOrigin());
TimePeriod::Ptr GetCheckPeriod(void) const; TimePeriod::Ptr GetCheckPeriod(void) const;
void SetCheckPeriod(const TimePeriod::Ptr& tp, const MessageOrigin& origin = MessageOrigin());
double GetCheckInterval(void) const;
void SetCheckInterval(double interval, const MessageOrigin& origin = MessageOrigin());
double GetRetryInterval(void) const;
void SetRetryInterval(double interval, const MessageOrigin& origin = MessageOrigin());
int GetMaxCheckAttempts(void) const;
void SetMaxCheckAttempts(int attempts, const MessageOrigin& origin = MessageOrigin());
long GetSchedulingOffset(void); long GetSchedulingOffset(void);
void SetSchedulingOffset(long offset); void SetSchedulingOffset(long offset);
void SetNextCheck(double nextCheck, const MessageOrigin& origin = MessageOrigin());
double GetNextCheck(void);
void UpdateNextCheck(void); void UpdateNextCheck(void);
bool HasBeenChecked(void) const; bool HasBeenChecked(void) const;
double GetLastCheck(void) const; double GetLastCheck(void) const;
bool GetEnableActiveChecks(void) const;
void SetEnableActiveChecks(bool enabled, const MessageOrigin& origin = MessageOrigin());
bool GetEnablePassiveChecks(void) const;
void SetEnablePassiveChecks(bool enabled, const MessageOrigin& origin = MessageOrigin());
bool GetForceNextCheck(void) const;
void SetForceNextCheck(bool forced, const MessageOrigin& origin = MessageOrigin());
static void UpdateStatistics(const CheckResult::Ptr& cr, CheckableType type); static void UpdateStatistics(const CheckResult::Ptr& cr, CheckableType type);
void ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr()); void ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr());
void ExecuteCheck(); void ExecuteCheck();
void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin = MessageOrigin()); void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
int GetModifiedAttributes(void) const; int GetModifiedAttributes(void) const;
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin()); void SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
Endpoint::Ptr GetCommandEndpoint(void) const; Endpoint::Ptr GetCommandEndpoint(void) const;
@ -149,26 +113,9 @@ public:
static double CalculateExecutionTime(const CheckResult::Ptr& cr); static double CalculateExecutionTime(const CheckResult::Ptr& cr);
static double CalculateLatency(const CheckResult::Ptr& cr); static double CalculateLatency(const CheckResult::Ptr& cr);
static boost::signals2::signal<void (const Checkable::Ptr&, double, const MessageOrigin&)> OnNextCheckChanged; static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin::Ptr&)> OnNewCheckResult;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnForceNextCheckChanged; static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin::Ptr&)> OnStateChange;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnForceNextNotificationChanged; static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin::Ptr&)> OnReachabilityChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableActiveChecksChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePassiveChecksChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableFlappingChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePerfdataChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableEventHandlerChanged;
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 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;
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin&)> OnStateChange;
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin&)> OnReachabilityChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
const String&, const String&)> OnNotificationsRequested; const String&, const String&)> OnNotificationsRequested;
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&, static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&,
@ -180,15 +127,14 @@ public:
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&, static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&,
const NotificationType&, const CheckResult::Ptr&, const String&, const NotificationType&, const CheckResult::Ptr&, const String&,
const String&)> OnNotificationSentToAllUsers; const String&)> OnNotificationSentToAllUsers;
static boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin&)> OnCommentAdded; static boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin::Ptr&)> OnCommentAdded;
static boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin&)> OnCommentRemoved; static boost::signals2::signal<void (const Checkable::Ptr&, const Comment::Ptr&, const MessageOrigin::Ptr&)> OnCommentRemoved;
static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin&)> OnDowntimeAdded; static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin::Ptr&)> OnDowntimeAdded;
static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin&)> OnDowntimeRemoved; static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&, const MessageOrigin::Ptr&)> OnDowntimeRemoved;
static boost::signals2::signal<void (const Checkable::Ptr&, FlappingState)> OnFlappingChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&)> OnDowntimeTriggered; static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&)> OnDowntimeTriggered;
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType,
bool, double, const MessageOrigin&)> OnAcknowledgementSet; bool, double, const MessageOrigin::Ptr&)> OnAcknowledgementSet;
static boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> OnAcknowledgementCleared; static boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted; static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted;
/* Downtimes */ /* Downtimes */
@ -200,9 +146,9 @@ public:
double startTime, double endTime, bool fixed, double startTime, double endTime, bool fixed,
const String& triggeredBy, double duration, const String& triggeredBy, double duration,
const String& scheduledBy = String(), const String& id = String(), const String& scheduledBy = String(), const String& id = String(),
const MessageOrigin& origin = MessageOrigin()); const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
static void RemoveDowntime(const String& id, bool cancelled, const MessageOrigin& origin = MessageOrigin()); static void RemoveDowntime(const String& id, bool cancelled, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void TriggerDowntimes(void); void TriggerDowntimes(void);
static void TriggerDowntime(const String& id); static void TriggerDowntime(const String& id);
@ -220,29 +166,23 @@ public:
static int GetNextCommentID(void); static int GetNextCommentID(void);
String AddComment(CommentType entryType, const String& author, String AddComment(CommentType entryType, const String& author,
const String& text, double expireTime, const String& id = String(), const MessageOrigin& origin = MessageOrigin()); const String& text, double expireTime, const String& id = String(), const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void RemoveAllComments(void); void RemoveAllComments(void);
void RemoveCommentsByType(int type); void RemoveCommentsByType(int type);
static void RemoveComment(const String& id, const MessageOrigin& origin = MessageOrigin()); static void RemoveComment(const String& id, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
static String GetCommentIDFromLegacyID(int id); static String GetCommentIDFromLegacyID(int id);
static Checkable::Ptr GetOwnerByCommentID(const String& id); static Checkable::Ptr GetOwnerByCommentID(const String& id);
static Comment::Ptr GetCommentByID(const String& id); static Comment::Ptr GetCommentByID(const String& id);
/* Notifications */ /* Notifications */
bool GetEnableNotifications(void) const;
void SetEnableNotifications(bool enabled, const MessageOrigin& origin = MessageOrigin());
void SendNotifications(NotificationType type, const CheckResult::Ptr& cr, const String& author = "", const String& text = ""); void SendNotifications(NotificationType type, const CheckResult::Ptr& cr, const String& author = "", const String& text = "");
std::set<Notification::Ptr> GetNotifications(void) const; std::set<Notification::Ptr> GetNotifications(void) const;
void AddNotification(const Notification::Ptr& notification); void AddNotification(const Notification::Ptr& notification);
void RemoveNotification(const Notification::Ptr& notification); void RemoveNotification(const Notification::Ptr& notification);
void SetForceNextNotification(bool force, const MessageOrigin& origin = MessageOrigin());
bool GetForceNextNotification(void) const;
void ResetNotificationNumbers(void); void ResetNotificationNumbers(void);
/* Event Handler */ /* Event Handler */
@ -250,24 +190,13 @@ public:
bool useResolvedMacros = false); bool useResolvedMacros = false);
intrusive_ptr<EventCommand> GetEventCommand(void) const; 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());
/* Flapping Detection */ /* Flapping Detection */
double GetFlappingCurrent(void) const; double GetFlappingCurrent(void) const;
bool GetEnableFlapping(void) const;
void SetEnableFlapping(bool enabled, const MessageOrigin& origin = MessageOrigin());
bool IsFlapping(void) const; bool IsFlapping(void) const;
void UpdateFlappingStatus(bool stateChange); void UpdateFlappingStatus(bool stateChange);
/* Performance data */
bool GetEnablePerfdata(void) const;
void SetEnablePerfdata(bool enabled, const MessageOrigin& origin = MessageOrigin());
/* Dependencies */ /* Dependencies */
void AddDependency(const intrusive_ptr<Dependency>& dep); void AddDependency(const intrusive_ptr<Dependency>& dep);
void RemoveDependency(const intrusive_ptr<Dependency>& dep); void RemoveDependency(const intrusive_ptr<Dependency>& dep);
@ -277,7 +206,7 @@ public:
void RemoveReverseDependency(const intrusive_ptr<Dependency>& dep); void RemoveReverseDependency(const intrusive_ptr<Dependency>& dep);
std::set<intrusive_ptr<Dependency> > GetReverseDependencies(void) const; std::set<intrusive_ptr<Dependency> > GetReverseDependencies(void) const;
virtual void ValidateCheckIntervalRaw(double value, const ValidationUtils& utils) override; virtual void ValidateCheckInterval(double value, const ValidationUtils& utils) override;
protected: protected:
virtual void Start(void); virtual void Start(void);

View File

@ -21,6 +21,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "base/array.hpp" #include "base/array.hpp"
library icinga;
namespace icinga namespace icinga
{ {
@ -40,15 +42,15 @@ enum AcknowledgementType
abstract class Checkable : CustomVarObject abstract class Checkable : CustomVarObject
{ {
[config, protected, required] name(CheckCommand) check_command (CheckCommandRaw); [config, required] name(CheckCommand) check_command (CheckCommandRaw);
[config] int max_check_attempts (MaxCheckAttemptsRaw) { [config] int max_check_attempts {
default {{{ return 3; }}} default {{{ return 3; }}}
}; };
[config, protected] name(TimePeriod) check_period (CheckPeriodRaw); [config] name(TimePeriod) check_period (CheckPeriodRaw);
[config] double check_interval (CheckIntervalRaw) { [config] double check_interval {
default {{{ return 5 * 60; }}} default {{{ return 5 * 60; }}}
}; };
[config] double retry_interval (RetryIntervalRaw) { [config] double retry_interval {
default {{{ return 60; }}} default {{{ return 60; }}}
}; };
[config] name(EventCommand) event_command (EventCommandRaw); [config] name(EventCommand) event_command (EventCommandRaw);
@ -56,22 +58,22 @@ abstract class Checkable : CustomVarObject
[config] double flapping_threshold { [config] double flapping_threshold {
default {{{ return 30; }}} default {{{ return 30; }}}
}; };
[config] bool enable_active_checks (EnableActiveChecksRaw) { [config] bool enable_active_checks {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[config] bool enable_passive_checks (EnablePassiveChecksRaw) { [config] bool enable_passive_checks {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[config] bool enable_event_handler (EnableEventHandlerRaw) { [config] bool enable_event_handler {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[config] bool enable_notifications (EnableNotificationsRaw) { [config] bool enable_notifications {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[config] bool enable_flapping (EnableFlappingRaw) { [config] bool enable_flapping {
default {{{ return false; }}} default {{{ return false; }}}
}; };
[config] bool enable_perfdata (EnablePerfdataRaw) { [config] bool enable_perfdata {
default {{{ return true; }}} default {{{ return true; }}}
}; };
@ -81,7 +83,7 @@ abstract class Checkable : CustomVarObject
[config] String icon_image; [config] String icon_image;
[config] String icon_image_alt; [config] String icon_image_alt;
[state] double next_check (NextCheckRaw); [state] double next_check;
[state] int check_attempt { [state] int check_attempt {
default {{{ return 1; }}} default {{{ return 1; }}}
}; };
@ -116,7 +118,7 @@ abstract class Checkable : CustomVarObject
[state] double last_state_unknown; [state] double last_state_unknown;
[state] double last_state_unreachable; [state] double last_state_unreachable;
[state] bool last_in_downtime; [state] bool last_in_downtime;
[state] bool force_next_check (ForceNextCheckRaw); [state] bool force_next_check;
[state] int acknowledgement (AcknowledgementRaw) { [state] int acknowledgement (AcknowledgementRaw) {
default {{{ return AcknowledgementNone; }}} default {{{ return AcknowledgementNone; }}}
}; };
@ -127,22 +129,13 @@ abstract class Checkable : CustomVarObject
[state] Dictionary::Ptr downtimes { [state] Dictionary::Ptr downtimes {
default {{{ return new Dictionary(); }}} default {{{ return new Dictionary(); }}}
}; };
[state] bool force_next_notification (ForceNextNotificationRaw); [state] bool force_next_notification;
[state] int flapping_positive; [state] int flapping_positive;
[state] int flapping_negative; [state] int flapping_negative;
[state] double flapping_last_change; [state] double flapping_last_change;
[state] Value override_enable_notifications; [no_storage, protected] bool flapping {
[state] Value override_enable_active_checks; get {{{ return false; }}}
[state] Value override_enable_passive_checks; };
[state] Value override_enable_flapping;
[state] Value override_enable_perfdata;
[state] Value override_check_interval;
[state] Value override_retry_interval;
[state] Value override_enable_event_handler;
[state] Value override_event_command;
[state] Value override_check_command;
[state] Value override_max_check_attempts;
[state] Value override_check_period;
[config] name(Endpoint) command_endpoint (CommandEndpointRaw); [config] name(Endpoint) command_endpoint (CommandEndpointRaw);
}; };

View File

@ -19,6 +19,8 @@
#include "icinga/command.hpp" #include "icinga/command.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -17,6 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -30,20 +30,13 @@ REGISTER_TYPE(Command);
int Command::GetModifiedAttributes(void) const int Command::GetModifiedAttributes(void) const
{ {
int attrs = 0; //TODO-MA
return 0;
if (GetOverrideVars())
attrs |= ModAttrCustomVariable;
return attrs;
} }
void Command::SetModifiedAttributes(int flags, const MessageOrigin& origin) void Command::SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin)
{ {
if ((flags & ModAttrCustomVariable) == 0) { //TODO-MA
SetOverrideVars(Empty);
OnVarsChanged(this, GetVars(), origin);
}
} }
void Command::Validate(int types, const ValidationUtils& utils) void Command::Validate(int types, const ValidationUtils& utils)

View File

@ -42,7 +42,7 @@ public:
virtual void Validate(int types, const ValidationUtils& utils) override; virtual void Validate(int types, const ValidationUtils& utils) override;
int GetModifiedAttributes(void) const; int GetModifiedAttributes(void) const;
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin()); void SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
}; };
} }

View File

@ -20,6 +20,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "base/function.hpp" #include "base/function.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -17,6 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -30,45 +30,24 @@ using namespace icinga;
REGISTER_TYPE(CustomVarObject); REGISTER_TYPE(CustomVarObject);
boost::signals2::signal<void (const CustomVarObject::Ptr&, const Dictionary::Ptr& vars, const MessageOrigin&)> CustomVarObject::OnVarsChanged;
Dictionary::Ptr CustomVarObject::GetVars(void) const
{
if (GetOverrideVars())
return GetOverrideVars();
else
return GetVarsRaw();
}
void CustomVarObject::SetVars(const Dictionary::Ptr& vars, const MessageOrigin& origin)
{
SetOverrideVars(vars);
OnVarsChanged(this, vars, origin);
}
int CustomVarObject::GetModifiedAttributes(void) const int CustomVarObject::GetModifiedAttributes(void) const
{ {
/* does nothing by default */ //TODO-MA
return 0; return 0;
} }
void CustomVarObject::SetModifiedAttributes(int, const MessageOrigin&) void CustomVarObject::SetModifiedAttributes(int, const MessageOrigin::Ptr&)
{ {
/* does nothing by default */ //TODO-MA
} }
bool CustomVarObject::IsVarOverridden(const String& name) const bool CustomVarObject::IsVarOverridden(const String& name) const
{ {
Dictionary::Ptr vars_override = GetOverrideVars(); //TODO: implement
if (!vars_override)
return false; return false;
return vars_override->Contains(name);
} }
void CustomVarObject::ValidateVarsRaw(const Dictionary::Ptr& value, const ValidationUtils& utils) void CustomVarObject::ValidateVars(const Dictionary::Ptr& value, const ValidationUtils& utils)
{ {
if (!value) if (!value)
return; return;

View File

@ -59,15 +59,10 @@ class I2_ICINGA_API CustomVarObject : public ObjectImpl<CustomVarObject>
public: public:
DECLARE_OBJECT(CustomVarObject); DECLARE_OBJECT(CustomVarObject);
static boost::signals2::signal<void (const CustomVarObject::Ptr&, const Dictionary::Ptr& vars, const MessageOrigin&)> OnVarsChanged; virtual void ValidateVars(const Dictionary::Ptr& value, const ValidationUtils& utils) override;
virtual void ValidateVarsRaw(const Dictionary::Ptr& value, const ValidationUtils& utils) override;
Dictionary::Ptr GetVars(void) const;
void SetVars(const Dictionary::Ptr& vars, const MessageOrigin& origin = MessageOrigin());
virtual int GetModifiedAttributes(void) const; virtual int GetModifiedAttributes(void) const;
virtual void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin()); virtual void SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
bool IsVarOverridden(const String& name) const; bool IsVarOverridden(const String& name) const;
}; };

View File

@ -19,14 +19,14 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {
abstract class CustomVarObject : DynamicObject abstract class CustomVarObject : DynamicObject
{ {
[config] Dictionary::Ptr vars (VarsRaw); [config] Dictionary::Ptr vars;
[state] Dictionary::Ptr override_vars;
}; };
} }

View File

@ -20,6 +20,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "icinga/checkable.hpp" #include "icinga/checkable.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -17,6 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,9 @@
#include "icinga/command.hpp" #include "icinga/command.hpp"
library icinga;
namespace icinga namespace icinga
{ {

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,8 @@
#include "icinga/checkable.hpp" #include "icinga/checkable.hpp"
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -233,108 +233,60 @@ bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr
bool IcingaApplication::GetEnableNotifications(void) const bool IcingaApplication::GetEnableNotifications(void) const
{ {
if (!GetOverrideEnableNotifications().IsEmpty())
return GetOverrideEnableNotifications();
else
return ScriptGlobal::Get("EnableNotifications"); return ScriptGlobal::Get("EnableNotifications");
} }
void IcingaApplication::SetEnableNotifications(bool enabled) void IcingaApplication::SetEnableNotifications(bool enabled)
{ {
SetOverrideEnableNotifications(enabled); ScriptGlobal::Set("EnableNotifications", enabled);
}
void IcingaApplication::ClearEnableNotifications(void)
{
SetOverrideEnableNotifications(Empty);
} }
bool IcingaApplication::GetEnableEventHandlers(void) const bool IcingaApplication::GetEnableEventHandlers(void) const
{ {
if (!GetOverrideEnableEventHandlers().IsEmpty())
return GetOverrideEnableEventHandlers();
else
return ScriptGlobal::Get("EnableEventHandlers"); return ScriptGlobal::Get("EnableEventHandlers");
} }
void IcingaApplication::SetEnableEventHandlers(bool enabled) void IcingaApplication::SetEnableEventHandlers(bool enabled)
{ {
SetOverrideEnableEventHandlers(enabled); ScriptGlobal::Set("EnableEventHandlers", enabled);
}
void IcingaApplication::ClearEnableEventHandlers(void)
{
SetOverrideEnableEventHandlers(Empty);
} }
bool IcingaApplication::GetEnableFlapping(void) const bool IcingaApplication::GetEnableFlapping(void) const
{ {
if (!GetOverrideEnableFlapping().IsEmpty())
return GetOverrideEnableFlapping();
else
return ScriptGlobal::Get("EnableFlapping"); return ScriptGlobal::Get("EnableFlapping");
} }
void IcingaApplication::SetEnableFlapping(bool enabled) void IcingaApplication::SetEnableFlapping(bool enabled)
{ {
SetOverrideEnableFlapping(enabled); ScriptGlobal::Set("EnableFlapping", enabled);
}
void IcingaApplication::ClearEnableFlapping(void)
{
SetOverrideEnableFlapping(Empty);
} }
bool IcingaApplication::GetEnableHostChecks(void) const bool IcingaApplication::GetEnableHostChecks(void) const
{ {
if (!GetOverrideEnableHostChecks().IsEmpty())
return GetOverrideEnableHostChecks();
else
return ScriptGlobal::Get("EnableHostChecks"); return ScriptGlobal::Get("EnableHostChecks");
} }
void IcingaApplication::SetEnableHostChecks(bool enabled) void IcingaApplication::SetEnableHostChecks(bool enabled)
{ {
SetOverrideEnableHostChecks(enabled); ScriptGlobal::Set("EnableHostChecks", enabled);
}
void IcingaApplication::ClearEnableHostChecks(void)
{
SetOverrideEnableHostChecks(Empty);
} }
bool IcingaApplication::GetEnableServiceChecks(void) const bool IcingaApplication::GetEnableServiceChecks(void) const
{ {
if (!GetOverrideEnableServiceChecks().IsEmpty())
return GetOverrideEnableServiceChecks();
else
return ScriptGlobal::Get("EnableServiceChecks"); return ScriptGlobal::Get("EnableServiceChecks");
} }
void IcingaApplication::SetEnableServiceChecks(bool enabled) void IcingaApplication::SetEnableServiceChecks(bool enabled)
{ {
SetOverrideEnableServiceChecks(enabled); ScriptGlobal::Set("EnableServiceChecks", enabled);
}
void IcingaApplication::ClearEnableServiceChecks(void)
{
SetOverrideEnableServiceChecks(Empty);
} }
bool IcingaApplication::GetEnablePerfdata(void) const bool IcingaApplication::GetEnablePerfdata(void) const
{ {
if (!GetOverrideEnablePerfdata().IsEmpty())
return GetOverrideEnablePerfdata();
else
return ScriptGlobal::Get("EnablePerfdata"); return ScriptGlobal::Get("EnablePerfdata");
} }
void IcingaApplication::SetEnablePerfdata(bool enabled) void IcingaApplication::SetEnablePerfdata(bool enabled)
{ {
SetOverrideEnablePerfdata(enabled); ScriptGlobal::Set("EnablePerfdata", enabled);
}
void IcingaApplication::ClearEnablePerfdata(void)
{
SetOverrideEnablePerfdata(Empty);
} }

View File

@ -19,17 +19,13 @@
#include "base/application.hpp" #include "base/application.hpp"
library icinga;
namespace icinga namespace icinga
{ {
class IcingaApplication : Application class IcingaApplication : Application
{ {
[state, protected] Value override_enable_notifications;
[state, protected] Value override_enable_event_handlers;
[state, protected] Value override_enable_flapping;
[state, protected] Value override_enable_host_checks;
[state, protected] Value override_enable_service_checks;
[state, protected] Value override_enable_perfdata;
}; };
} }

View File

@ -20,6 +20,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -35,7 +35,7 @@ using namespace icinga;
REGISTER_TYPE(Notification); REGISTER_TYPE(Notification);
INITIALIZE_ONCE(&Notification::StaticInitialize); INITIALIZE_ONCE(&Notification::StaticInitialize);
boost::signals2::signal<void (const Notification::Ptr&, double, const MessageOrigin&)> Notification::OnNextNotificationChanged; boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNextNotificationChanged;
String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
{ {
@ -174,22 +174,6 @@ TimePeriod::Ptr Notification::GetPeriod(void) const
return TimePeriod::GetByName(GetPeriodRaw()); return TimePeriod::GetByName(GetPeriodRaw());
} }
double Notification::GetNextNotification(void) const
{
return GetNextNotificationRaw();
}
/**
* Sets the timestamp when the next periodical notification should be sent.
* This does not affect notifications that are sent for state changes.
*/
void Notification::SetNextNotification(double time, const MessageOrigin& origin)
{
SetNextNotificationRaw(time);
OnNextNotificationChanged(this, time, origin);
}
void Notification::UpdateNotificationNumber(void) void Notification::UpdateNotificationNumber(void)
{ {
SetNotificationNumber(GetNotificationNumber() + 1); SetNotificationNumber(GetNotificationNumber() + 1);

View File

@ -91,9 +91,6 @@ public:
std::set<User::Ptr> GetUsers(void) const; std::set<User::Ptr> GetUsers(void) const;
std::set<UserGroup::Ptr> GetUserGroups(void) const; std::set<UserGroup::Ptr> GetUserGroups(void) const;
double GetNextNotification(void) const;
void SetNextNotification(double time, const MessageOrigin& origin = MessageOrigin());
void UpdateNotificationNumber(void); void UpdateNotificationNumber(void);
void ResetNotificationNumber(void); void ResetNotificationNumber(void);
@ -106,7 +103,7 @@ public:
static String NotificationTypeToString(NotificationType type); static String NotificationTypeToString(NotificationType type);
static String NotificationFilterToString(int filter); static String NotificationFilterToString(int filter);
static boost::signals2::signal<void (const Notification::Ptr&, double, const MessageOrigin&)> OnNextNotificationChanged; static boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> OnNextNotificationChanged;
static void RegisterApplyRuleHandler(void); static void RegisterApplyRuleHandler(void);

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {
@ -55,7 +57,7 @@ class Notification : CustomVarObject < NotificationNameComposer
}; };
[state] double last_notification; [state] double last_notification;
[state, set_protected] double next_notification (NextNotificationRaw); [state] double next_notification;
[state, set_protected] Value notification_number; [state, set_protected] Value notification_number;
[state] double last_problem_notification; [state] double last_problem_notification;

View File

@ -19,6 +19,8 @@
#include "icinga/command.hpp" #include "icinga/command.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -39,14 +39,14 @@ PerfdataValue::PerfdataValue(String label, double value, bool counter,
const String& unit, const Value& warn, const Value& crit, const Value& min, const String& unit, const Value& warn, const Value& crit, const Value& min,
const Value& max) const Value& max)
{ {
SetLabel(label); SetLabel(label, true);
SetValue(value); SetValue(value, true);
SetCounter(counter); SetCounter(counter, true);
SetUnit(unit); SetUnit(unit, true);
SetWarn(warn); SetWarn(warn, true);
SetCrit(crit); SetCrit(crit, true);
SetMin(min); SetMin(min, true);
SetMax(max); SetMax(max, true);
} }
PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata) PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -22,6 +22,8 @@
#include "icinga/icingaapplication.hpp" #include "icinga/icingaapplication.hpp"
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -20,6 +20,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "base/function.hpp" #include "base/function.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -30,8 +30,6 @@ using namespace icinga;
REGISTER_TYPE(User); REGISTER_TYPE(User);
boost::signals2::signal<void (const User::Ptr&, bool, const MessageOrigin&)> User::OnEnableNotificationsChanged;
void User::OnConfigLoaded(void) void User::OnConfigLoaded(void)
{ {
DynamicObject::OnConfigLoaded(); DynamicObject::OnConfigLoaded();
@ -124,34 +122,12 @@ void User::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils)
int User::GetModifiedAttributes(void) const int User::GetModifiedAttributes(void) const
{ {
int attrs = 0; //TODO-MA
return 0;
if (GetOverrideVars())
attrs |= ModAttrCustomVariable;
return attrs;
} }
void User::SetModifiedAttributes(int flags, const MessageOrigin& origin) void User::SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin)
{ {
if ((flags & ModAttrCustomVariable) == 0) { //TODO-MA
SetOverrideVars(Empty); return;
OnVarsChanged(this, GetVars(), origin);
} }
}
bool User::GetEnableNotifications(void) const
{
if (!GetOverrideEnableNotifications().IsEmpty())
return GetOverrideEnableNotifications();
else
return GetEnableNotificationsRaw();
}
void User::SetEnableNotifications(bool enabled, const MessageOrigin& origin)
{
SetOverrideEnableNotifications(enabled);
OnEnableNotificationsChanged(this, enabled, origin);
}

View File

@ -47,13 +47,8 @@ public:
virtual void ValidateStates(const Array::Ptr& value, const ValidationUtils& utils) override; virtual void ValidateStates(const Array::Ptr& value, const ValidationUtils& utils) override;
virtual void ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils) override; virtual void ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils) override;
bool GetEnableNotifications(void) const;
void SetEnableNotifications(bool enabled, const MessageOrigin& origin = MessageOrigin());
int GetModifiedAttributes(void) const; int GetModifiedAttributes(void) const;
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin()); void SetModifiedAttributes(int flags, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
static boost::signals2::signal<void (const User::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged;
protected: protected:
virtual void Stop(void); virtual void Stop(void);

View File

@ -20,6 +20,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "base/array.hpp" #include "base/array.hpp"
library icinga;
namespace icinga namespace icinga
{ {
@ -45,11 +47,10 @@ class User : CustomVarObject
[config] String email; [config] String email;
[config] String pager; [config] String pager;
[config] bool enable_notifications (EnableNotificationsRaw) { [config] bool enable_notifications {
default {{{ return true; }}} default {{{ return true; }}}
}; };
[state] Value override_enable_notifications;
[state] double last_notification; [state] double last_notification;
}; };

View File

@ -19,6 +19,8 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
library icinga;
namespace icinga namespace icinga
{ {

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library livestatus;
namespace icinga namespace icinga
{ {

View File

@ -32,6 +32,7 @@ target_link_libraries(notification ${Boost_LIBRARIES} base config icinga)
set_target_properties ( set_target_properties (
notification PROPERTIES notification PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_NOTIFICATION_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library notification;
namespace icinga namespace icinga
{ {

View File

@ -35,6 +35,7 @@ target_link_libraries(perfdata ${Boost_LIBRARIES} base config icinga)
set_target_properties ( set_target_properties (
perfdata PROPERTIES perfdata PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
DEFINE_SYMBOL I2_PERFDATA_BUILD
FOLDER Components FOLDER Components
) )

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library perfdata;
namespace icinga namespace icinga
{ {

View File

@ -19,6 +19,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library perfdata;
namespace icinga namespace icinga
{ {

View File

@ -1,5 +1,26 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2015 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/dynamicobject.hpp" #include "base/dynamicobject.hpp"
library perfdata;
namespace icinga namespace icinga
{ {

View File

@ -20,6 +20,8 @@
#include "base/dynamicobject.hpp" #include "base/dynamicobject.hpp"
#include "base/application.hpp" #include "base/application.hpp"
library perfdata;
namespace icinga namespace icinga
{ {

View File

@ -26,7 +26,7 @@ ApiFunction::ApiFunction(const Callback& function)
: m_Callback(function) : m_Callback(function)
{ } { }
Value ApiFunction::Invoke(const MessageOrigin& origin, const Dictionary::Ptr& arguments) Value ApiFunction::Invoke(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& arguments)
{ {
return m_Callback(origin, arguments); return m_Callback(origin, arguments);
} }

View File

@ -41,11 +41,11 @@ class I2_REMOTE_API ApiFunction : public Object
public: public:
DECLARE_PTR_TYPEDEFS(ApiFunction); DECLARE_PTR_TYPEDEFS(ApiFunction);
typedef boost::function<Value(const MessageOrigin& origin, const Dictionary::Ptr&)> Callback; typedef boost::function<Value(const MessageOrigin::Ptr& origin, const Dictionary::Ptr&)> Callback;
ApiFunction(const Callback& function); ApiFunction(const Callback& function);
Value Invoke(const MessageOrigin& origin, const Dictionary::Ptr& arguments); Value Invoke(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& arguments);
static ApiFunction::Ptr GetByName(const String& name); static ApiFunction::Ptr GetByName(const String& name);
static void Register(const String& name, const ApiFunction::Ptr& function); static void Register(const String& name, const ApiFunction::Ptr& function);

View File

@ -214,9 +214,9 @@ void ApiListener::SendConfigUpdate(const JsonRpcConnection::Ptr& aclient)
aclient->SendMessage(message); aclient->SendMessage(message);
} }
Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictionary::Ptr& params) Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
{ {
if (!origin.FromClient->GetEndpoint() || (origin.FromZone && !Zone::GetLocalZone()->IsChildOf(origin.FromZone))) if (!origin->FromClient->GetEndpoint() || (origin->FromZone && !Zone::GetLocalZone()->IsChildOf(origin->FromZone)))
return Empty; return Empty;
ApiListener::Ptr listener = ApiListener::GetInstance(); ApiListener::Ptr listener = ApiListener::GetInstance();

View File

@ -508,7 +508,7 @@ void ApiListener::ApiTimerHandler(void)
<< "Connected endpoints: " << Utility::NaturalJoin(names); << "Connected endpoints: " << Utility::NaturalJoin(names);
} }
void ApiListener::RelayMessage(const MessageOrigin& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log) void ApiListener::RelayMessage(const MessageOrigin::Ptr& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log)
{ {
m_RelayQueue.Enqueue(boost::bind(&ApiListener::SyncRelayMessage, this, origin, secobj, message, log)); m_RelayQueue.Enqueue(boost::bind(&ApiListener::SyncRelayMessage, this, origin, secobj, message, log));
} }
@ -557,7 +557,7 @@ void ApiListener::SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionar
} }
void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log) void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log)
{ {
double ts = Utility::GetTime(); double ts = Utility::GetTime();
message->Set("ts", ts); message->Set("ts", ts);
@ -568,8 +568,8 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
if (log) if (log)
PersistMessage(message, secobj); PersistMessage(message, secobj);
if (origin.FromZone) if (origin && origin->FromZone)
message->Set("originZone", origin.FromZone->GetName()); message->Set("originZone", origin->FromZone->GetName());
bool is_master = IsMaster(); bool is_master = IsMaster();
Endpoint::Ptr master = GetMaster(); Endpoint::Ptr master = GetMaster();
@ -592,13 +592,13 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
} }
/* don't relay messages back to the endpoint which we got the message from */ /* don't relay messages back to the endpoint which we got the message from */
if (origin.FromClient && endpoint == origin.FromClient->GetEndpoint()) { if (origin && origin->FromClient && endpoint == origin->FromClient->GetEndpoint()) {
skippedEndpoints.push_back(endpoint); skippedEndpoints.push_back(endpoint);
continue; continue;
} }
/* don't relay messages back to the zone which we got the message from */ /* don't relay messages back to the zone which we got the message from */
if (origin.FromZone && target_zone == origin.FromZone) { if (origin && origin->FromZone && target_zone == origin->FromZone) {
skippedEndpoints.push_back(endpoint); skippedEndpoints.push_back(endpoint);
continue; continue;
} }
@ -926,7 +926,7 @@ std::set<HttpConnection::Ptr> ApiListener::GetHttpClients(void) const
return m_HttpClients; return m_HttpClients;
} }
Value ApiListener::HelloAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params) Value ApiListener::HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
{ {
return Empty; return Empty;
} }

View File

@ -60,7 +60,7 @@ public:
static String GetApiDir(void); static String GetApiDir(void);
void SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionary::Ptr& message); void SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionary::Ptr& message);
void RelayMessage(const MessageOrigin& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log); void RelayMessage(const MessageOrigin::Ptr& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log);
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
std::pair<Dictionary::Ptr, Dictionary::Ptr> GetStatus(void); std::pair<Dictionary::Ptr, Dictionary::Ptr> GetStatus(void);
@ -73,9 +73,9 @@ public:
void RemoveHttpClient(const HttpConnection::Ptr& aclient); void RemoveHttpClient(const HttpConnection::Ptr& aclient);
std::set<HttpConnection::Ptr> GetHttpClients(void) const; std::set<HttpConnection::Ptr> GetHttpClients(void) const;
static Value ConfigUpdateHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static Value HelloAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
protected: protected:
virtual void OnConfigLoaded(void); virtual void OnConfigLoaded(void);
virtual void OnAllConfigLoaded(void); virtual void OnAllConfigLoaded(void);
@ -103,7 +103,7 @@ private:
Stream::Ptr m_LogFile; Stream::Ptr m_LogFile;
size_t m_LogMessageCount; size_t m_LogMessageCount;
void SyncRelayMessage(const MessageOrigin& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log); void SyncRelayMessage(const MessageOrigin::Ptr& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log);
void PersistMessage(const Dictionary::Ptr& message, const DynamicObject::Ptr& secobj); void PersistMessage(const Dictionary::Ptr& message, const DynamicObject::Ptr& secobj);
void OpenLogFile(void); void OpenLogFile(void);

Some files were not shown because too many files have changed in this diff Show More