Created
September 7, 2018 07:44
-
-
Save fsarradin/28c282bb93cfd6c273753be9e35ef622 to your computer and use it in GitHub Desktop.
Getting some system information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.management.ManagementFactory | |
import java.net.{InetAddress, NetworkInterface} | |
object Main { | |
import scala.collection.JavaConverters._ | |
def main(args: Array[String]): Unit = { | |
val localHost = InetAddress.getLocalHost | |
println(localHost) | |
println("host name: " + localHost.getHostName) | |
println("canonical host name: " + localHost.getCanonicalHostName) | |
println("host address: " + localHost.getHostAddress) | |
println() | |
val networkInterface = NetworkInterface.getByInetAddress(localHost) | |
println(networkInterface) | |
println("name: " + networkInterface.getName) | |
println("display name: " + networkInterface.getDisplayName) | |
println("index: " + networkInterface.getIndex) | |
println("parent: " + networkInterface.getParent) | |
println("hardware address: " + networkInterface.getHardwareAddress.map("%02x" format _).mkString(":")) | |
println() | |
val os = ManagementFactory.getOperatingSystemMXBean | |
println("processors: " + os.getAvailableProcessors) | |
println("os arch: " + os.getArch) | |
println("os name: " + os.getName) | |
println("os version: " + os.getVersion) | |
val runtime = ManagementFactory.getRuntimeMXBean | |
println("runtime name: " + runtime.getName) | |
println("runtime pid: " + runtime.getPid) | |
println("runtime input args: " + runtime.getInputArguments.asScala) | |
println("runtime uptime: " + runtime.getUptime) | |
println("runtime VM name: " + runtime.getVmName) | |
println("runtime VM vendor: " + runtime.getVmVendor) | |
println("runtime VM version: " + runtime.getVmVersion) | |
println("runtime spec name: " + runtime.getSpecName) | |
println("runtime spec vendor: " + runtime.getSpecVendor) | |
println("runtime spec version: " + runtime.getSpecVersion) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment