Skip to content

iostat#

You'll see the term "I/O" or "IO" thrown around a lot. All it means is "Input/Output" and it generally refers to the process of putting data into or onto something or taking data from somewhere or off of something.

When we're talking about network interfaces I/O would mean the packets coming in (I) and the packets going out (O). With disks, it means bytes being written to (I) the disk and bytes being read (O) from the disk.

That's why iostat is called io and stat: input/output statistics. Let's run iostat:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
~$ iostat
Linux 5.4.0-1018-aws (develop)  04/02/22    _x86_64_    (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7.20    0.33    4.07    0.19    2.59   85.63

Device             tps    kB_read/s    kB_wrtn/s    kB_dscd/s    kB_read    kB_wrtn    kB_dscd
loop0             0.71         0.76         0.00         0.00      17372          0          0
loop1             0.07         0.09         0.00         0.00       1961          0          0
loop2             0.00         0.05         0.00         0.00       1077          0          0
loop3             0.25         0.26         0.00         0.00       5928          0          0
xvda              2.93        32.25       105.69         0.00     737806    2417688          0

It's funny how iostat also give us the CPU load average because a CPU is an I/O device. We'll ignore this though, as we've covered load averages previously.

Now we have rows representing the disks on this system. I only have one inside of this VM: xvda. We can safely ignore the loop devices.

Let's look at each column, above:

  • tps - transfers per second
  • kB_read/s - Kilobytes (B = bytes, b = bits) read from the device, per second
  • kB_wrtn/s - Kilobytes (B = bytes, b = bits) written to the device, per second
  • kB_dscd/s - Kilobytes (B = bytes, b = bits) disgarded, per second
  • kB_read - Kilobytes (B = bytes, b = bits) read from the device, total (since monitoring started)
  • kB_wrtn - Kilobytes (B = bytes, b = bits) written to the device, total
  • kB_dscd - - Kilobytes (B = bytes, b = bits) disgarded, total

So, we can see my primary device, xvda, is very idle. There are hardly any transactions per second, hardly anything being read from or written to the device at this moment in time. Let's change that by faking some disk activity.

I've generated a 20GiB file and then used rsync to transfer the file from one part of the disk to another part of the same disk (basically within the same file system on the disk):

1
2
Device             tps    kB_read/s    kB_wrtn/s    kB_dscd/s    kB_read    kB_wrtn    kB_dscd
xvda            665.00        52.00     83916.00         0.00         52      83916          0

Now we can see 665 transactions per second and we're writing 83,916 KiB per second. We're also reading it heavily too. This demonstrates the disk being heavily utilised. If I take a second snapshot moment later, I can see it's still being heavily utilised:'

1
2
Device             tps    MB_read/s    MB_wrtn/s    MB_dscd/s    MB_read    MB_wrtn    MB_dscd
xvda            682.00         0.27        81.95         0.00          0         81          0

This time I ran iostat with the -m flag so that it converted kilobytes (KB) to megabytes (MB). We're writing at a rate of 81.95 megabytes per second. That's pretty slow for a disk, but it's actually being limited by the underlaying provider: AWS Lightsail. They've me a limited amount of disk throughput to protect their infrastructure (and extract more money from me!)

That's a basically look at how measuring disk utilisation works. Simple.

Next#

Now we're going to move on to SSH: configuring it and using it.