[TriLUG] Other ways to get to iostat data?

Joseph Mack NA3T jmack at wm7d.net
Thu Jun 2 10:22:38 EDT 2011


On Thu, 2 Jun 2011, Jason Watts wrote:

> its a 2.4 kernel.  Thanks for the info.  its what I need, just need to
> figure out how to get what I need out of it.

Splicing out some of my code (let me know if some bits are missing).

Joe
---


         temp_disks=`awk '{print $4}' /proc/partitions | grep -s '^[h,s]d.$' | sort | xargs`

         disks=""
         #some of the disks aren't in /etc/fstab
         for disk in $temp_disks
         do
                 #take only disks in /etc/fstab
                 count=`grep -v "^#" /etc/fstab | grep -c $disk`
                 if [ "$count" != "0" ]
                 then
                         disks="$disks $disk"
                 fi
         done

         partitions=`grep "^/dev" /etc/fstab | grep $disk | grep -v "^\#" | awk '{printf "%s=%s\n", $1, $2}' | xargs | sed -e 's/\/dev\///g'`


 	#for 2.4 kernels
         #field #3 ($7) is sectors read, field #7 ($10) is sectors written
         for partition in $partitions
         do
                 part=${partition%%=*}
                 #use "$part " rather than "$part" so won't pick up hdd11, when want hdd1
                 eval `grep "$part " /proc/partitions |awk '{printf "sectors_R=%-11d\nsectors_W=%-11d\n", $7, $10}'`
                 for i in sectors_R sectors_W
                 do
                         if [ -z ${!i} ]; then
                                 eval $i=U
                         fi
                 done
                 partition_string="${partition_string}:${sectors_R}:${sectors_W}"
         done


if you want latency rather than sectors read/written

         eval `grep "$disk " /proc/partitions |awk '{printf "latency_RT=%-11d\nlatency_WT=%-11d\n", $8, $12}'`


-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!



More information about the TriLUG mailing list