Solved

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

Posted on 2012-03-13
4
184 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

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
@SBGen Method 3 38
JDeveloper 12c for 32 bit 4 71
AWS and Java and Rest - newbie question (Is this an authentication issue) 4 68
maven project error 5 48
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 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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

920 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