8.2.2 Monitoring Usage of System Resources

You need to collect and monitor system resources regularly to provide you with a continuous record of a system. Establish a baseline of acceptable measurements under typical operating conditions. You can then use the baseline as a reference point to make it easier to identify memory shortages, spikes in resource usage, and other problems when they occur. Monitoring system performance also allows you to plan for future growth and to see how configuration changes might affect future performance.

To run a monitoring command every interval seconds in real time and watch its output change, use the watch command. For example, the following command runs the mpstat command once per second:

# watch -n interval mpstat

Alternatively, many of the commands allow you to specify the sampling interval in seconds, for example:

# mpstat interval

If installed, the sar command records statistics every 10 minutes while the system is running and retains this information for every day of the current month. The following command displays all the statistics that sar recorded for day DD of the current month:

# sar -A -f /var/log/sa/saDD

To run sar command as a background process and collect data in a file that you can display later by using the -f option:

# sar -o datafile interval count >/dev/null 2>&1 &

where count is the number of samples to record.

Oracle OSWatcher Black Box (OSWbb) and OSWbb analyzer (OSWbba) are useful tools for collecting and analysing performance statistics. For more information, see Section 8.2.4, “About OSWatcher Black Box”.