mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
parent
5718cbebe4
commit
20a2fd2388
@ -20,6 +20,7 @@
|
|||||||
#include "compat/compatlogger.h"
|
#include "compat/compatlogger.h"
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
#include "icinga/checkcommand.h"
|
#include "icinga/checkcommand.h"
|
||||||
|
#include "icinga/eventcommand.h"
|
||||||
#include "icinga/notification.h"
|
#include "icinga/notification.h"
|
||||||
#include "icinga/macroprocessor.h"
|
#include "icinga/macroprocessor.h"
|
||||||
#include "icinga/externalcommandprocessor.h"
|
#include "icinga/externalcommandprocessor.h"
|
||||||
@ -58,6 +59,7 @@ void CompatLogger::Start(void)
|
|||||||
Service::OnFlappingChanged.connect(bind(&CompatLogger::FlappingHandler, this, _1, _2));
|
Service::OnFlappingChanged.connect(bind(&CompatLogger::FlappingHandler, this, _1, _2));
|
||||||
Service::OnDowntimeTriggered.connect(boost::bind(&CompatLogger::TriggerDowntimeHandler, this, _1, _2));
|
Service::OnDowntimeTriggered.connect(boost::bind(&CompatLogger::TriggerDowntimeHandler, this, _1, _2));
|
||||||
Service::OnDowntimeRemoved.connect(boost::bind(&CompatLogger::RemoveDowntimeHandler, this, _1, _2));
|
Service::OnDowntimeRemoved.connect(boost::bind(&CompatLogger::RemoveDowntimeHandler, this, _1, _2));
|
||||||
|
Service::OnEventCommandExecuted.connect(bind(&CompatLogger::EventCommandHandler, this, _1));
|
||||||
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
|
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
|
||||||
|
|
||||||
m_RotationTimer = boost::make_shared<Timer>();
|
m_RotationTimer = boost::make_shared<Timer>();
|
||||||
@ -393,6 +395,55 @@ void CompatLogger::ExternalCommandHandler(const String& command, const std::vect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompatLogger::EventCommandHandler(const Service::Ptr& service)
|
||||||
|
{
|
||||||
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
|
if (!host)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EventCommand::Ptr event_command = service->GetEventCommand();
|
||||||
|
String event_command_name = event_command->GetName();
|
||||||
|
String state = Service::StateToString(service->GetState());
|
||||||
|
String state_type = Service::StateTypeToString(service->GetStateType());
|
||||||
|
long current_attempt = service->GetCheckAttempt();
|
||||||
|
|
||||||
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
|
msgbuf << "SERVICE EVENT HANDLER: "
|
||||||
|
<< host->GetName() << ";"
|
||||||
|
<< service->GetShortName() << ";"
|
||||||
|
<< state << ";"
|
||||||
|
<< state_type << ";"
|
||||||
|
<< current_attempt << ";"
|
||||||
|
<< event_command_name;
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock oLock(this);
|
||||||
|
WriteLine(msgbuf.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (service == host->GetCheckService()) {
|
||||||
|
std::ostringstream msgbuf;
|
||||||
|
msgbuf << "HOST EVENT HANDLER: "
|
||||||
|
<< host->GetName() << ";"
|
||||||
|
<< state << ";"
|
||||||
|
<< state_type << ";"
|
||||||
|
<< current_attempt << ";"
|
||||||
|
<< event_command_name;
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock oLock(this);
|
||||||
|
WriteLine(msgbuf.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock oLock(this);
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CompatLogger::WriteLine(const String& line)
|
void CompatLogger::WriteLine(const String& line)
|
||||||
{
|
{
|
||||||
ASSERT(OwnsLock());
|
ASSERT(OwnsLock());
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
void TriggerDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
void TriggerDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
void RemoveDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
void RemoveDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
||||||
|
void EventCommandHandler(const Service::Ptr& service);
|
||||||
|
|
||||||
Timer::Ptr m_RotationTimer;
|
Timer::Ptr m_RotationTimer;
|
||||||
void RotationTimerHandler(void);
|
void RotationTimerHandler(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user