Topic 200: Capacity Planning

0
1734

Capacity Planning is the first topic of the LPIC-2 exam 201-405 It covers the following objectives as described in LPIC-2 Exam 201-405 Objectives.

  • Measure and Troubleshoot Resource Usage
  • Predict Future Resource Needs

In order to meet the first objectives, the following utilities are covered.

iostat

The iostat command is used to report the CPU as well as input/output statistics for devices and partitions since last system boot (run without options).

The command syntax is:

iostat [options] [interval [count] ]
  • The interval parameter specifies the amount of time in seconds between each report.
  • The count parameter value if specified, determines the number of reports generated at interval seconds apart.
  • If the interval parameter is specified without the count parameter, the iostat command generates reports continuously one after the other at a specified interval.

When run with options, the first report generated provides statistics concerning the time since the system was booted, unless the -y option is used which omits the first report is used. Each subsequent report covers the time since the previous report.

Example usage

The following examples shows various usage of the iostat command.

Display a single history since boot report for all CPU and Devices
# iostat
Linux 4.13.0-45-generic (amos.kifarunix.com) 10/010/2018 _x86_64_ (4 CPU)

avg-cpu: %user  %nice  %system %iowait %steal %idle
          25.28  0.16   24.14   1.47    0.00   48.95

Device: tps kB_read/s kB_wrtn/s   kB_read  kB_wrtn
loop0  0.00      0.00      0.00        10        0
sda   19.16    529.02    228.60 195214314 84355231
dm-0  23.23    527.04    228.60 194483308 84355111
dm-1  22.97    527.03    228.60 194480588 84355111
dm-2   0.00      0.01      0.00      2228        0
Display the CPU utilization report
# iostat -c
Linux 4.13.0-45-generic (amos.kifarunix.com) 10/10/2018 _x86_64_ (4 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
          30.11 0.08   14.58    1.22   0.00 54.00
Display the device utilization report
# iostat -d
Linux 4.13.0-45-generic (amos.kifarunix.com) 10/10/2018 _x86_64_ (4 CPU)

Device: tps kB_read/s kB_wrtn/s  kB_read kB_wrtn
loop0  0.00      0.00      0.00        5       0
sda   17.42    656.11     98.36 58722778 8802927
dm-0  20.90    654.51     98.35 58579258 8802847
dm-1  20.65    654.48     98.35 58576538 8802847
dm-2   0.00      0.02      0.00     2228       0
Display two reports at two second intervals for all devices
# iostat -d 2 2
Linux 4.13.0-45-generic (amos.kifarunix.com) 10/10/2018 _x86_64_ (4 CPU)

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
loop0  0.00      0.00      0.00       5       0
sda   17.36    653.10 98.15 58724182 8825475
dm-0  20.83    651.50 98.15 58580662 8825395
dm-1  20.58    651.47 98.15 58577942 8825395
dm-2   0.00      0.02 0.00      2228       0

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
loop0  0.00      0.00      0.00       0       0
sda    2.50      0.00     18.00       0      36
dm-0   5.00      0.00     18.00       0      36
dm-1   4.50      0.00     18.00       0      36
dm-2   0.00      0.00      0.00       0       0
Display two reports at two second intervals for device sda and all its partitions
# iostat -p 2 2
Linux 4.13.0-45-generic (amos.kifarunix.com) 10/10/2018 _x86_64_ (4 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
          29.27 0.07   14.15    1.19   0.00 55.31

Device: tps kB_read/s kB_wrtn/s  kB_read kB_wrtn
loop0  0.00      0.00      0.00        5       0
sda   17.30    650.70     97.85 58724182 8830643
sda1   0.03      1.56      0.00   140990      80
sda2   0.00      0.00      0.00        2       0
sda5  17.01    649.11     97.85 58581086 8830563
dm-0  20.76    649.11     97.85 58580662 8830563
dm-1  20.51    649.08     97.85 58577942 8830563
dm-2   0.00      0.02      0.00     2228       0

avg-cpu: %user %nice %system %iowait %steal %idle
          3.02  0.00    2.02    0.13   0.00 94.84

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
loop0  0.00      0.00      0.00       0       0
sda   14.50      0.00     94.00       0     188
sda1   0.00      0.00      0.00       0       0
sda2   0.00      0.00      0.00       0       0
sda5  14.50      0.00     94.00       0     188
dm-0  16.00      0.00     94.00       0     188
dm-1  16.00      0.00     94.00       0     188
dm-2   0.00      0.00      0.00       0       0
Display LVM2 statistics.
# iostat -N
Linux 4.13.0-45-generic (mibeyki.silensec.com) 10/10/2018 _x86_64_ (4 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
          29.22 0.07   13.89    1.21   0.00 55.60

Device:          tps kB_read/s kB_wrtn/s  kB_read kB_wrtn
loop0           0.00      0.00      0.00        5       0
sda            17.33    653.54     99.28 59330566 9012683
sda5_crypt     20.81    651.96     99.28 59187046 9012603
ubuntu--vg-root 20.56   651.93     99.28 59184326 9012603
ubuntu--vg-swap_1  0.00   0.02      0.00     2228       0

For more description of options, check the man pages for iostat.

iotop

iotop is a simple top-like I/O monitoring utility. It watches I/O usage information output by the Linux kernel  and displays a table of current I/O usage by processes or threads on the system. In summary, iotop displays:

  • columns for the I/O bandwidth read and written by each process/thread during the sampling period.
  • the percentage of time the thread/process spent while swapping in and while waiting on I/O.
  • the total I/O bandwidth read and written during the sampling period is displayed at
    the top of the interface.

The iotop command syntax is:

iotop [OPTIONS]

For each process, its I/O priority (class/level) is shown.

Some of the commonly used iotop options are described below.

  • -o, –only – Shows the processes or threads that are actually doing I/O.
  • -b, –batch – Turn on non-interactive mode. Useful for logging I/O usage over time.
  • -n NUM, –iter=NUM – Sets the number of iterations before quitting (never quit by default). It is most useful in non-interactive mode.
  • -d SEC, –delay=SEC – Sets the delay between iterations in seconds (1 second by default). Accepts non-integer values such as 1.1 seconds.
  • -p PID, –pid=PID – A list of processes/threads to monitor (all by default).
  • -u USER, –user=USER – A list of users to monitor (all by default)
  • -P, –processes – Display processes only. Normally iotop shows all threads.
  • -a, –accumulated – Shows accumulated I/O instead of bandwidth. In this mode, iotop shows the amount of I/O processes have done since iotop started.
  • -k, –kilobytes – display all sizes in kilobytes.
  • -t, –time – Add a timestamp on each line. Each line will be prefixed by the current time.
  • -q, –quiet – suppress some lines of header. This option can be specified up to three times to remove header lines.
    • -q – column names are only printed on the first iteration
    • -qq – column names are never printed
    • -qqq – the I/O summary is never printed.

With iotop output, you can use;

  • the left and right arrows to change the sorting
  • r to reverse the sorting order
  • o to toggle the –only option
  • p to toggle the –processes option
  • a to toggle the –accumulated option
  • q to quit
  • i to change the priority of a thread or a process’ thread(s).
  • Any other key will force a refresh.

In its simplest form, when run with no options, it displays a list of running processes and their current disk I/O usage information.

# iotop

iotop

vmstat

vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu
activity. The reports are intended to help identify system bottlenecks. Linux vmstat does not count itself as a running process. All Linux blocks are currently 1024 bytes. Old kernels may report blocks as 512 bytes, 2048 bytes, or 4096 bytes.

The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.

The vmstat command syntax is:

vmstat [options] [delay [count]]
  • The delay value specifies the delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
  • The count value specifies the number of updates. In absence of count, when delay is defined, default is infinite.
  • Example:
$ vmstat 2 2
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 645800 169244 9668292    0    0   624    96   34  160 27 11 60  2  0
 0  0      0 643160 169244 9668288    0    0     0     0 1109 5644  7  4 89  0  0

Some of the vmstat options include;

  • -s, –stats – Displays a table of various event counters and memory statistics.
$ vmstat -s
     16320636 K total memory
      6288240 K used memory
      8262064 K active memory
      4722704 K inactive memory
       435856 K free memory
       177340 K buffer memory
      9419200 K swap cache
      8286204 K total swap
            0 K used swap
      8286204 K free swap
      3730414 non-nice user cpu ticks
         8082 nice user cpu ticks
      1508042 system cpu ticks
...output snipped...
  • -d, –disk – Reports disk statistics
$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
loop0      2      0      10       0      0      0       0       0      0      0
loop1      0      0       0       0      0      0       0       0      0      0
loop2      0      0       0       0      0      0       0       0      0      0
loop3      0      0       0       0      0      0       0       0      0      0
loop4      0      0       0       0      0      0       0       0      0      0
loop5      0      0       0       0      0      0       0       0      0      0
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
loop6      0      0       0       0      0      0       0       0      0      0
loop7      0      0       0       0      0      0       0       0      0      0
sda   1692580  50979 168982445 12303780 505953 369792 26419328 21207388      0   7499
dm-0  1741888      0 168695405 14835928 874372      0 26419168 50045308      0   7562
dm-1  1741680      0 168689965 14816996 845078      0 26419168 50046932      0   7569
dm-2      94      0    4456    4944      0      0       0       0      0      3
  • -D, –disk-sum – Summarizes disk statistics
# vmstat -D 
           12 disks 
            3 partitions 
      5167119 total reads
        49765 merged reads
    505893799 read sectors
     41886236 milli reading
      2218953 writes
       369161 merged writes
     78938326 written sectors
    121215228 milli writing
            0 inprogress IO
        22571 milli spent IO
  • -p, –partition <dev> – Reports partition specific statistics
# vmstat -p sda1
sda1          reads   read sectors  writes    requested writes
                2326     281980         11        160
  • -S, –unit <char> – Defines display unit (k, K, m, M)
# vmstat -S m
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0    562    181   9634    0    0   593    94   55  241 26 11 62  2  0
  • -t, –timestamp – Shows timestamp
vmstat -t
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- -----timestamp-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st                 EAT
 0  0      0 410224 177148 9421144    0    0   592    94   55  243 26 11 62  2  0 2018-10-10 13:42:11

Field Description for the Virtual Memory output.

Procs
    r: The number of runnable processes (running or waiting for run time).
    b: The number of processes in uninterruptible sleep.
Memory
    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)
Swap
    si: Amount of memory swapped in from disk (/s).
    so: Amount of memory swapped to disk (/s).
IO
    bi: Blocks received from a block device (blocks/s).
    bo: Blocks sent to a block device (blocks/s).
System
    in: The number of interrupts per second, including the clock.
    cs: The number of context switches per second.
CPU
    These are percentages of total CPU time.
    us: Time spent running non-kernel code.  (user time, including nice time)
    sy: Time spent running kernel code.  (system time)
    id: Time spent idle.
    wa: Time spent waiting for IO.
    st: Time stolen from a virtual machine.

netstat

Netstat command prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

The netstat command syntax is:

netstat {arguments} [options]

The type of information printed by netstat is controlled by the first argument passed. The command arguments and options include;

Netstat Arguments:

  • (none)
    By default, netstat displays a list of open sockets. If you don’t specify any address families, then the active sockets of all configured address families will be printed.
  • –route , -r
    Display the kernel routing tables. See the description in route(8) for details. netstat -r and route -e produce the same output except that later requires elevated privileges.
  • –groups , -g
    Display multicast group membership information for IPv4 and IPv6.
  • –interfaces, -i
    Display a table of all network interfaces.
  • –masquerade , -M
    Display a list of masqueraded connections.
  • –statistics , -s
    Display summary statistics for each protocol.

Netstat Options:

  • -p, –program
    Show the PID and name of the program to which each socket belongs.
  • -l, –listening
    Show only listening sockets. (These are omitted by default.)
  • -a, –all
    Show both listening and non-listening sockets. With the –interfaces option, show interfaces that are not up
  • –protocol={inet,unix,ipx,ax25,netrom,ddp} , -A
    Specifies the address families for which connections are to be shown. The address family is inet includes raw, udp and tcp protocol sockets.
  • –numeric , -n
    Show numerical addresses instead of trying to determine symbolic host, port or user names

Check the netstat man pages for a comprehensive list of options.

Some of the example usage for netstat include the following:

List all listening UDP/TCP ports and programs using those ports

# netstat -altup

ss

The ss command is used to show socket statistics. It can display stats for PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix domain sockets, and more. It shows information similar to the netstat command, but it can display more TCP and state information.

The command syntax is:

 ss [options] [ FILTER ]

When run with no option, ss displays a list of open non-listening sockets (e.g. TCP/UNIX/UDP) that have established connection.

Some of the commonly used options include:

  • -n, –numeric – Do not try to resolve service names.
  • -r, –resolve – Try to resolve numeric address/ports.
  • -a, –all – Display both listening and non-listening (for TCP this means established connections) sockets.
  • -l, –listening – Display only listening sockets (these are omitted by default).
  • -o, –options – Show timer information.
  • -e, –extended – Show detailed socket information
  • -m, –memory – Show socket memory usage.
  • -p, –processes – Show process using socket.
  • -t, –tcp – Display TCP sockets.
  • -u, –udp – Display UDP sockets.
  • -d, –dccp – Display DCCP sockets.
  • -w, –raw – Display RAW sockets.
  • -x, –unix – Display Unix domain sockets (alias for -f unix).

Check man ss for a comprehensice list of options.

Examples;

Display all TCP sockets.
ss -at
Display all UDP sockets.
ss -au
Display all established ssh connections.
ss -o state established '( dport = :ssh or sport = :ssh )'
Find all local processes connected to X server.
ss -x src /tmp/.X11-unix/*

iptraf

iptraf is an ncurses-based IP LAN monitor that generates various network statistics including TCP info, UDP counts, ICMP and OSPF information, Ethernet load info, node stats, IP checksum errors, and others.

The command syntax is:

iptraf-ng [options]
iptraf-ng { [ -f ] [ -q ] [ -u ] [ { -i iface | -g | -d iface | -s iface | -z iface | -l iface } [ -t timeout ] [ -B [ -L logfile ] ] ] | [ -h ] }

If the iptraf command is issued without any command-line options, the program comes up in interactive mode, with the various facilities accessed through the main menu.

# iptraf-ng

iptraf ng

For a detailed information on options, see the man pages for iptraf/iptraf-ng.

Some of the command line examples:

Start the IP traffic monitor (use ‘-i all’ for all interfaces)
# iptraf-ng -i enp0s3
Start the detailed statistics facility on an interface
# iptraf-ng -d enp0s3
Start the TCP and UDP monitor on an interface
# iptraf-ng -s enp0s3
Start the IP traffic monitor (use ‘-i all’ for all interfaces)
# iptraf-ng -l enp0s3
Start the general interface statistics
# iptraf-ng -g

ps

ps displays information about a selection of the active processes. ps accepts several kinds of options:

1 UNIX options, which may be grouped and must be preceded by a dash eg ps -aux
2 BSD options, which may be grouped and must not be used with a dash eg ps aux
3 GNU long options, which are preceded by two dashes.

In the example shown above, ps -aux is distinct from ps aux in that:

  • ps -aux prints all processes owned by a user named “x”, as well as printing all processes that would be selected by the -a option.
  • ps aux prints all processes on the system

See the man pages for the ps command a comprehensive list of options and their description.

pstree

pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is
omitted. If a user name is specified, all process trees rooted at processes owned by that user
are shown.

The command syntax is:

pstree [options] [pid|username]

Exmples:

Display the owner of a process
# pstree -u
systemd─┬─ModemManager───2*[{ModemManager}]
        ├─NetworkManager───2*[{NetworkManager}]
        ├─2*[VBoxClient(amos)───VBoxClient───{VBoxClient}]
        ├─VBoxClient(amos)───VBoxClient
        ├─VBoxClient(amos)───VBoxClient───2*[{VBoxClient}]
        ├─VBoxService───7*[{VBoxService}]
        ├─accounts-daemon───2*[{accounts-daemon}]
        ├─acpid
        ├─avahi-daemon(avahi)───avahi-daemon
        ├─boltd───2*[{boltd}]
        ├─clamd(clamav)───{clamd}
        ├─colord(colord)───2*[{colord}]
        ├─cron
        ├─cups-browsed───2*[{cups-browsed}]
        ├─cupsd
        ├─dbus-daemon(messagebus)
        ├─freshclam(clamav)
        ├─fwupd───4*[{fwupd}]
...output snipped...
Display PIDs of processes
# pstree -p
systemd(1)─┬─ModemManager(977)─┬─{ModemManager}(1011)
           │                   └─{ModemManager}(1013)
           ├─NetworkManager(969)─┬─{NetworkManager}(1016)
           │                     └─{NetworkManager}(1018)
           ├─VBoxClient(1857)───VBoxClient(1858)───{VBoxClient}(1880)
           ├─VBoxClient(1867)───VBoxClient(1868)
           ├─VBoxClient(1872)───VBoxClient(1873)───{VBoxClient}(1886)
           ├─VBoxClient(1877)───VBoxClient(1878)─┬─{VBoxClient}(1882)
           │                                     └─{VBoxClient}(1884)
           ├─VBoxService(1281)─┬─{VBoxService}(1283)
           │                   ├─{VBoxService}(1284)
           │                   ├─{VBoxService}(1285)
           │                   ├─{VBoxService}(1286)
           │                   ├─{VBoxService}(1287)
           │                   ├─{VBoxService}(1288)
           │                   └─{VBoxService}(1289)
           ├─accounts-daemon(929)─┬─{accounts-daemon}(966)
           │                      └─{accounts-daemon}(970)
           ├─acpid(972)
           ├─avahi-daemon(915)───avahi-daemon(916)
...output snipped...

See the man pages for pstree for a detailed description of the command options.

w

w displays information about the users currently on the machine, and their processes. The
header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU, PCPU, and the command line of their current process.

The JCPU time is the time used by all processes attached to the tty. It does not include past
background jobs, but does include currently running background jobs.

The PCPU time is the time used by the current process, named in the “what” field.

The command usage syntax is:

w [options] [user]

Check the w man pages for a comprehensive list of options.

# w
 16:26:35 up  4:27,  4 users,  load average: 0.13, 0.18, 0.13
USER     TTY      FROM             [email protected]   IDLE   JCPU   PCPU WHAT
amos     :0       :0               12:02   ?xdm?   3:52   0.01s /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
root     pts/2    192.168.43.149   16:24    2:03   0.04s  0.00s tmux -u -2 -f /usr/share/byobu/profiles/tmuxrc new-session -n - /usr/bin/byobu-shell
root     pts/3    tmux(2977).%1    16:24    2:03   0.61s  0.60s top
amos     pts/4    192.168.43.63    16:26   11.00s  0.09s  0.05s vim /etc/hosts

lsof

lsof command lists on its standard output file information about files opened by processes. An open file may be a regular file, a directory, a block special file, a character special file,
an executing text reference, a library, a stream or a network file (Internet socket, NFS file or
UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

The command usage syntax is:

lsof [options] [names]

Consult the man  pages for a detailed description of options and their usage.

Example usage:

List all open files

# lsof

List all files opened by a specific user

# lsof -u amos

List all processes using a specific port

# lsof -i TCP:80

List all commands being used by user

# lsof -i -u amos

free

free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo.

The command line syntax is:

free [options]

Example usage

free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        7.0G        1.3G        485M        7.3G        7.7G
Swap:          7.9G          0B        7.9G

The displayed columns are:

  • total – Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
  • used – Used memory (calculated as total – free – buffers – cache)
  • free – Unused memory (MemFree and SwapFree in /proc/meminfo)
  • shared – Memory used (mostly) by tmpfs (Shmem in /proc/meminfo, available on kernels 2.6.32, displayed as zero if not available)
  • buffers – Memory used by kernel buffers (Buffers in /proc/meminfo)
  • cache – Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo)
  • buff/cache – Sum of buffers and cache
  • available – Estimation of how much memory is available for starting new applications, without swapping

top

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel.

The command syntax is:

top -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols]

The traditional switches `-‘ and whitespace are optional.
See the man pages for a comprehensive description of the options used.

Example usage;

# top

top

htop

Htop is a free ncurses-based process viewer for Linux. It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines, as well as viewing them as a process tree, selecting multiple processes and acting on them all at once.

Tasks related to processes (killing, renicing) can be done without entering their PIDs.

The command syntax is:

 htop [options]

See the man pages for a description of the options used.

In its simplest usage, just run the command without options.

# htop

htop

uptime

uptime gives a one line display of the following information:

  • The current time
  • how long the system has been running
  • how many users are currently logged o
  • the system load averages for the past 1, 5, and 15 minutes.

This is the same information contained in the header line displayed by w.

The command syntax is:

uptime [options]

In its simplest usage, just run the command without options

# uptime
 17:27:51 up 1 day,  8:32,  6 users,  load average: 0.85, 1.00, 0.99

System load averages is the average number of processes that are either in a runnable or uninterruptable state.

  • A process in a runnable state is either using the CPU or waiting to use the CPU.
  • A process in uninterruptable state is waiting for some I/O access, eg waiting for disk.

The averages are taken over the three time intervals. Load averages are not normalized for the number of CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.

sar

sar program collects, reports, or saves system activity information.

  • It writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval
    parameters, writes information the specified number of times spaced at the specified intervals in seconds.
  • If the interval parameter is set to zero, the sar command displays the average statistics for the time since the system was started.
  • If the interval parameter is specified without the count parameter, then reports are generated continuously.
  • The collected data can also be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen.
  • If filename is omitted, sar uses the standard system activity daily data file. Standard system activity daily data files are named saDD or saYYYYMMDD, where YYYY stands for the current year, MM for the current month and DD for the current day.

See the man pages for sar for more detailed description

The command syntax is:

sar [options] [interval [count] ]

Examples;

Report I/O and transfer rate statistics.

# sar -b 2 2
Linux 4.15.0-20-generic (amos.example.com) 	10/10/2018 	_x86_64_	(2 CPU)

 5:44:51          tps      rtps      wtps   bread/s   bwrtn/s
 5:44:53         0.50      0.50      0.00     16.00      0.00
 5:44:55         0.00      0.00      0.00      0.00      0.00
Average:         0.25      0.25      0.00      8.00      0.00

Report activity for each block device

# sar -d 1 1
Linux 4.15.0-20-generic (amos.example.com) 	10/10/2018 	_x86_64_	(2 CPU)

 5:47:20          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
 5:47:21       dev7-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 5:47:21       dev7-1      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 5:47:21       dev7-2      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
Average:       dev7-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:       dev7-1      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:       dev7-2      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

To wrap up this objective, the measurements obtained from the above utilities can be correlated in order to identify deviant behaviors of your systems.

Any problem relating to resource usage usually affects the user experience and can be easily identified by unavailability of a resource or a service e.g slow response of a we application. You have compare the defiant behavior to the normal system behavior to unearth what is causing abnormality.

The second objective of this chapter aims at ensuring that you are able to predict future system resource needs. In order to realize this, use monitoring tools such as collected, Nagios, Zabix, Icinga, Cacti or even MRTG to measure, collect and display resource performance statistics.

These statistics can then be used to analyze and graph performance data over a period of time which gives you ability to create effective baselines and compare current performance to the baselines. As a result, you can determine how resource consumption on the server varies over time. This helps you to predict when certain amount of resources will be required to to cope with the demand during certain circumstances.

LEAVE A REPLY

Please enter your comment!
Please enter your name here