Sunday, October 26, 2008

Super-quick Linux performance monitoring using top command

Need to have super quick system performance monitoring in Unix and don't have time to install even Nagios?

A one-line top command might do the trick:
top -b -n 672 -d 900 > top.log&
The above command will run top in the background (due to the ampersand, "&") 672 times (in this case 7 days) with a measurement interval of 900 seconds (15 minutes) and write the results to the file "top.log". On a system with low-to-moderate usage, this could produce a log file as small as under 7 MB. Adjust the inputs to your needs as necessary. If you want to predict the size of a log file in advance, you could just run a test like this beforehand:
top -b -n 1 > top.test.log
This syntax was tested in bash on openSUSE but should work in other contexts. The "-b" option runs the command in a batch mode.

The top command only tracks very basic system stats like CPU, memory usage, and swapped size, of course. If or when you have more time for deeper and better monitoring, you might try Nagios or even Hyperic.

No comments:

Copyright 2011 by William Cain