Use hostname if fqdn is empty for NodeName.

Refs #6393
This commit is contained in:
Michael Friedrich 2014-06-04 11:29:29 +02:00
parent 63df43eea2
commit 1d048462a2
1 changed files with 14 additions and 1 deletions

View File

@ -45,7 +45,20 @@ void IcingaApplication::StaticInitialize(void)
ScriptVariable::Set("EnableHostChecks", true);
ScriptVariable::Set("EnableServiceChecks", true);
ScriptVariable::Set("EnablePerfdata", true);
ScriptVariable::Set("NodeName", Utility::GetFQDN());
String node_name = Utility::GetFQDN();
if (node_name.IsEmpty()) {
Log(LogNotice, "IcingaApplication", "No FQDN available. Trying Hostname.");
node_name = Utility::GetHostName();
if (node_name.IsEmpty()) {
Log(LogWarning, "IcingaApplication", "No FQDN nor Hostname available. Setting Nodename to 'localhost'.");
node_name = "localhost";
}
}
ScriptVariable::Set("NodeName", node_name);
}
REGISTER_STATSFUNCTION(IcingaApplicationStats, &IcingaApplication::StatsFunc);