문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top