This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 41597
    
  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: 41597
    
  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: 41597
    
  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.
 
Don't get me started about those stupid light bulbs.
 
subject: Reading values from Task manager