Solved

Reading CPU, Memory and Thread utilization in java

Posted on 2004-08-25
12
410 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ForLoop Example 3 40
factorial example 4 34
Way to decrease size of apk file 9 42
Opening PDF on button click and fill new document 2 16
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now