mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-12 16:24:41 +02:00
parent
345ebe8061
commit
f53f8e64fd
@ -37,7 +37,8 @@ void CheckerComponent::Start(void)
|
|||||||
m_CheckTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::CheckTimerHandler, this));
|
m_CheckTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::CheckTimerHandler, this));
|
||||||
m_CheckTimer->Start();
|
m_CheckTimer->Start();
|
||||||
|
|
||||||
NagiosCheckTask::Register();
|
/* TODO: figure out a way to register check types */
|
||||||
|
PluginCheckTask::Register();
|
||||||
NullCheckTask::Register();
|
NullCheckTask::Register();
|
||||||
|
|
||||||
m_ResultTimer = boost::make_shared<Timer>();
|
m_ResultTimer = boost::make_shared<Timer>();
|
||||||
|
@ -16,7 +16,7 @@ local object Component "compat" {
|
|||||||
|
|
||||||
abstract object Service "nagios-service" {
|
abstract object Service "nagios-service" {
|
||||||
methods = {
|
methods = {
|
||||||
check = "native::NagiosCheck"
|
check = "native::PluginCheck"
|
||||||
},
|
},
|
||||||
|
|
||||||
macros = {
|
macros = {
|
||||||
|
@ -16,10 +16,10 @@ libicinga_la_SOURCES = \
|
|||||||
icingaapplication.h \
|
icingaapplication.h \
|
||||||
macroprocessor.cpp \
|
macroprocessor.cpp \
|
||||||
macroprocessor.h \
|
macroprocessor.h \
|
||||||
nagioschecktask.cpp \
|
|
||||||
nagioschecktask.h \
|
|
||||||
nullchecktask.cpp \
|
nullchecktask.cpp \
|
||||||
nullchecktask.h \
|
nullchecktask.h \
|
||||||
|
pluginchecktask.cpp \
|
||||||
|
pluginchecktask.h \
|
||||||
service.cpp \
|
service.cpp \
|
||||||
servicegroup.cpp \
|
servicegroup.cpp \
|
||||||
servicegroup.h \
|
servicegroup.h \
|
||||||
|
@ -50,7 +50,7 @@ using boost::algorithm::is_any_of;
|
|||||||
#include "servicegroup.h"
|
#include "servicegroup.h"
|
||||||
|
|
||||||
#include "macroprocessor.h"
|
#include "macroprocessor.h"
|
||||||
#include "nagioschecktask.h"
|
#include "pluginchecktask.h"
|
||||||
#include "nullchecktask.h"
|
#include "nullchecktask.h"
|
||||||
|
|
||||||
#include "servicestatechangemessage.h"
|
#include "servicestatechangemessage.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="icingaapplication.cpp" />
|
<ClCompile Include="icingaapplication.cpp" />
|
||||||
<ClCompile Include="macroprocessor.cpp" />
|
<ClCompile Include="macroprocessor.cpp" />
|
||||||
<ClCompile Include="nagioschecktask.cpp" />
|
<ClCompile Include="pluginchecktask.cpp" />
|
||||||
<ClCompile Include="nullchecktask.cpp" />
|
<ClCompile Include="nullchecktask.cpp" />
|
||||||
<ClCompile Include="service.cpp" />
|
<ClCompile Include="service.cpp" />
|
||||||
<ClCompile Include="servicegroup.cpp" />
|
<ClCompile Include="servicegroup.cpp" />
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<ClInclude Include="i2-icinga.h" />
|
<ClInclude Include="i2-icinga.h" />
|
||||||
<ClInclude Include="icingaapplication.h" />
|
<ClInclude Include="icingaapplication.h" />
|
||||||
<ClInclude Include="macroprocessor.h" />
|
<ClInclude Include="macroprocessor.h" />
|
||||||
<ClInclude Include="nagioschecktask.h" />
|
<ClInclude Include="pluginchecktask.h" />
|
||||||
<ClInclude Include="nullchecktask.h" />
|
<ClInclude Include="nullchecktask.h" />
|
||||||
<ClInclude Include="service.h" />
|
<ClInclude Include="service.h" />
|
||||||
<ClInclude Include="servicegroup.h" />
|
<ClInclude Include="servicegroup.h" />
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
NagiosCheckTask::NagiosCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process)
|
PluginCheckTask::PluginCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process)
|
||||||
: m_Task(task), m_Process(process)
|
: m_Task(task), m_Process(process)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void NagiosCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
void PluginCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Missing argument: Service must be specified."));
|
throw_exception(invalid_argument("Missing argument: Service must be specified."));
|
||||||
@ -46,15 +46,15 @@ void NagiosCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value
|
|||||||
|
|
||||||
Process::Ptr process = boost::make_shared<Process>(command);
|
Process::Ptr process = boost::make_shared<Process>(command);
|
||||||
|
|
||||||
NagiosCheckTask ct(task, process);
|
PluginCheckTask ct(task, process);
|
||||||
|
|
||||||
ct.m_Result = boost::make_shared<Dictionary>();
|
ct.m_Result = boost::make_shared<Dictionary>();
|
||||||
ct.m_Result->Set("schedule_start", Utility::GetTime());
|
ct.m_Result->Set("schedule_start", Utility::GetTime());
|
||||||
|
|
||||||
process->Start(boost::bind(&NagiosCheckTask::ProcessFinishedHandler, ct));
|
process->Start(boost::bind(&PluginCheckTask::ProcessFinishedHandler, ct));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct)
|
void PluginCheckTask::ProcessFinishedHandler(PluginCheckTask ct)
|
||||||
{
|
{
|
||||||
ProcessResult pr;
|
ProcessResult pr;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct)
|
|||||||
ct.m_Task->FinishResult(ct.m_Result);
|
ct.m_Task->FinishResult(ct.m_Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NagiosCheckTask::ProcessCheckOutput(const Dictionary::Ptr& result, String& output)
|
void PluginCheckTask::ProcessCheckOutput(const Dictionary::Ptr& result, String& output)
|
||||||
{
|
{
|
||||||
String text;
|
String text;
|
||||||
String perfdata;
|
String perfdata;
|
||||||
@ -125,8 +125,8 @@ void NagiosCheckTask::ProcessCheckOutput(const Dictionary::Ptr& result, String&
|
|||||||
result->Set("performance_data_raw", perfdata);
|
result->Set("performance_data_raw", perfdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NagiosCheckTask::Register(void)
|
void PluginCheckTask::Register(void)
|
||||||
{
|
{
|
||||||
ScriptFunction::Ptr func = boost::make_shared<ScriptFunction>(&NagiosCheckTask::ScriptFunc);
|
ScriptFunction::Ptr func = boost::make_shared<ScriptFunction>(&PluginCheckTask::ScriptFunc);
|
||||||
ScriptFunction::Register("native::NagiosCheck", func);
|
ScriptFunction::Register("native::PluginCheck", func);
|
||||||
}
|
}
|
@ -17,18 +17,18 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef NAGIOSCHECKTASK_H
|
#ifndef PLUGINCHECKTASK_H
|
||||||
#define NAGIOSCHECKTASK_H
|
#define PLUGINCHECKTASK_H
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Nagios(TM)-style checks.
|
* Implements service checks based on external plugins.
|
||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API NagiosCheckTask
|
class I2_ICINGA_API PluginCheckTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Register(void);
|
static void Register(void);
|
||||||
@ -36,10 +36,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
static void ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments);
|
static void ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments);
|
||||||
|
|
||||||
static void ProcessFinishedHandler(NagiosCheckTask ct);
|
static void ProcessFinishedHandler(PluginCheckTask ct);
|
||||||
static void ProcessCheckOutput(const Dictionary::Ptr& result, String& output);
|
static void ProcessCheckOutput(const Dictionary::Ptr& result, String& output);
|
||||||
|
|
||||||
NagiosCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process);
|
PluginCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process);
|
||||||
|
|
||||||
ScriptTask::Ptr m_Task;
|
ScriptTask::Ptr m_Task;
|
||||||
Process::Ptr m_Process;
|
Process::Ptr m_Process;
|
||||||
@ -48,4 +48,4 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NAGIOSCHECKTASK_H */
|
#endif /* PLUGINCHECKTASK_H */
|
Loading…
x
Reference in New Issue
Block a user