2012-07-16 09:10:42 -04:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Icinga 2 *
|
2015-01-22 06:00:23 -05:00
|
|
|
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
2012-07-16 09:10:42 -04: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-10-03 14:33:32 -04:00
|
|
|
#ifndef _WIN32
|
2013-10-24 01:38:29 -04:00
|
|
|
# include <stdlib.h>
|
|
|
|
|
#endif /* _WIN32 */
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "methods/nullchecktask.hpp"
|
2014-09-17 09:38:39 -04:00
|
|
|
#include "icinga/perfdatavalue.hpp"
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "base/utility.hpp"
|
|
|
|
|
#include "base/convert.hpp"
|
2015-01-21 02:47:45 -05:00
|
|
|
#include "base/function.hpp"
|
2014-10-19 08:21:12 -04:00
|
|
|
#include "base/logger.hpp"
|
2012-07-16 09:10:42 -04:00
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
2013-03-25 13:36:15 -04:00
|
|
|
REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
|
2013-01-22 03:21:50 -05:00
|
|
|
|
2014-11-13 05:23:57 -05:00
|
|
|
void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
|
|
|
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
2012-07-16 09:10:42 -04:00
|
|
|
{
|
2014-12-01 07:19:07 -05:00
|
|
|
if (resolvedMacros && !useResolvedMacros)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-09-12 04:36:50 -04:00
|
|
|
String output = "Hello from ";
|
2014-05-27 06:53:41 -04:00
|
|
|
output += Utility::GetFQDN();
|
2013-11-07 08:38:37 -05:00
|
|
|
|
2014-11-08 15:17:16 -05:00
|
|
|
Array::Ptr perfdata = new Array();
|
|
|
|
|
perfdata->Add(new PerfdataValue("time", Convert::ToDouble(Utility::GetTime())));
|
2013-09-12 04:36:50 -04:00
|
|
|
|
2013-11-09 08:22:38 -05:00
|
|
|
cr->SetOutput(output);
|
|
|
|
|
cr->SetPerformanceData(perfdata);
|
2014-04-08 03:11:54 -04:00
|
|
|
cr->SetState(ServiceOK);
|
2012-07-16 09:10:42 -04:00
|
|
|
|
2014-03-12 05:05:36 -04:00
|
|
|
service->ProcessCheckResult(cr);
|
2012-07-16 09:10:42 -04:00
|
|
|
}
|