2012-07-09 20:32:02 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2018-10-18 09:27:04 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
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
|
|
|
|
*/
|
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);
|
|
|
|
static String FormatPerfdata(const Array::Ptr& perfdata);
|
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 */
|