Continuous system-performance monitoring with commands

The vmstat, iostat, netstat, and sar commands provide the basic foundation upon which you can construct a performance-monitoring mechanism.

You can write shell scripts to perform data reduction on the command output, warn of performance problems, or record data on the status of a system when a problem is occurring. For example, a shell script can test the CPU idle percentage for zero, a saturated condition, and execute another shell script for when the CPU-saturated condition occurred. The following script records the 15 active processes that consumed the most CPU time other than the processes owned by the user of the script:

# ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15