22 Ocak 2018 Pazartesi

JMX OperatingSystemMXBean Arayüzü

getObjectName metodu
Şöyle yaparız.
String[] attr={ "TotalPhysicalMemorySize", "FreePhysicalMemorySize",
                        "FreeSwapSpaceSize", "TotalSwapSpaceSize"};
OperatingSystemMXBean op = ManagementFactory.getOperatingSystemMXBean();
List<Attribute> al;
try {
  al = ManagementFactory.getPlatformMBeanServer()
    .getAttributes(op.getObjectName(), attr).asList();
} catch (InstanceNotFoundException | ReflectionException ex) {
  Logger.getLogger(ExtendedOsMxBeanAttr.class.getName())
    .log(Level.SEVERE, null, ex);
  al = Collections.emptyList();
}
for(Attribute a: al) {
  System.out.println(a.getName()+": "+a.getValue());
}

Hiç yorum yok:

Yorum Gönder