Forums Register Login

How to get process related information as shown in Task Manager in java

+Pie Number of slices to send: Send
Hi,

I want to get process related information as seen in Task Manager for windows. When process name is passed to my API, it should return a map consisting of following keys and values which will be dynamic according to process name. Example when I pass OUTLOOK.EXE to my API then it should return.

ImageName: Outlook.exe
PID: 1234
Username: xyz
CPU: 03%
Mem Usage: 22532K
Handles: 2141
Threads: 12

I was able to retrive the information upto Mem Usage through Runtime.exec("tasklist") and then parsing the output. Can some one guide me to retrive information for handles and threads. I will prefer not to use JNI.


Thanks
+Pie Number of slices to send: Send
Tasklist supports flags. Type tasklist/? on your command prompt to view them.
You can run the command with the appropriate flags, parse the output and retrieve the required values.
e.g. On my system right now Outlook's PID is 3572.
If I use tasklist /FI "PID eq 3572" I get the details for outlook.exe
Notice the quotes in the above command.
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:Tasklist supports flags. Type tasklist/? on your command prompt to view them.
You can run the command with the appropriate flags, parse the output and retrieve the required values.
e.g. On my system right now Outlook's PID is 3572.
If I use tasklist /FI "PID eq 3572" I get the details for outlook.exe
Notice the quotes in the above command.



This does not give any information regarding Handles and Threads. Need guidance how to get them.
+Pie Number of slices to send: Send
rubbery bacon. rubbery tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3628 times.
Similar Threads
CPU usage and memory usage by processes
What could still be running after threads return?
WebServer's process management
Memory Leak using System.arraycopy?
java program problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:16:31.