I’d like to monitor the CPU and memory usage of the whole system and not just the JVM.
Thanks for any help or source code.
Something like this should work, though it’s not guaranteed to work on every JVM:
>>> from java.lang.management import ManagementFactory >>> bean = ManagementFactory.getOperatingSystemMXBean() >>> print bean.getSystemCpuLoad() * 100.0
I check but it doesn’t work it seems it only return JVM CPU usage.
I find some code but I cant make it work in igniton. Could you please help me on that.
import com.sun.management.OperatingSystemMXBean OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); # What % CPU load this current JVM is taking, from 0.0-1.0 print osBean.getProcessCpuLoad() # What % load the overall system is at, from 0.0-1.0 System.out.println(osBean.getSystemCpuLoad());
The code I posted is the same thing but already converted to Jython and should work in Ignition…