2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2012-07-09 20:32:02 +02:00
|
|
|
|
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
|
|
|
|
*/
|
2017-12-31 07:22:16 +01:00
|
|
|
class 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,
|
2017-12-19 15:50:05 +01:00
|
|
|
const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
|
2018-09-28 14:32:57 +02:00
|
|
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int timeout,
|
2017-12-19 15:50:05 +01:00
|
|
|
const std::function<void(const Value& commandLine, const ProcessResult&)>& callback = std::function<void(const Value& commandLine, const ProcessResult&)>());
|
2014-04-26 13:16:08 +02:00
|
|
|
|
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);
|
2021-05-11 16:47:03 +02:00
|
|
|
static String FormatPerfdata(const Array::Ptr& perfdata, bool normalize = false);
|
2013-11-07 13:37:58 +01:00
|
|
|
|
2012-06-13 13:42:55 +02:00
|
|
|
private:
|
2018-01-04 04:25:35 +01:00
|
|
|
PluginUtility();
|
2012-06-13 13:42:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:41:24 +01:00
|
|
|
#endif /* PLUGINUTILITY_H */
|