When getCanonicalHostName fails use getHostName instead of getHostAddress as it's more compatible with our mail servers.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5553 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kshakir 2011-04-01 20:26:26 +00:00
parent abf4b5afbb
commit 73f0610abf
1 changed files with 9 additions and 10 deletions

View File

@ -34,23 +34,22 @@ import io.Source
*/
object SystemUtils {
val inetAddress = InetAddress.getLocalHost.getHostAddress
val hostName = InetAddress.getLocalHost.getCanonicalHostName
val canonicalHostName = InetAddress.getLocalHost.getCanonicalHostName
val hostName = {
if (canonicalHostName != inetAddress)
canonicalHostName
else
InetAddress.getLocalHost.getHostName
}
val mailName = {
val mailnameFile = new File("/etc/mailname")
if (mailnameFile.exists)
Source.fromFile(mailnameFile).mkString.trim
else if (hostName == inetAddress)
inetAddress
else
hostName.split('.').takeRight(2).mkString(".")
}
val pidAtHost = {
val mxBeanName = ManagementFactory.getRuntimeMXBean.getName
if (hostName == inetAddress)
mxBeanName
else
mxBeanName.split('.').head
}
val pidAtHost = ManagementFactory.getRuntimeMXBean.getName.split('.').head
}