1 /******************************************************************************
3 * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
23 #include "methods/nullchecktask.hpp"
24 #include "icinga/perfdatavalue.hpp"
25 #include "icinga/icingaapplication.hpp"
26 #include "base/utility.hpp"
27 #include "base/convert.hpp"
28 #include "base/function.hpp"
29 #include "base/logger.hpp"
31 using namespace icinga;
33 REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
35 void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
36 const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
38 if (resolvedMacros && !useResolvedMacros)
41 String output = "Hello from ";
42 output += IcingaApplication::GetInstance()->GetNodeName();
44 Array::Ptr perfdata = new Array();
45 perfdata->Add(new PerfdataValue("time", Convert::ToDouble(Utility::GetTime())));
47 cr->SetOutput(output);
48 cr->SetPerformanceData(perfdata);
49 cr->SetState(ServiceOK);
51 service->ProcessCheckResult(cr);