• 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

CPU and memeory utilization

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic