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