CompatLogger: Add external commands.

refs #4362
This commit is contained in:
Michael Friedrich 2013-09-30 20:34:55 +02:00
parent 1ab5639c9a
commit 7dae41ee98
2 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "icinga/checkcommand.h"
#include "icinga/notification.h"
#include "icinga/macroprocessor.h"
#include "icinga/externalcommandprocessor.h"
#include "config/configcompilercontext.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
@ -56,6 +57,7 @@ void CompatLogger::Start(void)
Service::OnFlappingChanged.connect(bind(&CompatLogger::FlappingHandler, this, _1, _2));
Service::OnDowntimeTriggered.connect(boost::bind(&CompatLogger::TriggerDowntimeHandler, this, _1, _2));
Service::OnDowntimeRemoved.connect(boost::bind(&CompatLogger::RemoveDowntimeHandler, this, _1, _2));
ExternalCommandProcessor::OnNewExternalCommand.connect(bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
m_RotationTimer = boost::make_shared<Timer>();
m_RotationTimer->OnTimerExpired.connect(boost::bind(&CompatLogger::RotationTimerHandler, this));
@ -413,6 +415,21 @@ void CompatLogger::FlappingHandler(const Service::Ptr& service, FlappingState fl
}
void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
{
std::ostringstream msgbuf;
msgbuf << "EXTERNAL COMMAND: "
<< command << ";"
<< boost::algorithm::join(arguments, ";")
<< "";
{
ObjectLock oLock(this);
WriteLine(msgbuf.str());
}
}
void CompatLogger::WriteLine(const String& line)
{
ASSERT(OwnsLock());

View File

@ -67,6 +67,7 @@ private:
void FlappingHandler(const Service::Ptr& service, FlappingState flapping_state);
void TriggerDowntimeHandler(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);
Timer::Ptr m_RotationTimer;
void RotationTimerHandler(void);