Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes CPU and memeory utilization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "CPU and memeory utilization" Watch "CPU and memeory utilization" New topic
Author

CPU and memeory utilization

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
HI,

I dont kow whether uts possible or not however just ante to ask whether its possible to write a program in java that can calculate CPU and memory utilization.
Alistair J MacDonald
Greenhorn

Joined: Jul 15, 2011
Posts: 8
Yes it is possible, have a look at the java.lang.management package
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
i need to write a program to get the cpu and memory usage from the server so that if the cpu or memory exceeds the threshold we can get a alert and can act to it accordingly.

can you guide me through means where should i start from and what all things i need to take care etc etc


Thanks in advance
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

The first thing you should always do is figure out what you are trying to do. for example:

What would the thresholds be? Will they need to change throughout the day?
How do you want to be alerted - email? phone call? pop-up window somewhere?

Don't write a single line of code until you think through these at minimum.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Following on from what Fred said, you will also want to improve on the level of detail in your requirements statement. For example you want to look at "the cpu and memory usage". Would that be the CPU and memory usage of a specific application, or of the whole server?
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Hi ALL

thanks for your reply.

I am looking for a program which can tell what is the current cpu and memory usage and i want thses alerts in mail...Can this be work out.The plan is in place and its time to implement it.
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Just to add i wanna do health check of whole server not just particular apps.

Thanks in advance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It's not likely you can do that in Java. In my opinion you're better off buying a commercial monitoring package for whatever operating system you had in mind.
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
i was looking at management pack in java.lang but i was unable to find any info which can help me..where should i particulary look to get extact thing what i need.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
Java tools like JConsole and VisualVM can get this data from remote servers via JMX, so an all-Java solution likely exists. I suggest to start reading up on JMX; you should be able to find articles and example code for that on Oracle's site.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CPU and memeory utilization
 
Similar Threads
How to see the utilization in oracle
XML Parsing and Validation with SAX parser shoots CPU to 100% utilization
Java mechanism to get remote server details
cpu utilization
Threadcount vs Memory size/CPU utilization