2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2012-07-09 14:32:02 -04:00
|
|
|
|
2013-11-04 08:41:24 -05:00
|
|
|
#ifndef PLUGINUTILITY_H
|
|
|
|
|
#define PLUGINUTILITY_H
|
2012-06-13 07:42:55 -04:00
|
|
|
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
|
|
|
|
#include "icinga/checkable.hpp"
|
|
|
|
|
#include "icinga/checkcommand.hpp"
|
|
|
|
|
#include "icinga/macroprocessor.hpp"
|
2013-11-04 08:41:24 -05:00
|
|
|
#include <vector>
|
2013-03-16 16:18:53 -04:00
|
|
|
|
2012-06-13 07:42:55 -04:00
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
2014-05-11 11:14:35 -04:00
|
|
|
struct ProcessResult;
|
|
|
|
|
|
2012-09-17 07:35:55 -04:00
|
|
|
/**
|
2013-11-04 08:41:24 -05:00
|
|
|
* Utility functions for plugin-based checks.
|
2012-09-17 07:35:55 -04:00
|
|
|
*
|
|
|
|
|
* @ingroup icinga
|
|
|
|
|
*/
|
2017-12-31 01:22:16 -05:00
|
|
|
class PluginUtility
|
2012-06-13 07:42:55 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2023-03-31 06:38:24 -04:00
|
|
|
static void ExecuteCommand(const Command::Ptr& commandObj,
|
2017-12-19 09:50:05 -05:00
|
|
|
const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
|
2018-09-28 08:32:57 -04:00
|
|
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int timeout,
|
2017-12-19 09:50:05 -05:00
|
|
|
const std::function<void(const Value& commandLine, const ProcessResult&)>& callback = std::function<void(const Value& commandLine, const ProcessResult&)>());
|
2014-04-26 07:16:08 -04:00
|
|
|
|
2013-01-22 06:05:36 -05:00
|
|
|
static ServiceState ExitStatusToState(int exitStatus);
|
2014-09-07 06:27:06 -04:00
|
|
|
static std::pair<String, String> ParseCheckOutput(const String& output);
|
2013-01-22 06:05:36 -05:00
|
|
|
|
2014-09-17 09:38:39 -04:00
|
|
|
static Array::Ptr SplitPerfdata(const String& perfdata);
|
2021-05-11 10:47:03 -04:00
|
|
|
static String FormatPerfdata(const Array::Ptr& perfdata, bool normalize = false);
|
2013-11-07 07:37:58 -05:00
|
|
|
|
2012-06-13 07:42:55 -04:00
|
|
|
private:
|
2018-01-03 22:25:35 -05:00
|
|
|
PluginUtility();
|
2012-06-13 07:42:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 08:41:24 -05:00
|
|
|
#endif /* PLUGINUTILITY_H */
|