An addendum to the findslowdisks DTrace hack

In the previous installment, I posted a script that will output a series of lines that look like this:

multipath/s33d7: 417.3 ms > 372.9 ms
multipath/s25d22: 682.9 ms > 372.9 ms
multipath/s29d5: 699.2 ms > 372.9 ms
multipath/s25d4: 1449.1 ms > 372.9 ms

every five seconds. If you leave it running for a while, and DTrace doesn’t report any warnings, you’ll get a whole bunch of these, and it might not be obvious which slow disks are the most urgent to be replaced. Or at least, it wasn’t to me (other than the top one or two). So a way to further summarize this data is desirable.

My first step, as it usually is, was to paste the output into an Emacs buffer and then sort it with M-x sort-lines. Deleting the extraneous matter (shell prompts, blank lines, etc.) makes a somewhat more informative display, but not quite as summarized as I would like. So I hit upon using shell-command-on-region (M-|) with uniq, but of course the lines are already unique due to random variation in the reported service times, so a little bit more shell hacking would be necessary. I finally came up with the following pipeline for shell-command-on-region (which works for vi users too, although I have no idea what particular obscure key sequence the Left Coast Editor requires):

cut -d: -f1 | uniq -c | sort -n

This produces a nice summary of a minute’s worth of findslowdisks output:

   1 multipath/s29d22
   7 multipath/s25d18
   8 multipath/s21d7
   9 multipath/s29d21
   9 multipath/s29d5
  11 multipath/s25d12
  11 multipath/s25d4
  13 multipath/s33d7
  14 multipath/s25d22
Aside | This entry was posted in FreeBSD and tagged , , , . Bookmark the permalink.