Get OS-level system information

后端 未结 16 1803
情话喂你
情话喂你 2020-11-22 02:02

I\'m currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.

Has anyone been abl

16条回答
  •  梦毁少年i
    2020-11-22 02:31

    If you are using Jrockit VM then here is an other way of getting VM CPU usage. Runtime bean can also give you CPU load per processor. I have used this only on Red Hat Linux to observer Tomcat performance. You have to enable JMX remote in catalina.sh for this to work.

    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://my.tomcat.host:8080/jmxrmi");
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);     
    MBeanServerConnection conn = jmxc.getMBeanServerConnection();       
    ObjectName name = new ObjectName("oracle.jrockit.management:type=Runtime");
    Double jvmCpuLoad =(Double)conn.getAttribute(name, "VMGeneratedCPULoad");
    

提交回复
热议问题