]> granicus.if.org Git - icinga2/commitdiff
Use hostname if fqdn is empty for NodeName.
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 4 Jun 2014 09:29:29 +0000 (11:29 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 4 Jun 2014 09:29:29 +0000 (11:29 +0200)
Refs #6393

lib/icinga/icingaapplication.cpp

index 9d428cb0931c1a1dd57ae2669905c0456fee00c3..de8ee47e652462b205ae494af1740cb1d7047e6b 100644 (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);