Probe disk performance (MRTG)

The hdparam can be used to monitor the throughput speed of a hard disk:
# <strong>hdparm -tT /dev/hda</strong>
/dev/hda:
Timing buffer-cache reads: 888 MB in 2.00 seconds = 444.00 MB/sec
Timing buffered disk reads: 20 MB in 3.30 seconds = 6.06 MB/sec

This would be an interesting performance metric to see plotted against time. So let’s convert it to a format ready for MRTG.

  • The only numbers we need are the last ones: resulting speed. This can be parsed from the output as follows:
    #hdparm -tT /dev/hda | gawk -F = "/seconds/ { print $2}" 

    440.00 MB/sec   3.30 MB/sec
  • if we could suppose that the results will always be in “MB/sec”, we could parse out the numbers with
    (...) | gawk "{print $1}"
    and then add a line to our MRTG config files to adjust the units:
    kMG[_]: M,G,T,P,X
    But let’s say that KB/sec or GB/sec speeds are possible.
  • One gawk can do the conversion trick:
    #(...) | gawk "/GB/ {print $1*1000000000} /MB/ {print $1*1000000} /KB/ {print $1*1000}" 

    440000000 3300000
  • To have a complete MRTG-ready output, we also add the boot time on line 3 and the name of the MRTG output on line 4
  • Q: Do we need 2 gawks one after the other? Can’t one do it?
    A: You could do it in 1, I guess, but the parsing would be more complex. I use 2 because the FS (field separator) changes: the first gawk uses the ‘=’ character, the second uses the normal whitespace.
  • del.icio.us
  • digg
  • Reddit
  • Facebook
  • FriendFeed

Related posts:

  1. Probe average cpu utilisation (MRTG) There are two main tools to keep track of your...
  2. Calculate hit rate from a log file You have a huge file that contains one line per...
  3. Date formatting in GAWK: boot time I have one server with apparently an exceptional stability: #...
  4. Convert Bind DNS zone into PTR records The following script I made in order to convert the...
  5. Perl HTML scraping part #1 Here we are, back at the scene of the crime....

0 Response to “Probe disk performance (MRTG)”


  • No Comments

Leave a Reply