Merge branch 'feature/mod-attr-cluster-5219'

fixes #5219
This commit is contained in:
Michael Friedrich 2014-08-26 17:16:11 +02:00
commit 520884f3f7
10 changed files with 596 additions and 22 deletions

View File

@ -44,6 +44,15 @@ REGISTER_APIFUNCTION(SetEnableActiveChecks, event, &ApiEvents::EnableActiveCheck
REGISTER_APIFUNCTION(SetEnablePassiveChecks, event, &ApiEvents::EnablePassiveChecksChangedAPIHandler); REGISTER_APIFUNCTION(SetEnablePassiveChecks, event, &ApiEvents::EnablePassiveChecksChangedAPIHandler);
REGISTER_APIFUNCTION(SetEnableNotifications, event, &ApiEvents::EnableNotificationsChangedAPIHandler); REGISTER_APIFUNCTION(SetEnableNotifications, event, &ApiEvents::EnableNotificationsChangedAPIHandler);
REGISTER_APIFUNCTION(SetEnableFlapping, event, &ApiEvents::EnableFlappingChangedAPIHandler); REGISTER_APIFUNCTION(SetEnableFlapping, event, &ApiEvents::EnableFlappingChangedAPIHandler);
REGISTER_APIFUNCTION(SetEnableEventHandler, event, &ApiEvents::EnableEventHandlerChangedAPIHandler);
REGISTER_APIFUNCTION(SetEnablePerfdata, event, &ApiEvents::EnablePerfdataChangedAPIHandler);
REGISTER_APIFUNCTION(SetCheckInterval, event, &ApiEvents::CheckIntervalChangedAPIHandler);
REGISTER_APIFUNCTION(SetRetryInterval, event, &ApiEvents::RetryIntervalChangedAPIHandler);
REGISTER_APIFUNCTION(SetMaxCheckAttempts, event, &ApiEvents::MaxCheckAttemptsChangedAPIHandler);
REGISTER_APIFUNCTION(SetEventCommand, event, &ApiEvents::EventCommandChangedAPIHandler);
REGISTER_APIFUNCTION(SetCheckCommand, event, &ApiEvents::CheckCommandChangedAPIHandler);
REGISTER_APIFUNCTION(SetCheckPeriod, event, &ApiEvents::CheckPeriodChangedAPIHandler);
REGISTER_APIFUNCTION(SetVars, event, &ApiEvents::VarsChangedAPIHandler);
REGISTER_APIFUNCTION(AddComment, event, &ApiEvents::CommentAddedAPIHandler); REGISTER_APIFUNCTION(AddComment, event, &ApiEvents::CommentAddedAPIHandler);
REGISTER_APIFUNCTION(RemoveComment, event, &ApiEvents::CommentRemovedAPIHandler); REGISTER_APIFUNCTION(RemoveComment, event, &ApiEvents::CommentRemovedAPIHandler);
REGISTER_APIFUNCTION(AddDowntime, event, &ApiEvents::DowntimeAddedAPIHandler); REGISTER_APIFUNCTION(AddDowntime, event, &ApiEvents::DowntimeAddedAPIHandler);
@ -65,6 +74,15 @@ void ApiEvents::StaticInitialize(void)
Checkable::OnEnablePassiveChecksChanged.connect(&ApiEvents::EnablePassiveChecksChangedHandler); Checkable::OnEnablePassiveChecksChanged.connect(&ApiEvents::EnablePassiveChecksChangedHandler);
Checkable::OnEnableNotificationsChanged.connect(&ApiEvents::EnableNotificationsChangedHandler); Checkable::OnEnableNotificationsChanged.connect(&ApiEvents::EnableNotificationsChangedHandler);
Checkable::OnEnableFlappingChanged.connect(&ApiEvents::EnableFlappingChangedHandler); Checkable::OnEnableFlappingChanged.connect(&ApiEvents::EnableFlappingChangedHandler);
Checkable::OnEnableEventHandlerChanged.connect(&ApiEvents::EnableEventHandlerChangedHandler);
Checkable::OnEnablePerfdataChanged.connect(&ApiEvents::EnablePerfdataChangedHandler);
Checkable::OnCheckIntervalChanged.connect(&ApiEvents::CheckIntervalChangedHandler);
Checkable::OnRetryIntervalChanged.connect(&ApiEvents::RetryIntervalChangedHandler);
Checkable::OnMaxCheckAttemptsChanged.connect(&ApiEvents::MaxCheckAttemptsChangedHandler);
Checkable::OnEventCommandChanged.connect(&ApiEvents::EventCommandChangedHandler);
Checkable::OnCheckCommandChanged.connect(&ApiEvents::CheckCommandChangedHandler);
Checkable::OnCheckPeriodChanged.connect(&ApiEvents::CheckPeriodChangedHandler);
Checkable::OnVarsChanged.connect(&ApiEvents::VarsChangedHandler);
Checkable::OnCommentAdded.connect(&ApiEvents::CommentAddedHandler); Checkable::OnCommentAdded.connect(&ApiEvents::CommentAddedHandler);
Checkable::OnCommentRemoved.connect(&ApiEvents::CommentRemovedHandler); Checkable::OnCommentRemoved.connect(&ApiEvents::CommentRemovedHandler);
Checkable::OnDowntimeAdded.connect(&ApiEvents::DowntimeAddedHandler); Checkable::OnDowntimeAdded.connect(&ApiEvents::DowntimeAddedHandler);
@ -545,6 +563,504 @@ Value ApiEvents::EnableFlappingChangedAPIHandler(const MessageOrigin& origin, co
return Empty; return Empty;
} }
void ApiEvents::EnableEventHandlerChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnableEventHandler");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::EnableEventHandlerChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetEnableEventHandler(params->Get("enabled"), origin);
return Empty;
}
void ApiEvents::EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("enabled", enabled);
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEnablePerfdata");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::EnablePerfdataChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetEnablePerfdata(params->Get("enabled"), origin);
return Empty;
}
void ApiEvents::CheckIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("interval", interval);
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckInterval");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::CheckIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetCheckInterval(params->Get("interval"), origin);
return Empty;
}
void ApiEvents::RetryIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("interval", interval);
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetRetryInterval");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::RetryIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetRetryInterval(params->Get("interval"), origin);
return Empty;
}
void ApiEvents::MaxCheckAttemptsChangedHandler(const Checkable::Ptr& checkable, int attempts, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("attempts", attempts);
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetMaxCheckAttempts");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::MaxCheckAttemptsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetMaxCheckAttempts(params->Get("attempts"), origin);
return Empty;
}
void ApiEvents::EventCommandChangedHandler(const Checkable::Ptr& checkable, const EventCommand::Ptr& command, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("command", command->GetName());
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetEventCommand");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::EventCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
EventCommand::Ptr command = EventCommand::GetByName(params->Get("command"));
if (!command)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
checkable->SetEventCommand(command, origin);
return Empty;
}
void ApiEvents::CheckCommandChangedHandler(const Checkable::Ptr& checkable, const CheckCommand::Ptr& command, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("command", command->GetName());
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckCommand");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::CheckCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
CheckCommand::Ptr command = CheckCommand::GetByName(params->Get("command"));
if (!command)
return Empty;
checkable->SetCheckCommand(command, origin);
return Empty;
}
void ApiEvents::CheckPeriodChangedHandler(const Checkable::Ptr& checkable, const TimePeriod::Ptr& timeperiod, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("host", host->GetName());
if (service)
params->Set("service", service->GetShortName());
params->Set("timeperiod", timeperiod->GetName());
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetCheckPeriod");
message->Set("params", params);
listener->RelayMessage(origin, checkable, message, true);
}
Value ApiEvents::CheckPeriodChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
Host::Ptr host = FindHostByVirtualName(params->Get("host"), origin);
if (!host)
return Empty;
Checkable::Ptr checkable;
if (params->Contains("service"))
checkable = host->GetServiceByShortName(params->Get("service"));
else
checkable = host;
if (!checkable)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
return Empty;
TimePeriod::Ptr timeperiod = TimePeriod::GetByName(params->Get("timeperiod"));
if (!timeperiod)
return Empty;
checkable->SetCheckPeriod(timeperiod, origin);
return Empty;
}
void ApiEvents::VarsChangedHandler(const CustomVarObject::Ptr& object, const Dictionary::Ptr& vars, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return;
Dictionary::Ptr params = make_shared<Dictionary>();
params->Set("object", object->GetName());
params->Set("vars", Serialize(vars));
Dictionary::Ptr message = make_shared<Dictionary>();
message->Set("jsonrpc", "2.0");
message->Set("method", "event::SetVars");
message->Set("params", params);
listener->RelayMessage(origin, object, message, true);
}
Value ApiEvents::VarsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
if (!params)
return Empty;
String objectName = params->Get("object");
if (objectName.IsEmpty())
return Empty;
/* ugly, but there is no other way currently */
CustomVarObject::Ptr object = Host::GetByName(objectName);
if (!object)
object = Service::GetByName(objectName);
if (!object)
object = User::GetByName(objectName);
if (!object)
object = Service::GetByName(objectName);
if (!object)
object = EventCommand::GetByName(objectName);
if (!object)
object = CheckCommand::GetByName(objectName);
if (!object)
object = NotificationCommand::GetByName(objectName);
if (!object)
return Empty;
if (origin.FromZone && !origin.FromZone->CanAccessObject(object))
return Empty;
Dictionary::Ptr vars = Deserialize(params->Get("vars"), true);
if (!vars)
return Empty;
object->SetVars(vars, origin);
return Empty;
}
void ApiEvents::CommentAddedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin& origin) void ApiEvents::CommentAddedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const MessageOrigin& origin)
{ {
ApiListener::Ptr listener = ApiListener::GetInstance(); ApiListener::Ptr listener = ApiListener::GetInstance();

View File

@ -22,6 +22,9 @@
#include "icinga/checkable.hpp" #include "icinga/checkable.hpp"
#include "icinga/host.hpp" #include "icinga/host.hpp"
#include "icinga/checkcommand.hpp"
#include "icinga/eventcommand.hpp"
#include "icinga/notificationcommand.hpp"
namespace icinga namespace icinga
{ {
@ -61,6 +64,33 @@ public:
static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin); static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin);
static Value EnableFlappingChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value EnableFlappingChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void EnableEventHandlerChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin);
static Value EnableEventHandlerChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled, const MessageOrigin& origin);
static Value EnablePerfdataChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void CheckIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin);
static Value CheckIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void RetryIntervalChangedHandler(const Checkable::Ptr& checkable, double interval, const MessageOrigin& origin);
static Value RetryIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void MaxCheckAttemptsChangedHandler(const Checkable::Ptr& checkable, int attempts, const MessageOrigin& origin);
static Value MaxCheckAttemptsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void EventCommandChangedHandler(const Checkable::Ptr& checkable, const EventCommand::Ptr& command, const MessageOrigin& origin);
static Value EventCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void CheckCommandChangedHandler(const Checkable::Ptr& checkable, const CheckCommand::Ptr& command, const MessageOrigin& origin);
static Value CheckCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void CheckPeriodChangedHandler(const Checkable::Ptr& checkable, const TimePeriod::Ptr& timeperiod, const MessageOrigin& origin);
static Value CheckPeriodChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void VarsChangedHandler(const CustomVarObject::Ptr& object, const Dictionary::Ptr& vars, const MessageOrigin& origin);
static Value VarsChangedAPIHandler(const MessageOrigin& 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& origin);
static Value CommentAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); static Value CommentAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);

View File

@ -43,6 +43,11 @@ boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePassiveChecksChanged; 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::OnEnableNotificationsChanged;
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnableFlappingChanged; 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; boost::signals2::signal<void (const Checkable::Ptr&, FlappingState)> Checkable::OnFlappingChanged;
CheckCommand::Ptr Checkable::GetCheckCommand(void) const CheckCommand::Ptr Checkable::GetCheckCommand(void) const
@ -57,9 +62,11 @@ CheckCommand::Ptr Checkable::GetCheckCommand(void) const
return CheckCommand::GetByName(command); return CheckCommand::GetByName(command);
} }
void Checkable::SetCheckCommand(const CheckCommand::Ptr& command) void Checkable::SetCheckCommand(const CheckCommand::Ptr& command, const MessageOrigin& origin)
{ {
SetOverrideCheckCommand(command->GetName()); SetOverrideCheckCommand(command->GetName());
OnCheckCommandChanged(GetSelf(), command, origin);
} }
TimePeriod::Ptr Checkable::GetCheckPeriod(void) const TimePeriod::Ptr Checkable::GetCheckPeriod(void) const
@ -74,9 +81,11 @@ TimePeriod::Ptr Checkable::GetCheckPeriod(void) const
return TimePeriod::GetByName(tp); return TimePeriod::GetByName(tp);
} }
void Checkable::SetCheckPeriod(const TimePeriod::Ptr& tp) void Checkable::SetCheckPeriod(const TimePeriod::Ptr& tp, const MessageOrigin& origin)
{ {
SetOverrideCheckPeriod(tp->GetName()); SetOverrideCheckPeriod(tp->GetName());
OnCheckPeriodChanged(GetSelf(), tp, origin);
} }
double Checkable::GetCheckInterval(void) const double Checkable::GetCheckInterval(void) const
@ -87,9 +96,11 @@ double Checkable::GetCheckInterval(void) const
return GetCheckIntervalRaw(); return GetCheckIntervalRaw();
} }
void Checkable::SetCheckInterval(double interval) void Checkable::SetCheckInterval(double interval, const MessageOrigin& origin)
{ {
SetOverrideCheckInterval(interval); SetOverrideCheckInterval(interval);
OnCheckIntervalChanged(GetSelf(), interval, origin);
} }
double Checkable::GetRetryInterval(void) const double Checkable::GetRetryInterval(void) const
@ -100,9 +111,11 @@ double Checkable::GetRetryInterval(void) const
return GetRetryIntervalRaw(); return GetRetryIntervalRaw();
} }
void Checkable::SetRetryInterval(double interval) void Checkable::SetRetryInterval(double interval, const MessageOrigin& origin)
{ {
SetOverrideRetryInterval(interval); SetOverrideRetryInterval(interval);
OnRetryIntervalChanged(GetSelf(), interval, origin);
} }
void Checkable::SetSchedulingOffset(long offset) void Checkable::SetSchedulingOffset(long offset)
@ -211,9 +224,11 @@ int Checkable::GetMaxCheckAttempts(void) const
return GetMaxCheckAttemptsRaw(); return GetMaxCheckAttemptsRaw();
} }
void Checkable::SetMaxCheckAttempts(int attempts) void Checkable::SetMaxCheckAttempts(int attempts, const MessageOrigin& origin)
{ {
SetOverrideMaxCheckAttempts(attempts); SetOverrideMaxCheckAttempts(attempts);
OnMaxCheckAttemptsChanged(GetSelf(), attempts, origin);
} }
void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin) void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin)

View File

@ -26,6 +26,8 @@
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 bool Checkable::GetEnableEventHandler(void) const
{ {
@ -35,9 +37,11 @@ bool Checkable::GetEnableEventHandler(void) const
return GetEnableEventHandlerRaw(); return GetEnableEventHandlerRaw();
} }
void Checkable::SetEnableEventHandler(bool enabled) void Checkable::SetEnableEventHandler(bool enabled, const MessageOrigin& origin)
{ {
SetOverrideEnableEventHandler(enabled); SetOverrideEnableEventHandler(enabled);
OnEnableEventHandlerChanged(GetSelf(), enabled, origin);
} }
EventCommand::Ptr Checkable::GetEventCommand(void) const EventCommand::Ptr Checkable::GetEventCommand(void) const
@ -52,9 +56,11 @@ EventCommand::Ptr Checkable::GetEventCommand(void) const
return EventCommand::GetByName(command); return EventCommand::GetByName(command);
} }
void Checkable::SetEventCommand(const EventCommand::Ptr& command) void Checkable::SetEventCommand(const EventCommand::Ptr& command, const MessageOrigin& origin)
{ {
SetOverrideEventCommand(command->GetName()); SetOverrideEventCommand(command->GetName());
OnEventCommandChanged(GetSelf(), command, origin);
} }
void Checkable::ExecuteEventHandler(void) void Checkable::ExecuteEventHandler(void)

View File

@ -255,6 +255,6 @@ void Checkable::SetModifiedAttributes(int flags, const MessageOrigin& origin)
if ((flags & ModAttrCustomVariable) == 0) { if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty); SetOverrideVars(Empty);
OnVarsChanged(GetSelf(), origin); OnVarsChanged(GetSelf(), GetVars(), origin);
} }
} }

View File

@ -98,19 +98,19 @@ public:
/* Checks */ /* Checks */
shared_ptr<CheckCommand> GetCheckCommand(void) const; shared_ptr<CheckCommand> GetCheckCommand(void) const;
void SetCheckCommand(const shared_ptr<CheckCommand>& command); void SetCheckCommand(const shared_ptr<CheckCommand>& command, const MessageOrigin& origin = MessageOrigin());
TimePeriod::Ptr GetCheckPeriod(void) const; TimePeriod::Ptr GetCheckPeriod(void) const;
void SetCheckPeriod(const TimePeriod::Ptr& tp); void SetCheckPeriod(const TimePeriod::Ptr& tp, const MessageOrigin& origin = MessageOrigin());
double GetCheckInterval(void) const; double GetCheckInterval(void) const;
void SetCheckInterval(double interval); void SetCheckInterval(double interval, const MessageOrigin& origin = MessageOrigin());
double GetRetryInterval(void) const; double GetRetryInterval(void) const;
void SetRetryInterval(double interval); void SetRetryInterval(double interval, const MessageOrigin& origin = MessageOrigin());
int GetMaxCheckAttempts(void) const; int GetMaxCheckAttempts(void) const;
void SetMaxCheckAttempts(int attempts); void SetMaxCheckAttempts(int attempts, const MessageOrigin& origin = MessageOrigin());
long GetSchedulingOffset(void); long GetSchedulingOffset(void);
void SetSchedulingOffset(long offset); void SetSchedulingOffset(long offset);
@ -153,6 +153,15 @@ public:
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged; 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&)> OnEnableFlappingChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePerfdataChanged; 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 shared_ptr<EventCommand>&, const MessageOrigin&)> OnEventCommandChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const shared_ptr<CheckCommand>&, const MessageOrigin&)> OnCheckCommandChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const 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&, 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&, StateType, const MessageOrigin&)> OnStateChange;
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
@ -235,10 +244,10 @@ public:
void ExecuteEventHandler(void); void ExecuteEventHandler(void);
shared_ptr<EventCommand> GetEventCommand(void) const; shared_ptr<EventCommand> GetEventCommand(void) const;
void SetEventCommand(const shared_ptr<EventCommand>& command); void SetEventCommand(const shared_ptr<EventCommand>& command, const MessageOrigin& origin = MessageOrigin());
bool GetEnableEventHandler(void) const; bool GetEnableEventHandler(void) const;
void SetEnableEventHandler(bool enabled); void SetEnableEventHandler(bool enabled, const MessageOrigin& origin = MessageOrigin());
/* Flapping Detection */ /* Flapping Detection */
double GetFlappingCurrent(void) const; double GetFlappingCurrent(void) const;

View File

@ -40,7 +40,7 @@ void Command::SetModifiedAttributes(int flags, const MessageOrigin& origin)
{ {
if ((flags & ModAttrCustomVariable) == 0) { if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty); SetOverrideVars(Empty);
OnVarsChanged(GetSelf(), origin); OnVarsChanged(GetSelf(), GetVars(), origin);
} }
} }

View File

@ -24,7 +24,7 @@ using namespace icinga;
REGISTER_TYPE(CustomVarObject); REGISTER_TYPE(CustomVarObject);
boost::signals2::signal<void (const CustomVarObject::Ptr&, const MessageOrigin&)> CustomVarObject::OnVarsChanged; boost::signals2::signal<void (const CustomVarObject::Ptr&, const Dictionary::Ptr& vars, const MessageOrigin&)> CustomVarObject::OnVarsChanged;
Dictionary::Ptr CustomVarObject::GetVars(void) const Dictionary::Ptr CustomVarObject::GetVars(void) const
{ {
@ -38,9 +38,7 @@ void CustomVarObject::SetVars(const Dictionary::Ptr& vars, const MessageOrigin&
{ {
SetOverrideVars(vars); SetOverrideVars(vars);
Log(LogNotice, "CustomVarObject", "Setting vars for object '" + GetName() + "'"); OnVarsChanged(GetSelf(), vars, origin);
OnVarsChanged(GetSelf(), origin);
} }
int CustomVarObject::GetModifiedAttributes(void) const int CustomVarObject::GetModifiedAttributes(void) const

View File

@ -59,7 +59,7 @@ class I2_ICINGA_API CustomVarObject : public ObjectImpl<CustomVarObject>
public: public:
DECLARE_PTR_TYPEDEFS(CustomVarObject); DECLARE_PTR_TYPEDEFS(CustomVarObject);
static boost::signals2::signal<void (const CustomVarObject::Ptr&, const MessageOrigin&)> OnVarsChanged; static boost::signals2::signal<void (const CustomVarObject::Ptr&, const Dictionary::Ptr& vars, const MessageOrigin&)> OnVarsChanged;
Dictionary::Ptr GetVars(void) const; Dictionary::Ptr GetVars(void) const;
void SetVars(const Dictionary::Ptr& vars, const MessageOrigin& origin = MessageOrigin()); void SetVars(const Dictionary::Ptr& vars, const MessageOrigin& origin = MessageOrigin());

View File

@ -122,7 +122,7 @@ void User::SetModifiedAttributes(int flags, const MessageOrigin& origin)
{ {
if ((flags & ModAttrCustomVariable) == 0) { if ((flags & ModAttrCustomVariable) == 0) {
SetOverrideVars(Empty); SetOverrideVars(Empty);
OnVarsChanged(GetSelf(), origin); OnVarsChanged(GetSelf(), GetVars(), origin);
} }
} }