IcingaStatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state".
IcingaPidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to IcingaLocalStateDir + "/run/icinga2/icinga2.pid".
IcingaMacros |**Read-write.** Contains a dictionary with global macros. Not set by default.
+IcingaNodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
ApplicationType |**Read-write.** Contains the name of the Application type. Defaults to "icinga/IcingaApplication".
IcingaEnableNotifications |**Read-write.** Whether notifications are globally enabled. Defaults to true.
IcingaEnableEventHandlers |**Read-write.** Whether event handlers are globally enabled. Defaults to true.
return 0;
}
+String Utility::GetHostName(void)
+{
+ char name[255];
+
+ if (gethostname(name, sizeof(name)) < 0)
+ strcpy(name, "<unknown host>");
+
+ return String(name);
+}
+
int Utility::Random(void)
{
#ifdef _WIN32
static int Random(void);
+ static String GetHostName(void);
+
static tm LocalTime(time_t ts);
private:
ScriptVariable::Set("IcingaEnableFlapping", true);
ScriptVariable::Set("IcingaEnableChecks", true);
ScriptVariable::Set("IcingaEnablePerfdata", true);
+ ScriptVariable::Set("IcingaNodeName", Utility::GetHostName());
}
/**
return ScriptVariable::Get("IcingaMacros");
}
+String IcingaApplication::GetIcingaNodeName(void) const
+{
+ return ScriptVariable::Get("IcingaNodeName");
+}
+
bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
{
double now = Utility::GetTime();
String GetPidPath(void) const;
Dictionary::Ptr GetMacros(void) const;
+ String GetIcingaNodeName(void) const;
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
#include "methods/icingachecktask.h"
#include "icinga/cib.h"
#include "icinga/service.h"
+#include "icinga/icingaapplication.h"
#include "base/application.h"
#include "base/utility.h"
#include "base/scriptfunction.h"
cr->SetOutput("Icinga 2 is running.");
cr->SetPerformanceData(perfdata);
cr->SetState(StateOK);
+ cr->SetCheckSource(IcingaApplication::GetInstance()->GetIcingaNodeName());
return cr;
}
result->SetExitStatus(pr.ExitStatus);
result->SetExecutionStart(pr.ExecutionStart);
result->SetExecutionEnd(pr.ExecutionEnd);
+ result->SetCheckSource(IcingaApplication::GetInstance()->GetIcingaNodeName());
return result;
}
#ifndef _WIN32
# include <stdlib.h>
#endif /* _WIN32 */
+#include "icinga/icingaapplication.h"
#include "methods/randomchecktask.h"
#include "base/utility.h"
#include "base/convert.h"
cr->SetOutput(output);
cr->SetPerformanceData(perfdata);
cr->SetState(static_cast<ServiceState>(Utility::Random() % 4));
+ cr->SetCheckSource(IcingaApplication::GetInstance()->GetIcingaNodeName());
return cr;
}