Solved

Reading CPU, Memory and Thread utilization in java

Posted on 2004-08-25
12
409 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 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

10 Experts available now in Live!

Get 1:1 Help Now