Solved

Is there good API to take the system resource all around , like linux / windows / Itanium / Solaris

Posted on 2012-03-13
4
180 Views
Last Modified: 2012-03-14
Is there good API to take the system resource all around , like linux / windows / Itanium / Solaris.

I want to know the status of the resource all around the platforms.

used memory / cpu / top process like that.

Please recommend me the good API .
No matter commercial or not

Thanks in advance
0
Comment
Question by:gamjaradio
  • 3
4 Comments
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 500 total points
ID: 37718498
This is about memory:

http://stackoverflow.com/questions/74674/how-to-do-i-check-cpu-and-memory-usage-in-java

  Runtime runtime = Runtime.getRuntime();

    NumberFormat format = NumberFormat.getInstance();

    StringBuilder sb = new StringBuilder();
    long maxMemory = runtime.maxMemory();
    long allocatedMemory = runtime.totalMemory();
    long freeMemory = runtime.freeMemory();

    sb.append("free memory: " + format.format(freeMemory / 1024) + "<br/>");
    sb.append("allocated memory: " + format.format(allocatedMemory / 1024) + "<br/>");
    sb.append("max memory: " + format.format(maxMemory / 1024) + "<br/>");
    sb.append("total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + "<br/>")

Open in new window

0
 

Author Comment

by:gamjaradio
ID: 37718502
actually I want know cpu percent per process.

like this

PID          used cpu percent
23122          20%
1920            30%
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 500 total points
ID: 37718503
I don't think you can have fully system indpednent way to list top processes
these are some examples:
http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37718508
I don't think you can get top processes in system indepdnednt way
You can use Runtime.getRuntime().exec(...) and use specific commands for the system
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

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

13 Experts available now in Live!

Get 1:1 Help Now