]> granicus.if.org Git - icinga2/blob - lib/icinga/pluginutility.hpp
Merge pull request #7164 from Icinga/bugfix/notification-times-validate
[icinga2] / lib / icinga / pluginutility.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef PLUGINUTILITY_H
4 #define PLUGINUTILITY_H
5
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/checkable.hpp"
8 #include "icinga/checkcommand.hpp"
9 #include "icinga/macroprocessor.hpp"
10 #include <vector>
11
12 namespace icinga
13 {
14
15 struct ProcessResult;
16
17 /**
18  * Utility functions for plugin-based checks.
19  *
20  * @ingroup icinga
21  */
22 class PluginUtility
23 {
24 public:
25         static void ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
26                 const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
27                 const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int timeout,
28                 const std::function<void(const Value& commandLine, const ProcessResult&)>& callback = std::function<void(const Value& commandLine, const ProcessResult&)>());
29
30         static ServiceState ExitStatusToState(int exitStatus);
31         static std::pair<String, String> ParseCheckOutput(const String& output);
32
33         static Array::Ptr SplitPerfdata(const String& perfdata);
34         static String FormatPerfdata(const Array::Ptr& perfdata);
35
36 private:
37         PluginUtility();
38 };
39
40 }
41
42 #endif /* PLUGINUTILITY_H */