mirror of https://github.com/Icinga/icinga2.git
parent
c07857dea8
commit
16de7f853b
|
@ -66,6 +66,8 @@ void ServiceDbObject::StaticInitialize(void)
|
||||||
Service::OnFlappingChanged.connect(bind(&ServiceDbObject::AddFlappingHistory, _1, _2));
|
Service::OnFlappingChanged.connect(bind(&ServiceDbObject::AddFlappingHistory, _1, _2));
|
||||||
Service::OnNewCheckResult.connect(bind(&ServiceDbObject::AddServiceCheckHistory, _1, _2));
|
Service::OnNewCheckResult.connect(bind(&ServiceDbObject::AddServiceCheckHistory, _1, _2));
|
||||||
|
|
||||||
|
Service::OnEventCommandExecuted.connect(bind(&ServiceDbObject::AddEventHandlerHistory, _1));
|
||||||
|
|
||||||
ExternalCommandProcessor::OnNewExternalCommand.connect(bind(&ServiceDbObject::AddExternalCommandHistory, _1, _2, _3));
|
ExternalCommandProcessor::OnNewExternalCommand.connect(bind(&ServiceDbObject::AddExternalCommandHistory, _1, _2, _3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,6 +1324,52 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eventhandlers */
|
||||||
|
void ServiceDbObject::AddEventHandlerHistory(const Service::Ptr& service)
|
||||||
|
{
|
||||||
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
|
if (!host)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log(LogDebug, "db_ido", "add eventhandler history for '" + service->GetName() + "'");
|
||||||
|
|
||||||
|
double now = Utility::GetTime();
|
||||||
|
unsigned long event_time = static_cast<long>(now);
|
||||||
|
unsigned long event_time_usec = (now - event_time) * 1000 * 1000;
|
||||||
|
|
||||||
|
DbQuery query1;
|
||||||
|
query1.Table = "eventhandlers";
|
||||||
|
query1.Type = DbQueryInsert;
|
||||||
|
|
||||||
|
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
|
fields1->Set("eventhandler_type", 1); /* service */
|
||||||
|
fields1->Set("object_id", service);
|
||||||
|
fields1->Set("state", service->GetState());
|
||||||
|
fields1->Set("state_type", service->GetStateType());
|
||||||
|
|
||||||
|
fields1->Set("start_time", DbValue::FromTimestamp(event_time));
|
||||||
|
fields1->Set("start_time_usec", event_time_usec);
|
||||||
|
fields1->Set("end_time", DbValue::FromTimestamp(event_time));
|
||||||
|
fields1->Set("end_time_usec", event_time_usec);
|
||||||
|
fields1->Set("command_object_id", service->GetEventCommand());
|
||||||
|
|
||||||
|
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
|
query1.Fields = fields1;
|
||||||
|
OnQuery(query1);
|
||||||
|
|
||||||
|
if (host->GetCheckService() == service) {
|
||||||
|
fields1->Set("eventhandler_type", 0); /* host */
|
||||||
|
fields1->Set("object_id", host);
|
||||||
|
fields1->Set("state", host->GetState());
|
||||||
|
fields1->Set("state_type", host->GetStateType());
|
||||||
|
query1.Fields = fields1;
|
||||||
|
OnQuery(query1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* externalcommands */
|
/* externalcommands */
|
||||||
void ServiceDbObject::AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments)
|
void ServiceDbObject::AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments)
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,6 +110,7 @@ private:
|
||||||
|
|
||||||
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
|
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
|
||||||
static void AddServiceCheckHistory(const Service::Ptr& service, const Dictionary::Ptr &cr);
|
static void AddServiceCheckHistory(const Service::Ptr& service, const Dictionary::Ptr &cr);
|
||||||
|
static void AddEventHandlerHistory(const Service::Ptr& service);
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
boost::signals2::signal<void (const Service::Ptr&)> Service::OnEventCommandExecuted;
|
||||||
|
|
||||||
EventCommand::Ptr Service::GetEventCommand(void) const
|
EventCommand::Ptr Service::GetEventCommand(void) const
|
||||||
{
|
{
|
||||||
return EventCommand::GetByName(m_EventCommand);
|
return EventCommand::GetByName(m_EventCommand);
|
||||||
|
@ -35,5 +37,8 @@ void Service::ExecuteEventHandler(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log(LogDebug, "icinga", "Executing event handler for service '" + GetName() + "'");
|
Log(LogDebug, "icinga", "Executing event handler for service '" + GetName() + "'");
|
||||||
|
|
||||||
ec->Execute(GetSelf());
|
ec->Execute(GetSelf());
|
||||||
|
|
||||||
|
OnEventCommandExecuted(GetSelf());
|
||||||
}
|
}
|
|
@ -250,6 +250,7 @@ public:
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&)> OnDowntimeTriggered;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&)> OnDowntimeTriggered;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const String&, const String&, AcknowledgementType, double, const String&)> OnAcknowledgementSet;
|
static boost::signals2::signal<void (const Service::Ptr&, const String&, const String&, AcknowledgementType, double, const String&)> OnAcknowledgementSet;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const String&)> OnAcknowledgementCleared;
|
static boost::signals2::signal<void (const Service::Ptr&, const String&)> OnAcknowledgementCleared;
|
||||||
|
static boost::signals2::signal<void (const Service::Ptr&)> OnEventCommandExecuted;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue