FreeBSD - Monitor geom disk i/o statistics using gstat/iostat
Many utilities are out there to measure I/O throughput statistics on disk. FreeBSD has a tool named "gstat". Man gstat:
Quote:
GSTAT(8) FreeBSD System Manager's Manual GSTAT(8)
NAME
gstat -- print statistics about GEOM disks
SYNOPSIS
gstat [-abcd] [-f filter] [-I interval]
DESCRIPTION
The gstat utility can be used to monitor I/O transactions of geom(4)
devices.
The options are as follows:
-a Only display providers that are at least 0.1% busy.
-b Batch mode. Collect numbers, print and exit. Default if stdout
is not a tty.
-c Enable display of geom(4) consumers too. The default is to show
statistics only for geom(4) producers.
-d Enable display of statistics for delete (BIO_DELETE) operations.
-f filter
A regular expression that can be used to only show statistics for
some devices. Only devices with the names matching filter will
be displayed. The format of the regular expression is described
in re_format(7).
-I interval
Refresh the gstat display every interval microseconds. Adding a
suffix of s, ms, or us (the default) indicates that the update
interval is specified in seconds, milliseconds, or microseconds,
respectively.
EXIT STATUS
The gstat utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
systat(1), geom(4), iostat(8), vmstat(8)
HISTORY
A gstat utility appeared in FreeBSD 5.0.
FreeBSD 9.2 March 12, 2009 FreeBSD 9.2
Sample output:
Code:
dT: 1.001s w: 1.000s
L(q) ops/s r/s kBps ms/r w/s kBps ms/w %busy Name
0 0 0 0 0.0 0 0 0.0 0.0| cd0
0 4518 4518 22666 0.4 0 0 0.0 79.6| da0
0 0 0 0 0.0 0 0 0.0 0.0| da0p1
0 0 0 0 0.0 0 0 0.0 0.0| da0p2
0 0 0 0 0.0 0 0 0.0 0.0| da0p3
0 4518 4518 22666 0.4 0 0 0.0 80.4| da0p4
0 0 0 0 0.0 0 0 0.0 0.0| gptid/152a4263-976f-11e1-bbdb-000c29d7775d
3 137 1 32 38.9 136 16937 67.5 93.3| da1
0 0 0 0 0.0 0 0 0.0 0.0| da1p1
0 0 0 0 0.0 0 0 0.0 0.0| ufsid/53146e31cacae381
0 0 0 0 0.0 0 0 0.0 0.0| gpt/boot
0 0 0 0 0.0 0 0 0.0 0.0| gptid/99d31bb2-a2cb-11e3-843e-000c29d7775d
0 0 0 0 0.0 0 0 0.0 0.0| da1p2
0 0 0 0 0.0 0 0 0.0 0.0| gpt/rootfs
0 0 0 0 0.0 0 0 0.0 0.0| da1p3
0 0 0 0 0.0 0 0 0.0 0.0| gpt/swap
0 0 0 0 0.0 0 0 0.0 0.0| gptid/a460fe55-a2cb-11e3-843e-000c29d7775d
3 137 1 32 38.9 136 16937 67.5 93.3| da1p4
3 137 1 32 38.9 136 16937 67.5 93.3| gpt/storage
The second tool is "iostat". Man:
Quote:
IOSTAT(8) FreeBSD System Manager's Manual IOSTAT(8)
NAME
iostat -- report I/O statistics
SYNOPSIS
iostat [-CdhIKoTxz?] [-c count] [-M core] [-n devs] [-N system] [-t
type,if,pass] [-w wait] [drives]
DESCRIPTION
The iostat utility displays kernel I/O statistics on terminal, device and
cpu operations. The first statistics that are printed are averaged over
the system uptime. To get information about the current activity, a
suitable wait time should be specified, so that the subsequent sets of
printed statistics will be averaged over that time.
The options are as follows:
-c Repeat the display count times. If no repeat count is specified,
the default depends on whether -w is specified. With -w the
default repeat count is infinity, otherwise it is 1.
-C Display CPU statistics. This is on by default, unless -d or -x is
specified.
-d Display only device statistics. If this flag is turned on, only
device statistics will be displayed, unless -C or -T is also speci-
fied to enable the display of CPU or TTY statistics.
-h Put iostat in `top' mode. In this mode, iostat will show devices
in order from highest to lowest bytes per measurement cycle.
-I Display total statistics for a given time period, rather than aver-
age statistics for each second during that time period.
-K In the blocks transferred display (-o), display block count in
kilobytes rather then the device native block size.
-M Extract values associated with the name list from the specified
core instead of the default ``/dev/kmem''.
-n Display up to devs number of devices. The iostat utility will dis-
play fewer devices if there are not devs devices present.
-N Extract the name list from the specified system instead of the
default ``/boot/kernel/kernel''.
-o Display old-style iostat device statistics. Sectors per second,
transfers per second, and milliseconds per seek are displayed. If
-I is specified, total blocks/sectors, total transfers, and mil-
liseconds per seek are displayed.
"iostat" command to show I/O statistics per disk with 1sec interval:
Code:
# iostat -dxz 1
extended device statistics
device r/s w/s kr/s kw/s qlen svc_t %b
da0 100.3 2.9 1049.1 256.0 3 5.3 5
da1 0.2 3.9 1.5 364.8 1 15.8 1
extended device statistics
device r/s w/s kr/s kw/s qlen svc_t %b
da0 11726.0 1.0 58811.4 0.5 2 0.2 99
da1 0.0 353.3 0.0 45219.3 1 0.8 28
extended device statistics
device r/s w/s kr/s kw/s qlen svc_t %b
da0 11947.1 2.0 59881.6 128.4 2 0.2 99
da1 0.0 359.7 0.0 46038.2 1 0.8 28