• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get CPU and Memory idle values using Java?

 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I want to measure the Memory and CPU utilization of over App Server.

I decided to write a Thread in java that will be activated after each 15 min.

Now my problem is that, how to get CUP and Memory idle value at the given point of time using Java?

Reg,
Chetan
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, if you are looking for system data, it is not available directly from the JVM. If I remember correctly, you might be able to get free memory, but even that, I don't think is free memory at an OS level.

The easiest way to get the info is to do a system exec to the appropriate OS command and parse the results. For Unix, the command is "vmstat", or examining the "/proc" file system. For Windows, the command is "typeperf".

Henry
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Taken from Henry Wong post:
Unfortunately, if you are looking for system data, it is not available directly from the JVM. If I remember correctly, you might be able to get free memory, but even that, I don't think is free memory at an OS level.



I assume that you are touching on the situation prior to J2SE 1.5

Yes the java.lang.management package is the answer, that has been introduced in Tiger.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/package-summary.html

Good starting point is to play with jConsole:

http://java.sun.com/j2se/1.5.0/docs/guide/management/

HTH,
Arjun K
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for useful link
 
reply
    Bookmark Topic Watch Topic
  • New Topic