• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CPU and memeory utilization

 
deepak carter
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible, have a look at the java.lang.management package
 
deepak carter
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12102
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Paul Clapham
Sheriff
Posts: 20992
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add i wanna do health check of whole server not just particular apps.

Thanks in advance
 
Paul Clapham
Sheriff
Posts: 20992
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic