Diskiops

From Ye Ole Stash
Jump to: navigation, search
#!/bin/bash
 
#Version 0.3
# Changelog
# 0.3 (Aug-3-2010) Changed my ls to use dmsetup as its quicker and more accurate.
# 0.2 (Aug-2-2010) Added quick hack to look for and map devicemapper (LVM) entries
 
drives="dm-0 dm-1 drbd2 md2"
 
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}'
    else
        dmsetup ls | grep -w [`echo $i | cut -d- -f2`] | awk '{print $1}'
    fi
    echo "Read IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $4}'`
    echo "Write IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $8}'`
done

#!/bin/bash
 
# Version 0.2
# Changelog
# 0.2 (Aug-2-2010) Added quick hack to look for and map devicemapper (LVM) entries
drives="dm-0 dm-1 drbd2 md2"
 
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}'
    else
        ls -al /dev/mapper/ | grep root| grep -w [`echo dm-0 | cut -d- -f2`] | awk '{print $10}'
    fi
    echo "Read IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $4}'`
    echo "Write IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $8}'`
done

#!/bin/bash
 
#Version 0.1
 
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.
 
for i in $drives; do
    df -P | grep $i | awk '{print $1,$6}'
    echo "Read IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $4}'`
    echo "Write IO"
    echo `cat /proc/diskstats | grep $i | awk '{print $8}'`
done
Personal tools