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:
parent
abf4b5afbb
commit
73f0610abf
|
|
@ -34,23 +34,22 @@ import io.Source
|
||||||
*/
|
*/
|
||||||
object SystemUtils {
|
object SystemUtils {
|
||||||
val inetAddress = InetAddress.getLocalHost.getHostAddress
|
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 mailName = {
|
||||||
val mailnameFile = new File("/etc/mailname")
|
val mailnameFile = new File("/etc/mailname")
|
||||||
if (mailnameFile.exists)
|
if (mailnameFile.exists)
|
||||||
Source.fromFile(mailnameFile).mkString.trim
|
Source.fromFile(mailnameFile).mkString.trim
|
||||||
else if (hostName == inetAddress)
|
|
||||||
inetAddress
|
|
||||||
else
|
else
|
||||||
hostName.split('.').takeRight(2).mkString(".")
|
hostName.split('.').takeRight(2).mkString(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
val pidAtHost = {
|
val pidAtHost = ManagementFactory.getRuntimeMXBean.getName.split('.').head
|
||||||
val mxBeanName = ManagementFactory.getRuntimeMXBean.getName
|
|
||||||
if (hostName == inetAddress)
|
|
||||||
mxBeanName
|
|
||||||
else
|
|
||||||
mxBeanName.split('.').head
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue