mirror of https://github.com/Icinga/icinga2.git
parent
731ee15d4d
commit
d20ee37196
|
@ -130,7 +130,8 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
|
|||
#endif /* _DEBUG */
|
||||
|
||||
try {
|
||||
wi.Callback();
|
||||
if (wi.Callback)
|
||||
wi.Callback();
|
||||
} catch (const std::exception& ex) {
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "Exception thrown in event handler: " << std::endl
|
||||
|
|
|
@ -48,5 +48,16 @@ void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable)
|
|||
resolvers.push_back(std::make_pair("command", commandObj));
|
||||
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
||||
|
||||
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers);
|
||||
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers, boost::bind(&PluginEventTask::ProcessFinishedHandler, checkable, _1, _2));
|
||||
}
|
||||
|
||||
void PluginEventTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr)
|
||||
{
|
||||
if (pr.ExitStatus != 0) {
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "Event command '" << command << "' for object '"
|
||||
<< checkable->GetName() << "' failed; exit status: "
|
||||
<< pr.ExitStatus << ", output: " << pr.Output;
|
||||
Log(LogWarning, "PluginEventTask", msgbuf.str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "methods/i2-methods.hpp"
|
||||
#include "icinga/service.hpp"
|
||||
#include "base/process.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -38,6 +39,8 @@ public:
|
|||
|
||||
private:
|
||||
PluginEventTask(void);
|
||||
|
||||
static void ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue