mirror of https://github.com/Icinga/icinga2.git
commit
043302cee4
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "compat/checkresultreader.h"
|
||||
#include "icinga/service.h"
|
||||
#include "icinga/pluginchecktask.h"
|
||||
#include "icinga/pluginutility.h"
|
||||
#include "base/dynamictype.h"
|
||||
#include "base/objectlock.h"
|
||||
#include "base/logger_fwd.h"
|
||||
|
@ -102,8 +102,8 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
|||
return;
|
||||
}
|
||||
|
||||
Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(attrs["output"]);
|
||||
result->Set("state", PluginCheckTask::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(attrs["output"]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
||||
result->Set("execution_start", Convert::ToDouble(attrs["start_time"]));
|
||||
result->Set("execution_end", Convert::ToDouble(attrs["finish_time"]));
|
||||
result->Set("active", 1);
|
||||
|
|
|
@ -10,7 +10,7 @@ IcingaPkgDataDir |**Read-only.** Contains the path of the package data
|
|||
IcingaStatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state".
|
||||
IcingaPidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to IcingaLocalStateDir + "/run/icinga2/icinga2.pid".
|
||||
IcingaMacros |**Read-write.** Contains a dictionary with global macros. Not set by default.
|
||||
ApplicationType |**Read-write.** Contains the name of the Application type. Defaults to "IcingaApplication".
|
||||
ApplicationType |**Read-write.** Contains the name of the Application type. Defaults to "icinga/IcingaApplication".
|
||||
IcingaEnableNotifications |**Read-write.** Whether notifications are globally enabled. Defaults to true.
|
||||
IcingaEnableEventHandlers |**Read-write.** Whether event handlers are globally enabled. Defaults to true.
|
||||
IcingaEnableFlapping |**Read-write.** Whether flap detection is globally enabled. Defaults to true.
|
||||
|
|
|
@ -44,7 +44,25 @@ namespace po = boost::program_options;
|
|||
|
||||
static po::variables_map g_AppParams;
|
||||
|
||||
static bool LoadConfigFiles(bool validateOnly)
|
||||
static String LoadAppType(const String& typeSpec)
|
||||
{
|
||||
int index;
|
||||
|
||||
Log(LogInformation, "icinga-app", "Loading application type: " + typeSpec);
|
||||
|
||||
index = typeSpec.FindFirstOf('/');
|
||||
|
||||
if (index == String::NPos)
|
||||
return typeSpec;
|
||||
|
||||
String library = typeSpec.SubStr(0, index);
|
||||
|
||||
(void) Utility::LoadExtensionLibrary(library);
|
||||
|
||||
return typeSpec.SubStr(index + 1);
|
||||
}
|
||||
|
||||
static bool LoadConfigFiles(const String& appType, bool validateOnly)
|
||||
{
|
||||
ConfigCompilerContext::GetInstance()->Reset();
|
||||
|
||||
|
@ -58,7 +76,7 @@ static bool LoadConfigFiles(bool validateOnly)
|
|||
}
|
||||
|
||||
ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>();
|
||||
builder->SetType(Application::GetApplicationType());
|
||||
builder->SetType(appType);
|
||||
builder->SetName("application");
|
||||
ConfigItem::Ptr item = builder->Compile();
|
||||
item->Register();
|
||||
|
@ -177,7 +195,7 @@ int main(int argc, char **argv)
|
|||
Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
|
||||
Application::DeclarePkgDataDir(ICINGA_PKGDATADIR);
|
||||
|
||||
Application::DeclareApplicationType("IcingaApplication");
|
||||
Application::DeclareApplicationType("icinga/IcingaApplication");
|
||||
|
||||
po::options_description desc("Supported options");
|
||||
desc.add_options()
|
||||
|
@ -311,7 +329,7 @@ int main(int argc, char **argv)
|
|||
|
||||
Log(LogInformation, "icinga-app", "Icinga application loader (version: " + Application::GetVersion() + ")");
|
||||
|
||||
(void) Utility::LoadExtensionLibrary("icinga");
|
||||
String appType = LoadAppType(Application::GetApplicationType());
|
||||
|
||||
if (g_AppParams.count("library")) {
|
||||
BOOST_FOREACH(const String& libraryName, g_AppParams["library"].as<std::vector<String> >()) {
|
||||
|
@ -344,7 +362,7 @@ int main(int argc, char **argv)
|
|||
|
||||
bool validateOnly = g_AppParams.count("validate");
|
||||
|
||||
if (!LoadConfigFiles(validateOnly))
|
||||
if (!LoadConfigFiles(appType, validateOnly))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (validateOnly) {
|
||||
|
|
|
@ -19,3 +19,4 @@ add_subdirectory(base)
|
|||
add_subdirectory(config)
|
||||
add_subdirectory(icinga)
|
||||
add_subdirectory(db_ido)
|
||||
add_subdirectory(methods)
|
||||
|
|
|
@ -28,7 +28,7 @@ add_library(db_ido SHARED
|
|||
)
|
||||
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga)
|
||||
target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga methods)
|
||||
|
||||
set_target_properties (
|
||||
db_ido PROPERTIES
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "db_ido/dbtype.h"
|
||||
#include "db_ido/dbvalue.h"
|
||||
#include "icinga/timeperiod.h"
|
||||
#include "icinga/legacytimeperiod.h"
|
||||
#include "methods/legacytimeperiod.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/objectlock.h"
|
||||
|
|
|
@ -36,11 +36,9 @@ add_library(icinga SHARED
|
|||
api.cpp api.h checkcommand.cpp checkcommand.th cib.cpp command.cpp command.th
|
||||
compatutility.cpp domain.cpp domain.th eventcommand.cpp eventcommand.th
|
||||
externalcommandprocessor.cpp host.cpp host.th hostgroup.cpp hostgroup.th
|
||||
icingaapplication.cpp icingaapplication.th legacytimeperiod.cpp
|
||||
macroprocessor.cpp macroresolver.cpp notificationcommand.cpp
|
||||
notificationcommand.th notification.cpp notification.th nullchecktask.cpp
|
||||
nulleventtask.cpp pluginchecktask.cpp plugineventtask.cpp
|
||||
pluginnotificationtask.cpp randomchecktask.cpp service-check.cpp
|
||||
icingaapplication.cpp icingaapplication.th macroprocessor.cpp
|
||||
macroresolver.cpp notificationcommand.cpp notificationcommand.th
|
||||
notification.cpp notification.th pluginutility.cpp service-check.cpp
|
||||
service-comment.cpp service.cpp service-downtime.cpp service-event.cpp
|
||||
service-flapping.cpp service.th servicegroup.cpp servicegroup.th
|
||||
service-notification.cpp timeperiod.cpp timeperiod.th user.cpp user.th
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "icinga/user.h"
|
||||
#include "icinga/hostgroup.h"
|
||||
#include "icinga/servicegroup.h"
|
||||
#include "icinga/pluginchecktask.h"
|
||||
#include "icinga/pluginutility.h"
|
||||
#include "icinga/icingaapplication.h"
|
||||
#include "base/convert.h"
|
||||
#include "base/logger_fwd.h"
|
||||
|
@ -214,8 +214,8 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
|
|||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
|
||||
|
||||
int exitStatus = Convert::ToDouble(arguments[1]);
|
||||
Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(arguments[2]);
|
||||
result->Set("state", PluginCheckTask::ExitStatusToState(exitStatus));
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[2]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
||||
|
||||
result->Set("schedule_start", time);
|
||||
result->Set("schedule_end", time);
|
||||
|
@ -250,8 +250,8 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
|
|||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
||||
|
||||
int exitStatus = Convert::ToDouble(arguments[2]);
|
||||
Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(arguments[3]);
|
||||
result->Set("state", PluginCheckTask::ExitStatusToState(exitStatus));
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[3]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
||||
|
||||
result->Set("schedule_start", time);
|
||||
result->Set("schedule_end", time);
|
||||
|
|
|
@ -38,6 +38,8 @@ INITIALIZE_ONCE(IcingaApplication, &IcingaApplication::StaticInitialize);
|
|||
|
||||
void IcingaApplication::StaticInitialize(void)
|
||||
{
|
||||
(void) Utility::LoadExtensionLibrary("methods");
|
||||
|
||||
ScriptVariable::Set("IcingaEnableNotifications", true);
|
||||
ScriptVariable::Set("IcingaEnableEventHandlers", true);
|
||||
ScriptVariable::Set("IcingaEnableFlapping", true);
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/pluginutility.h"
|
||||
#include "icinga/checkcommand.h"
|
||||
#include "icinga/macroprocessor.h"
|
||||
#include "icinga/icingaapplication.h"
|
||||
#include "base/dynamictype.h"
|
||||
#include "base/logger_fwd.h"
|
||||
#include "base/scriptfunction.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/process.h"
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
ServiceState PluginUtility::ExitStatusToState(int exitStatus)
|
||||
{
|
||||
switch (exitStatus) {
|
||||
case 0:
|
||||
return StateOK;
|
||||
case 1:
|
||||
return StateWarning;
|
||||
case 2:
|
||||
return StateCritical;
|
||||
default:
|
||||
return StateUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary::Ptr PluginUtility::ParseCheckOutput(const String& output)
|
||||
{
|
||||
Dictionary::Ptr result = boost::make_shared<Dictionary>();
|
||||
|
||||
String text;
|
||||
String perfdata;
|
||||
|
||||
std::vector<String> lines;
|
||||
boost::algorithm::split(lines, output, boost::is_any_of("\r\n"));
|
||||
|
||||
BOOST_FOREACH (const String& line, lines) {
|
||||
size_t delim = line.FindFirstOf("|");
|
||||
|
||||
if (!text.IsEmpty())
|
||||
text += "\n";
|
||||
|
||||
if (delim != String::NPos) {
|
||||
text += line.SubStr(0, delim);
|
||||
|
||||
if (!perfdata.IsEmpty())
|
||||
perfdata += " ";
|
||||
|
||||
perfdata += line.SubStr(delim + 1, line.GetLength());
|
||||
} else {
|
||||
text += line;
|
||||
}
|
||||
}
|
||||
|
||||
result->Set("output", text);
|
||||
result->Set("performance_data_raw", perfdata);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PLUGINUTILITY_H
|
||||
#define PLUGINUTILITY_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "icinga/service.h"
|
||||
#include "icinga/checkcommand.h"
|
||||
#include "base/dictionary.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include <vector>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Utility functions for plugin-based checks.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API PluginUtility
|
||||
{
|
||||
public:
|
||||
static ServiceState ExitStatusToState(int exitStatus);
|
||||
static Dictionary::Ptr ParseCheckOutput(const String& output);
|
||||
|
||||
private:
|
||||
PluginUtility(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* PLUGINUTILITY_H */
|
|
@ -0,0 +1,38 @@
|
|||
# Icinga 2
|
||||
# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
add_library(methods SHARED
|
||||
legacytimeperiod.cpp nullchecktask.cpp nulleventtask.cpp pluginchecktask.cpp
|
||||
plugineventtask.cpp pluginnotificationtask.cpp randomchecktask.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(methods ${Boost_LIBRARIES} base config icinga)
|
||||
|
||||
set_target_properties (
|
||||
methods PROPERTIES
|
||||
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
|
||||
DEFINE_SYMBOL I2_METHODS_BUILD
|
||||
FOLDER Lib
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS methods
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef I2METHODS_H
|
||||
#define I2METHODS_H
|
||||
|
||||
/**
|
||||
* @defgroup methods Icinga methods
|
||||
*
|
||||
* The methods library implements methods for various task (e.g. checks, event
|
||||
* handlers, etc.).
|
||||
*/
|
||||
|
||||
#include "base/i2-base.h"
|
||||
|
||||
#ifdef I2_METHODS_BUILD
|
||||
# define I2_METHODS_API I2_EXPORT
|
||||
#else /* I2_METHODS_BUILD */
|
||||
# define I2_METHODS_API I2_IMPORT
|
||||
#endif /* I2_METHODS_BUILD */
|
||||
|
||||
#endif /* I2METHODS_H */
|
|
@ -17,7 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/legacytimeperiod.h"
|
||||
#include "methods/legacytimeperiod.h"
|
||||
#include "base/scriptfunction.h"
|
||||
#include "base/convert.h"
|
||||
#include "base/exception.h"
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef LEGACYTIMEPERIOD_H
|
||||
#define LEGACYTIMEPERIOD_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API LegacyTimePeriod
|
||||
class I2_METHODS_API LegacyTimePeriod
|
||||
{
|
||||
public:
|
||||
static Array::Ptr ScriptFunc(const TimePeriod::Ptr& tp, double start, double end);
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _WIN32
|
||||
# include <stdlib.h>
|
||||
#endif /* _WIN32 */
|
||||
#include "icinga/nullchecktask.h"
|
||||
#include "methods/nullchecktask.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/convert.h"
|
||||
#include "base/scriptfunction.h"
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef NULLCHECKTASK_H
|
||||
#define NULLCHECKTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
|
@ -30,9 +30,9 @@ namespace icinga
|
|||
/**
|
||||
* Test class for additional check types. Implements the "null" check type.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API NullCheckTask
|
||||
class I2_METHODS_API NullCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
|
@ -17,7 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/nulleventtask.h"
|
||||
#include "methods/nulleventtask.h"
|
||||
#include "base/scriptfunction.h"
|
||||
#include "base/logger_fwd.h"
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef NULLEVENTTASK_H
|
||||
#define NULLEVENTTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
|
@ -30,9 +30,9 @@ namespace icinga
|
|||
/**
|
||||
* Test class for additional event handler types. Implements the "null" event handler type.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API NullEventTask
|
||||
class I2_METHODS_API NullEventTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Service::Ptr& service);
|
|
@ -17,7 +17,8 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/pluginchecktask.h"
|
||||
#include "methods/pluginchecktask.h"
|
||||
#include "icinga/pluginutility.h"
|
||||
#include "icinga/checkcommand.h"
|
||||
#include "icinga/macroprocessor.h"
|
||||
#include "icinga/icingaapplication.h"
|
||||
|
@ -73,9 +74,9 @@ Dictionary::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
|||
|
||||
String output = pr.Output;
|
||||
output.Trim();
|
||||
Dictionary::Ptr result = ParseCheckOutput(output);
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(output);
|
||||
result->Set("command", command);
|
||||
result->Set("state", ExitStatusToState(pr.ExitStatus));
|
||||
result->Set("state", PluginUtility::ExitStatusToState(pr.ExitStatus));
|
||||
result->Set("exit_state", pr.ExitStatus);
|
||||
result->Set("execution_start", pr.ExecutionStart);
|
||||
result->Set("execution_end", pr.ExecutionEnd);
|
||||
|
@ -83,50 +84,3 @@ Dictionary::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
|||
return result;
|
||||
}
|
||||
|
||||
ServiceState PluginCheckTask::ExitStatusToState(int exitStatus)
|
||||
{
|
||||
switch (exitStatus) {
|
||||
case 0:
|
||||
return StateOK;
|
||||
case 1:
|
||||
return StateWarning;
|
||||
case 2:
|
||||
return StateCritical;
|
||||
default:
|
||||
return StateUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary::Ptr PluginCheckTask::ParseCheckOutput(const String& output)
|
||||
{
|
||||
Dictionary::Ptr result = boost::make_shared<Dictionary>();
|
||||
|
||||
String text;
|
||||
String perfdata;
|
||||
|
||||
std::vector<String> lines;
|
||||
boost::algorithm::split(lines, output, boost::is_any_of("\r\n"));
|
||||
|
||||
BOOST_FOREACH (const String& line, lines) {
|
||||
size_t delim = line.FindFirstOf("|");
|
||||
|
||||
if (!text.IsEmpty())
|
||||
text += "\n";
|
||||
|
||||
if (delim != String::NPos) {
|
||||
text += line.SubStr(0, delim);
|
||||
|
||||
if (!perfdata.IsEmpty())
|
||||
perfdata += " ";
|
||||
|
||||
perfdata += line.SubStr(delim + 1, line.GetLength());
|
||||
} else {
|
||||
text += line;
|
||||
}
|
||||
}
|
||||
|
||||
result->Set("output", text);
|
||||
result->Set("performance_data_raw", perfdata);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PLUGINCHECKTASK_H
|
||||
#define PLUGINCHECKTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/service.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -29,16 +29,13 @@ namespace icinga
|
|||
/**
|
||||
* Implements service checks based on external plugins.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API PluginCheckTask
|
||||
class I2_METHODS_API PluginCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
|
||||
static ServiceState ExitStatusToState(int exitStatus);
|
||||
static Dictionary::Ptr ParseCheckOutput(const String& output);
|
||||
|
||||
private:
|
||||
PluginCheckTask(void);
|
||||
};
|
|
@ -17,7 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/plugineventtask.h"
|
||||
#include "methods/plugineventtask.h"
|
||||
#include "icinga/eventcommand.h"
|
||||
#include "icinga/macroprocessor.h"
|
||||
#include "icinga/icingaapplication.h"
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PLUGINEVENTTASK_H
|
||||
#define PLUGINEVENTTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/service.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -29,9 +29,9 @@ namespace icinga
|
|||
/**
|
||||
* Implements event handlers based on external plugins.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API PluginEventTask
|
||||
class I2_METHODS_API PluginEventTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Service::Ptr& service);
|
|
@ -17,7 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/pluginnotificationtask.h"
|
||||
#include "methods/pluginnotificationtask.h"
|
||||
#include "icinga/notification.h"
|
||||
#include "icinga/notificationcommand.h"
|
||||
#include "icinga/service.h"
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PLUGINNOTIFICATIONTASK_H
|
||||
#define PLUGINNOTIFICATIONTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "methods/i2-methods.h"
|
||||
#include "icinga/notification.h"
|
||||
|
||||
namespace icinga
|
||||
|
@ -29,9 +29,9 @@ namespace icinga
|
|||
/**
|
||||
* Implements sending notifications based on external plugins.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API PluginNotificationTask
|
||||
class I2_METHODS_API PluginNotificationTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Notification::Ptr& notification,
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _WIN32
|
||||
# include <stdlib.h>
|
||||
#endif /* _WIN32 */
|
||||
#include "icinga/randomchecktask.h"
|
||||
#include "methods/randomchecktask.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/convert.h"
|
||||
#include "base/scriptfunction.h"
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef RANDOMCHECKTASK_H
|
||||
#define RANDOMCHECKTASK_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "icinga/service.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
|
@ -30,9 +29,9 @@ namespace icinga
|
|||
/**
|
||||
* Test class for additional check types. Implements the "null" check type.
|
||||
*
|
||||
* @ingroup icinga
|
||||
* @ingroup methods
|
||||
*/
|
||||
class I2_ICINGA_API RandomCheckTask
|
||||
class RandomCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
Loading…
Reference in New Issue