new blog 2.0


0x0C. [LPIC-301] Capacity Planning - Measure Resource Usage

In this section we focus on measurement tools, in particular on the sysstat suite by Sebastien Godard.

I presume you are familiar with the /proc/cpuinfo file already. This information is static. How to obtain a dynamic info about CPU I/O?

iostatAccording to it's man page, iostat reports CPU statistics and I/O statistics for devices and partitions. In it's basic for iostat output looks like this:

100% of the CPU load is split into 6 categories as presented on the picture. Below a block device, sda, and statistics for it: transfers per second, block reads per second, block writes per second, total block reads, total block writes. Go to iostat man page for more information.

mpstat reports all CPU related statistics. Its output is similar to iostat's with the main difference being much preciser CPU stats (mstat is able to show info for every processor alone) and no information about other devices at all.
vmstat reports information about processes, memory, paging, block I/O, traps, and CPU activity. Basic vmstat output looks as follows:
You can specify a number of seconds (X) as a command line argument. If you do so, vmstat will show you average load since the last reboot as the first line (like above) and consecutive lines will be generated every X seconds and will report average stats for the last X-seconds period. You can find a some more comprehensive information on what can be read from the reports in the vmstat man page, "field description for vm mode" section.

This utility is more sophisticated than the previous programs from sysstat suite. sar is a command-line front-end to sadc program, which collects data at specific intervals (you can add data collection to crontab). In order to collect data, you can use two shellscripts sa1 and sa2, wrappers around sadc. Configuration of the tool is described at The following picture shows the how my two processors performed during one second:

Other, helpful tools include { pstree, w, lsof, top, uptime }. Refer to their man pages for more info.

How to ... ?
- Measure CPU usage
  • you can fire up 'uptime'. It gives you a one line of information: current time, time since the last reboot, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. If the load over the for the three values is consecutively decreasing, it means we may be in trouble. If the values increase from left to right it means that things are getting less and less CPU load. Usually good news.
  • iostat discloses instantaneous information about the average CPU load on all processors and some block I/O info, which can be connected to each other.
  • In order to get some more detailed info about the CPU, run mpstat, if you prefer with the "-P <processor_nr>" option in order to see info specific for one of the processors. (cat /proc/cpuinfo to see the amount of processors)
- Measure memory usage
  • vmstat would be the right pick for that purpose. According to the man page, it shows memory information in the following sections you:
    swpd: the amount of virtual memory used.
    free: the amount of idle memory.
    buff: the amount of memory used as buffers.
    cache: the amount of memory used as cache.
    inact: the amount of inactive memory. (-a option)
    active: the amount of active memory. (-a option)
- Measure disk I/O
  • vm in vmstat stands virtual memory and for this one it's intended. You can, however measure disk"vmstat -d" or "vmstat -p <partition_name>"
- Measure network I/O
  • "sar 1 -n DEV" does the trick. It will show you stats for network interfaces in received/transferred packets/compressed packets/bytes per second, as well as multicast packets per sec.
- Measure firewalling and routing throughput
  • sar?
- Map client bandwidth usage
  • sar?
Some good reference:

No comments: