This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread 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 Java 8 in Action this week in the Java 8 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: 39577
    
  27
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 - updated with new look and Ping home screen widget
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: 39577
    
  27
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: 39577
    
  27
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
 
Similar Threads
How to hide Widget from the task manager application
Idle java application eating memory
Windows XP/NT help -- vmstat functionality
Memory Problem
JVM - Reducing number of CPUs..