Solved

Reading CPU, Memory and Thread utilization in java

Posted on 2004-08-25
12
414 Views
Last Modified: 2010-05-19
hi,
i need to read cpu utilization,memory utilization and threads of java application. I need to read this information through java programming. can anyone help me out?
Thanks in advance
Mahesh
0
Comment
Question by:MMaheshwaran
12 Comments
 
LVL 5

Accepted Solution

by:
TrekkyLeaper earned 64 total points
ID: 11891410
If you're using UNIX, you can try parsing the results of a ps command. Otherwise, I think you will have to use some native code to do this.
0
 
LVL 12

Assisted Solution

by:Giant2
Giant2 earned 62 total points
ID: 11891448
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 62 total points
ID: 11891450
You can only find info about the memory that is allocated to the JVM by the OS.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MMaheshwaran
ID: 11891903
i need it in windows 2000. i have explored some of the java profiling agent. It makes use of JVMPI to read resource utilization(  JFluid Netbeans plugin ). is it possible to use JVMPI to read this information?

mahesh
0
 
LVL 35

Expert Comment

by:girionis
ID: 11892001
I am not sure. But for any memory or process utilization you want to do *outside* the JVM you will need to use native code.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11899904
See the link I posted before!
I believe it could be interesting for you.
(I point at a code in JNI doing what you want).
http://www.codeguru.com/Cpp/misc/misc/assemblylanguage/article.php/c3847/

Bye, Giant.
0
 

Assisted Solution

by:brosouille
brosouille earned 62 total points
ID: 11901713
-Memory
Use java.lang.Runtime

-Thread
In a file thread.jsp

<pre>
<%
            ThreadGroup tg = Thread.currentThread().getThreadGroup();
            while (tg.getParent() != null) {
                  tg = tg.getParent();            
            }
      
            Thread threads[] = new Thread[5000];
            tg.enumerate(threads,true);

            for(int i = 0 ; i < threads.length ;i++) {

                  Thread t = threads[i];
                  if (null != t) {
                        String name = t.getName();
                        int pri = t.getPriority();
                        String group = t.getThreadGroup().getName();
                        out.println("thread '" +name+"' of ["+group+"] ; prior "+pri+" alive="+t.isAlive()+" interrupted="+t.isInterrupted()+" daemon="+t.isDaemon());
                  }
            }

%>

0
 
LVL 12

Expert Comment

by:Giant2
ID: 12256364
I think a split or a delete.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12256649
I think the question is already answered so a split woudl be nice :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 49
Problem to Alipay 10 70
Eclipse for Java EE development 2 43
American Express @Work site and Java 4 64
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question