1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "methods/nullchecktask.hpp"
7 #include "icinga/icingaapplication.hpp"
8 #include "base/utility.hpp"
9 #include "base/perfdatavalue.hpp"
10 #include "base/convert.hpp"
11 #include "base/function.hpp"
12 #include "base/logger.hpp"
14 using namespace icinga;
16 REGISTER_FUNCTION_NONCONST(Internal, NullCheck, &NullCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
18 void NullCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
19 const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
21 REQUIRE_NOT_NULL(checkable);
24 if (resolvedMacros && !useResolvedMacros)
27 String output = "Hello from ";
28 output += IcingaApplication::GetInstance()->GetNodeName();
30 cr->SetOutput(output);
31 cr->SetPerformanceData(new Array({
32 new PerfdataValue("time", Convert::ToDouble(Utility::GetTime()))
34 cr->SetState(ServiceOK);
36 checkable->ProcessCheckResult(cr);