wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Reading values from Task manager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Reading values from Task manager" Watch "Reading values from Task manager" New topic
Author

Reading values from Task manager

Neha Deshmukh
Ranch Hand

Joined: Apr 04, 2007
Posts: 30
Hi,
I want to read CPU Usage percentage from task manager in a file.
Can anybody tell me can we do this and if yes how to do this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
I take it you're running Windows. Some versions come with an executable called "typeperf", which can report CPU utilization. You can execute it using Runtime.exec or ProcessBuilder, and then parse the results.

Some other tools were mentioned in this thread, but I think none of those reports CPU percentages.
[ August 15, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Neha Deshmukh
Ranch Hand

Joined: Apr 04, 2007
Posts: 30
Hi,
Can you please tell me how to typeperf throght Runtime.exec.
I really don't know how to use Runtime.exec and typeperf so can you please help me in this matter?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
An introduction to Runtime.exe can be found in this article.

Running typeperf shouldn't present a problem, if it's available.
Neha Deshmukh
Ranch Hand

Joined: Apr 04, 2007
Posts: 30
Hi,
When I am trying to run typeperf through runtime.exec() it is giving error -
ejava.io.IOException: Cannot run program "typeperf": CreateProcess error=2, The
system cannot find the file specified.
I guess typeperf is not available on machine so can you suggest how to download or use it?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
As the thread linked above mentions, it's not part of all Windows versions. Microsoft's web site would be a good place to get some information about it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading values from Task manager