Most Linux system administrators are familiar with
sar for collecting system status data. However, there's a few ways that
sar shows its age and doesn't quite live up to expectations. If you're looking for a newer utility that also handles NFS, Slab data and sub-second intervals, collectl may better fit the bill.
The collectl utility was written by Mark Seger, and it is dual-licensed under the Artistic License and GNU General Public License (GPL). It's written in Perl and does a bit more than just read from
/proc and copy data to the terminal.
Basically, collectl collects system data that reflects the system status/performance. If you're familiar with sar, you'll be right at home with collectl. If you've never used sar or a similar tool, here's a quick example running
collectl -s cn:
#<--------CPU--------><----------Network----------> #cpu sys inter ctxsw KBIn PktIn KBOut PktOut 16 8 619 733 0 0 0 0 24 8 773 1164 0 0 0 0 18 3 925 1261 11 14 2 14 20 4 812 1031 4 4 1 4 8 2 577 847 1 5 1 5 25 10 1103 1481 18 33 5 39 44 13 1879 2076 225 224 21 154 18 5 1057 1525 93 97 12 77 11 2 672 1040 7 6 1 6 36 13 1048 986 6 19 4 18 20 5 975 1385 27 34 7 31 54 16 1484 1280 12 22 5 21
As you can see, the
-s cn tells collectl "read the CPU and network subsystem data." By default, in interactive mode
collectl will read and display data every second. You can crank that up with the
-i interval option if you want. It can make data grabbable as frequent as every quarter of a second. Note that you'll also need the Time:HiRes Perl module. This might be installed by default. Check
collectl -v to be sure.
Collectl has an interactive mode, playback mode, record mode, socket mode and plot mode. Interactive is pretty self-explanatory. The record mode saves to a file for use later -- and you can use the playback mode to replay the data. The plot format saves data in a delimiter separated format that can be used with plotting utilities so you can graph system performance data. Finally, the socket mode directs collectl to send its data to a port specified with the
Why would you want to use collectl instead of sar? For one thing, collectl is supposed to have very low overhead. The author claims it's been measured to use less than 0.1 percent when run as a daemon -- although this may not hold for systems with massive numbers of disks and running processes.
It also handles things that sar doesn't, like Lustre file systems and Infiniband interconnects. As mentioned already, collectl has finer-grained monitoring intervals, so you can snarf data below the 1 second interval if you really must.
You can also control the format collectl uses to export data, if the default ones don't work for you for some reason. And it has support (experimental) for temperature and fan sensors.
If you monitor systems on a regular basis, check out collectl. It's not yet packaged for Ubuntu and just recently made it into Debian (so expect it for Debian Wheezy), but it's available for Fedora and openSUSE (Factory, at least -- haven't checked 11.4 yet) already. The most recent release came out in May, and you can grab an RPM or source on SourceForge.
Joe 'Zonker' Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at email@example.com and follow him on Twitter.