]> granicus.if.org Git - icinga2/commitdiff
CompatLogger: Add external commands.
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 30 Sep 2013 18:34:55 +0000 (20:34 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 30 Sep 2013 18:34:55 +0000 (20:34 +0200)
refs #4362

components/compat/compatlogger.cpp
components/compat/compatlogger.h

index 915d75ffae7a6f2c5016f9a6d0761a68f629ff5a..396f20034b02325854c50d761f13a1eb367dd7c1 100644 (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());
index aa8fad4c6400524dd5e62bed2d21e316fca37476..8b84ed3906cb61d5afd0e35cefc524bb026b42b9 100644 (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);