I would like to monitor the following system information in Java:
Available d
Make a batch file "Pc.bat" as, typeperf -sc 1 "\mukit\processor(_Total)\%% Processor Time"
You can use the class MProcess,
/* *Md. Mukit Hasan *CSE-JU,35 **/ import java.io.*;public class MProcessor {
public MProcessor() { String s; try { Process ps = Runtime.getRuntime().exec("Pc.bat"); BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream())); while((s = br.readLine()) != null) { System.out.println(s); } } catch( Exception ex ) { System.out.println(ex.toString()); } }
}
Then after some string manipulation, you get the CPU use. You can use the same process for other tasks.
--Mukit Hasan