2012-07-09 20:32:02 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2015-01-22 12:00:23 +01:00
|
|
|
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
2012-07-09 20:32:02 +02:00
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-11-04 14:41:24 +01:00
|
|
|
#ifndef PLUGINUTILITY_H
|
|
|
|
#define PLUGINUTILITY_H
|
2012-06-13 13:42:55 +02:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
|
|
|
#include "icinga/checkable.hpp"
|
|
|
|
#include "icinga/checkcommand.hpp"
|
|
|
|
#include "icinga/macroprocessor.hpp"
|
2013-11-04 14:41:24 +01:00
|
|
|
#include <vector>
|
2013-03-16 21:18:53 +01:00
|
|
|
|
2012-06-13 13:42:55 +02:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2014-05-11 17:14:35 +02:00
|
|
|
struct ProcessResult;
|
|
|
|
|
2012-09-17 13:35:55 +02:00
|
|
|
/**
|
2013-11-04 14:41:24 +01:00
|
|
|
* Utility functions for plugin-based checks.
|
2012-09-17 13:35:55 +02:00
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
2013-11-04 14:41:24 +01:00
|
|
|
class I2_ICINGA_API PluginUtility
|
2012-06-13 13:42:55 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-04-26 13:16:08 +02:00
|
|
|
static void ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
|
2014-05-22 08:59:46 +02:00
|
|
|
const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
|
2014-11-26 20:43:42 +01:00
|
|
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros,
|
2014-04-26 13:16:08 +02:00
|
|
|
const boost::function<void(const Value& commandLine, const ProcessResult&)>& callback = boost::function<void(const Value& commandLine, const ProcessResult&)>());
|
|
|
|
|
2013-01-22 12:05:36 +01:00
|
|
|
static ServiceState ExitStatusToState(int exitStatus);
|
2014-09-07 12:27:06 +02:00
|
|
|
static std::pair<String, String> ParseCheckOutput(const String& output);
|
2013-01-22 12:05:36 +01:00
|
|
|
|
2014-09-17 15:38:39 +02:00
|
|
|
static Array::Ptr SplitPerfdata(const String& perfdata);
|
|
|
|
static String FormatPerfdata(const Array::Ptr& perfdata);
|
2013-11-07 13:37:58 +01:00
|
|
|
|
2012-06-13 13:42:55 +02:00
|
|
|
private:
|
2013-11-04 14:41:24 +01:00
|
|
|
PluginUtility(void);
|
2014-11-26 20:43:42 +01:00
|
|
|
|
|
|
|
static void AddArgumentHelper(const Array::Ptr& args, const String& key, const String& value, bool add_key, bool add_value);
|
|
|
|
static Value EscapeMacroShellArg(const Value& value);
|
2012-06-13 13:42:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:41:24 +01:00
|
|
|
#endif /* PLUGINUTILITY_H */
|