<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Occasionally Coherent]]></provider_name><provider_url><![CDATA[http://blog.bimajority.org]]></provider_url><author_name><![CDATA[Garrett Wollman]]></author_name><author_url><![CDATA[https://blog.bimajority.org/author/garrettwollman/]]></author_url><title><![CDATA[An addendum to the findslowdisks DTrace&nbsp;hack]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>In <a href="http://blog.bimajority.org/2013/10/29/my-first-well-ok-third-dtrace-hack/">the previous installment</a>, I posted a script that will output a series of lines that look like this:</p>
<pre>multipath/s33d7: 417.3 ms &gt; 372.9 ms
multipath/s25d22: 682.9 ms &gt; 372.9 ms
multipath/s29d5: 699.2 ms &gt; 372.9 ms
multipath/s25d4: 1449.1 ms &gt; 372.9 ms</pre>
<p>every five seconds.  If you leave it running for a while, and DTrace doesn&#8217;t report any warnings, you&#8217;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&#8217;t to me (other than the top one or two).  So a way to further summarize this data is desirable.</p>
<p>My first step, as it usually is, was to paste the output into an Emacs buffer and then sort it with <code>M-x sort-lines</code>.  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 <code>shell-command-on-region</code> (<code>M-|</code>) with <code>uniq</code>, 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 <code>shell-command-on-region</code> (which works for vi users too, although I have no idea what particular obscure key sequence the Left Coast Editor requires):</p>
<pre>cut -d: -f1 | uniq -c | sort -n</pre>
<p>This produces a nice summary of a minute&#8217;s worth of <code>findslowdisks</code> output:</p>
<pre>   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</pre>
]]></html></oembed>