mirror of https://github.com/Icinga/icinga2.git
parent
14d7ee2777
commit
91901eafd8
|
@ -41,6 +41,7 @@ set(icinga_SOURCES
|
|||
customvarobject.cpp customvarobject.hpp customvarobject-ti.hpp
|
||||
dependency.cpp dependency.hpp dependency-ti.hpp dependency-apply.cpp
|
||||
downtime.cpp downtime.hpp downtime-ti.hpp
|
||||
envresolver.cpp envresolver.hpp
|
||||
eventcommand.cpp eventcommand.hpp eventcommand-ti.hpp
|
||||
externalcommandprocessor.cpp externalcommandprocessor.hpp
|
||||
host.cpp host.hpp host-ti.hpp
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */
|
||||
|
||||
#include "base/string.hpp"
|
||||
#include "base/value.hpp"
|
||||
#include "icinga/envresolver.hpp"
|
||||
#include "icinga/checkresult.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
bool EnvResolver::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *result) const
|
||||
{
|
||||
auto value (getenv(macro.CStr()));
|
||||
|
||||
if (value) {
|
||||
*result = value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */
|
||||
|
||||
#ifndef ENVRESOLVER_H
|
||||
#define ENVRESOLVER_H
|
||||
|
||||
#include "base/object.hpp"
|
||||
#include "base/string.hpp"
|
||||
#include "base/value.hpp"
|
||||
#include "icinga/macroresolver.hpp"
|
||||
#include "icinga/checkresult.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Resolves env var names.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class EnvResolver final : public Object, public MacroResolver
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(EnvResolver);
|
||||
|
||||
bool ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *result) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ENVRESOLVER_H */
|
Loading…
Reference in New Issue