• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bob Edward
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maneesh Godbole
Saloon Keeper
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bob Edward
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article may help.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic