Question

I need to monitor the CPU, N/w , memory and Disk I/O usage of a computer . Currently I'm using Ubuntu and will be running this using a Java code.

Also the monitoring frequency/ sampling interval must be customisable. I've already read this. There's no mention of network stats but for SIGAR API.

I'm looking at something lightweight. I'm having two things on my mind to do this:

  1. running a shell script from my java code which formats the o/p . If so, which command should I use? Top gave only the stats process wise.

  2. Use SIGAR API. but can the sampling rate be set?

Thanks!

Was it helpful?

Solution

You can install prstat, iostat, pidstat packages for linux and get all info using commandline. Use java's processbuilder to execute these commands in shell and capture the output in a file so that it can be used for future processing. A word of caution, writing continuously into the same file is not a good idea with these commands (control the info by specifying polling interval and number of polls using command' options).

Hope this helps.

PS: btw take a look at nagios.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top