Skip to main content
LPIC-2 Exam 201

LPIC-2 201 200.1 Measure and Troubleshoot Resource Usage

Weight 6
Description Candidates should be able to measure hardware resource and network bandwidth, identify and troubleshoot resource problems.

Key Knowledge Areas:

  • Measure CPU usage.LPIC-2-201
  • Measure memory usage.
  • Measure disk I/O.
  • Measure network I/O.
  • Measure firewalling and routing throughput.
  • Map client bandwidth usage.
  • Match / correlate system symptoms with likely problems.
  • Estimate throughput and identify bottlenecks in a system including networking.

The following is a partial list of the used files, terms and utilities:

  • iostat
  • vmstat
  • netstat
  • pstree, ps
  • w
  • lsof
  • top
  • uptime
  • sar
  • swap
  • processes blocked on I/O
  • blocks in
  • blocks out

This is a new objective added in November 2013 and is important to the exam, we see a weight of 6, so you can expect 6 questions on this during your exam; but also this is important in managing your server or desktop on a day to day basis. We need to be able analyze the performance of the system and especially any areas where performance seems slow and we will need to rectify.

SYSSTAT

Many of the tools come from the sysstat package. Not the double s in the middle. On CentOS this can be installed with:

yum install sysstat

On Debian based systems like Ubuntu this can be installed with:

apt-get install sysstat

If we want data collection to take place regularly, which is normal with sysstat then we shall need to enable this in cron. On CentOS the the cron files are added to /etc/cron.d/sysstat and run the collection script sa1 every 10 minutes by default and the summary script sa2 once a day.

To read collected information we can use the command /usr/bin/sar. If you have only just installed sysstat there will be no information available but with 30 minutes then there should have been 3 collection intervals that have passed, assuming collection is every 10 minutes. The collected information is stored in the log files : /var/log/sa/sa<daynumber>; where day number is 1 through to 31 represent that day of month. By default only 28 days of logs are maintained so no clash of name will occur. This can be controlled using the file: /etc/sysconfig/sysstat. If a value of greater than 28 days is used then sub-directories will be created to represent the month.

Running the command sar without any options is equivalent to running :

sar -s 07:00:00 -u -f /var/log/sa/sa<currentday>

Where:

  • -s is the start time expressed in hh:mm:ss
  • -u display the CPU load
  • -f indicates the log file t read from: for example /var/log/sa/sa20 if the day is the 20th.

Of course we can use the -f option to choose different day files to read from and if we need to read specific times we can use -s and -e to specify the start and end times. All times must be in the format hh:mm:ss.

Other options for sar (other than the -u to read the CPU load):

  • -r  Memory usage
  • -S  Swap usage
  • -q Load averages

The sysstat package will also provide access to commands like vmstat, mpstat and pidstat, looking at memory, processor and pid statistic receptively, although on Debian based systsn vmstat is supplied via the standard procps package.

The basic syntax for the program usage is

program interval count

Which in real terms relates to an example:

vmstat 10 5

Where we run vmstat 5 times with a 10 second interval between each running.

Other tools exist that can help you gain performance information on your system and perhaps detect a sub-standard NIC, Network Interface Card.

netstat -s

Will display detailed information about the packets received and transmitted for TCP, UDP, IP, ICMP etc

netstat -i

Well display receive and transmit details on a per interface basis.