File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 41186
    
  45
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: 41186
    
  45
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: 41186
    
  45
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
 
Similar Threads
Windows XP/NT help -- vmstat functionality
JVM - Reducing number of CPUs..
Idle java application eating memory
Memory Problem
How to hide Widget from the task manager application