Block devices are non volatile storage devices whose information can be accessed in any order. Hard disks, floppy disks, and CD-ROMs are examples of block devices. Block device reads from and writes to the device in blocks of different sizes. With block device as a hard disk we can read and write one block of data at a time. The commands blkiomon, blkparse, blkrawverify, blktrace are used in Linux distributions to work with block devices to check the performance and for monitoring purpose.
blkiomon:
blkiomon command is used for monitoring block devices I/O (input/output) operations periodically. It generates per device request size, request latency from blktrace data. With this data we can calculate minimum, maximum, average variance in the block devices performance.
Blkiomon command options with examples:
blkiomon utility generates every device request size, request latency, statistics from the output of blktrace command. With this blkiomon data we can calculate minimum, maximum, average variance. We need to use blkiomon command in with blktrace command as follows.
Note: Below commands will only work in root user and the user with sudo permission enabled.
blktrace /dev/sda -a issue -a complete -w 3600 -o - | blkiomon -I 10 -h –
With above command we can get I/O statistics for /dev/sdw for every 10 seconds for a period of one hour.
How to set time interval for polling trace data:
Use -I or –interval options with blkiomon command to poll the block devices trace data. With below command we can trace the block devices data for every 30 seconds for a period of 10 mins (mentioned as 600 secs with -w option in below command).
blktrace /dev/sda -a issue -a complete -w 600 -o - | blkiomon -I 30 -h -
How to redirect output to human readable file:
Use -h or –human-readable option to write the block devices monitoring data to human readable files. If we use – instead of file name then output will be displayed in standard output.
blktrace /dev/sda -a issue -a complete -w 600 -o - | blkiomon -I 30 -h output_data.txt
Below is the output for 30 secs for above command execution. Like this the output contains 20 iterations for 10 mins.
time: Tue Nov 22 08:07:44 2022
device: 8,0
sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0
sizes write (bytes): num 15, min 1024, max 32768, sum 211456, squ 3824418816, avg 14097.1, var 56233965.8
d2c read (usec): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0
d2c write (usec): num 15, min 147, max 328, sum 3472, squ 855230, avg 231.5, var 3438.5
throughput read (bytes/msec): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0
throughput write (bytes/msec): num 15, min 4633, max 111455, sum 932131, squ 73545740777, avg 62142.1, var 1041412935.5
sizes histogram (bytes):
0: 0 1024: 1 2048: 0 4096: 2
8192: 1 16384: 10 32768: 1 65536: 0
131072: 0 262144: 0 524288: 0 1048576: 0
2097152: 0 4194304: 0 8388608: 0 > 8388608: 0
d2c histogram (usec):
0: 0 8: 0 16: 0 32: 0
64: 0 128: 0 256: 10 512: 5
1024: 0 2048: 0 4096: 0 8192: 0
16384: 0 32768: 0 65536: 0 131072: 0
262144: 0 524288: 0 1048576: 0 2097152: 0
4194304: 0 8388608: 0 16777216: 0 33554432: 0
>33554432: 0
bidirectional requests: 0
How to write binary output of monitoring data to file:
We can generate the block monitoring data in binary format and redirect that output to a binary file. For that use -b or –binary option as below.
blktrace /dev/sda -a issue -a complete -w 600 -o - | blkiomon -I 30 -b binary_output_data.txt
The output for the above command is not human readable. It is in binary format written in the file mentioned in the command.
How to capture the monitoring data for low level device drivers:
Use -d or –dump-lldd option to store the monitoring data for low level device drivers.
blktrace /dev/sda -a issue -a complete -w 600 -o - | blkiomon -I 30 -d low_level_drivers_data.txt
How to capture debugging output for block devices monitoring:
For debug output for block devices monitoring use -D or –debug options. It will print all the debug logs in the output file.
blktrace /dev/sda -a issue -a complete -w 60 -o - | blkiomon -I 10 -D debug_output_drivers_data.txt
Below is the debug output of the above command execution.
--- mismatch ---
magic 1700885511 1700885511
sequence 1 15
time 6614498574862 6658083072021
sector 0 0
bytes 0 0
action 18a0008 18a0008
pid 0 0
device 8388608 8388608
cpu 0 0
error 0 0
pdu_len 0 0
order 2 19
--- leftover ---
magic 1700885511
sequence 15
time 6658083072021
sector 0
bytes 0
action 18a0008
pid 0
device 8388608
cpu 0
error 0
pdu_len 0
order 19
--- leftover ---
magic 1700885511
sequence 4
time 6614500290971
sector 124773763
bytes 0
action 118a0008
pid 0
device 8388608
cpu 0
error 0
pdu_len 0
order 6
How to set path name for message queue:
Use -Q or –msg-queue options to set path name as below.
blktrace /dev/sda -a issue -a complete -w 60 -o - | blkiomon -I 10 -Q /var/tmp/
How to set message queue id for block devices monitoring:
Use -q or –msg-queue-id options to set the message queue id for an existing message queue to be used for binary output
blktrace /dev/sda -a issue -a complete -w 60 -o - | blkiomon -I 10 -q 10
How to set message id for block devices monitoring:
Use -m or –msg-id options to set the message id for an existing message queue to be used for binary output
blktrace /dev/sda -a issue -a complete -w 60 -o - | blkiomon -I 10 -m 10
For more information about blkiomon command in Linux please check the manual page for blkiomon command.
See also: