Scala 2.12
import java.lang.management.{ManagementFactory, PlatformManagedObject}
import javax.management.{MBeanInfo, ObjectName}
import scala.collection.JavaConverters._
val mbeanInterfaces: Seq[Class[_ <: PlatformManagedObject]] = ManagementFactory.getPlatformManagementInterfaces.asScala.toSeq
val mbeanObjects: Seq[_ <: PlatformManagedObject] = mbeanInterfaces.flatMap(ManagementFactory.getPlatformMXBeans(_).asScala.toSeq)
val mbeanObjectNames: Seq[ObjectName] = mbeanObjects.map(_.getObjectName)
val mbeanInfos: Seq[MBeanInfo] = mbeanObjectNames.map(ManagementFactory.getPlatformMBeanServer.getMBeanInfo(_))
Get information via MBeanServer
(ManagementFactory.getPlatformMBeanServer
) using MBeanInfo
and ʻObjectName`.
Recommended Posts