Disklatency

From Ye Ole Stash
Jump to: navigation, search
#!/bin/bash
 
#Chris Layton for WorldSpice Aug 2010
#Version 0.3
#Changelog
#2010-8-3 Broke devicemapper (dm) and software raid (MD) devices out from the rest of the devices. This was because they needed special attention.
 
drives="dm-0 dm-1 dm-2 drbd2 md2"
 
# Turn on and off what is needed
# Field 1 - Read Latency in ms for drive
# Field 2 - Write Latency in ms for drive
# Field 3 - milliseconds spent doing I/O
# Field 4 - weighted # of milliseconds spent doing I/O
 
 
for i in $drives; do
#    echo $i | sed 's/[0-9]//g' | cut -d- -f1 | tr -d '\n';
     if [[ "$i" == dm* ]]; then
        dmsetup ls | grep -w [`echo $i | cut -d- -f2`] | awk '{print $1}'
        echo `cat /proc/diskstats  | grep $i | awk '{print $7}'`
        echo `cat /proc/diskstats  | grep $i | awk '{print $11}'`
        #echo `cat /proc/diskstats  | grep $i | awk '{print $13}'`
        #echo `cat /proc/diskstats  | grep $i | awk '{print $14}'`
 
    else
        if [[ "$i" == md* ]]; then
            df -P | grep $i | awk '{print $1,$6}'
            for d in `cat /proc/mdstat | grep $i | sed 's/[[0-9]]/ /g' | tr -d "[]" | awk '{print $5,$6,$7,$8,$10}'`;do
                echo `cat /proc/diskstats  | grep $d | awk '{print $7}'`
                echo `cat /proc/diskstats  | grep $d | awk '{print $11}'`
                #echo `cat /proc/diskstats  | grep $d | awk '{print $13}'`
                #echo `cat /proc/diskstats  | grep $d | awk '{print $14}'`
            done
            else
            df -P | grep $i | awk '{print $1,$6}'
            echo `cat /proc/diskstats  | grep $i | awk '{print $7}'`
            echo `cat /proc/diskstats  | grep $i | awk '{print $11}'`
            #echo `cat /proc/diskstats  | grep $i | awk '{print $13}'`
            #echo `cat /proc/diskstats  | grep $i | awk '{print $14}'`
        fi
fi
done

#!/bin/bash
 
#Chris Layton for WorldSpice Aug 2010
#Version 0.2c
 
 
drives="dm-0 dm-1 dm-2 drbd2 md2"
 
# Turn on and off what is needed
# Read Latency in ms for drive
# Write Latency in ms for drive
# milliseconds spent doing I/O
# weighted # of milliseconds spent doing I/O
 
for i in $drives; do
    echo $i | grep -o dm-[0-9] > /dev/null
    if [ $? -ne "0" ];then
        df -P | grep $i | awk '{print $1,$6}'
#       echo `cat /proc/diskstats  | grep $i | awk '{print $7}'`
#       echo `cat /proc/diskstats  | grep $i | awk '{print $11}'`
#       echo `cat /proc/diskstats  | grep $i | awk '{print $13}'`
        echo `cat /proc/diskstats  | grep $i | awk '{print $14}'`
    else
        dmsetup ls | grep -w [`echo $i | cut -d- -f2`] | awk '{print $1}'
#       echo `cat /proc/diskstats  | grep $i | awk '{print $7}'`
#       echo `cat /proc/diskstats  | grep $i | awk '{print $11}'`
#       echo `cat /proc/diskstats  | grep $i | awk '{print $13}'`
        echo `cat /proc/diskstats  | grep $i | awk '{print $14}'`
    fi
done

#!/bin/bash
 
 
drives="md0 md1 md2 md3 md4"
bytesinsector=512 #this is found by fdisk -l /dev/$device (look for Units = cylinders of 8 * 512 = 4096 bytes) the 512 is bytes in sector in this case.
 
# Turn on and off what is needed
# Read Latency in ms for drive
# Write Latency in ms for drive
# milliseconds spent doing I/O
# weighted # of milliseconds spent doing I/O
 
for i in $drives; do
    df -P | grep $i | awk '{print $1,$6}'
    for d in `cat /proc/mdstat | grep $i | sed 's/[[0-9]]/ /g' | tr -d "[]" | awk '{print $5,$6,$7,$8,$10}'`;do
#       echo `cat /proc/diskstats  | grep $d | awk '{print $7}'`
#       echo `cat /proc/diskstats  | grep $d | awk '{print $11}'`
#       echo `cat /proc/diskstats  | grep $d | awk '{print $13}'`
        echo `cat /proc/diskstats  | grep $d | awk '{print $14}'`
   done
done
Personal tools