A while back I wrote a blog entry showing how to get tape drives statistics with systemtap. This script wasn’t very reliable and I would frequently see it crash after collecting just a few samples. Due to the work of some amazing Linux kernel engineers I no longer have to touch systemtap. Recent Linux kernels now expose a number of incredibly useful statistics through the /sys file system:
$ pwd
/sys/class/scsi_tape/nst0/stats
$ ls -l
total 0
-r--r--r-- 1 root root 4096 Oct 10 16:15 in_flight
-r--r--r-- 1 root root 4096 Oct 10 16:15 io_ns
-r--r--r-- 1 root root 4096 Oct 10 16:15 other_cnt
-r--r--r-- 1 root root 4096 Oct 10 15:30 read_byte_cnt
-r--r--r-- 1 root root 4096 Oct 10 15:30 read_cnt
-r--r--r-- 1 root root 4096 Oct 10 16:15 read_ns
-r--r--r-- 1 root root 4096 Oct 10 16:15 resid_cnt
-r--r--r-- 1 root root 4096 Oct 10 15:30 write_byte_cnt
-r--r--r-- 1 root root 4096 Oct 10 15:30 write_cnt
-r--r--r-- 1 root root 4096 Oct 10 16:15 write_ns
There is also a tapestats utility in the syststat package that can be used to summarize these statistics:
$ tapestat -z 1
Linux 2.6.32-642.1.1.el6.x86_64 (wolfie) 10/10/2016 _x86_64_ (24 CPU)
Tape: r/s w/s kB_read/s kB_wrtn/s %Rd %Wr %Oa Rs/s Ot/s
st0 0 370 0 94899 0 22 22 0 0
st1 0 367 0 93971 0 18 19 0 0
st2 0 315 0 80885 0 19 19 0 0
st3 0 27 0 6979 0 1 1 0 0
Tape: r/s w/s kB_read/s kB_wrtn/s %Rd %Wr %Oa Rs/s Ot/s
st0 0 648 0 165888 0 30 30 0 0
st2 0 362 0 92928 0 17 17 0 0
This is a useful addition and I no longer have to worry about systemtap croaking when I’m tracking down issues.