I need to get the CPU usage fro a particular process from java code in LINUX.
I tried
Process p = Runtime.getRuntime().exec("top");
or
Process p = Runtime.getRuntime().exec("top | grep java");
But It's not returning any thing. Actually I want to get the CPU usages of several JBOSS nodes. If I can "top" or something inside the java code then I can process the out put an find the details that I want.
But if I try
Process p = Runtime.getRuntime().exec("ls -l");
Its returning the out put correctly.
Is there I can do like this or are there any other options to do this?
thanks.