Last active
December 15, 2015 14:19
-
-
Save Aricg/5273677 to your computer and use it in GitHub Desktop.
parses iostat to give iowait, reads and writes (Blk_read Blk_wrtn) in a specific way that I wanted it to at one point on some day or other.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| vg=vg_backup-lv_backup | |
| numlines=50 | |
| geta() { | |
| a=() | |
| while read -d $'\n'; do | |
| a+=("$REPLY") | |
| done < <(echo "$@" | tail -n 6| grep -A2 iowait | awk '{ print $4 }' | sed 's,\,,,g' | grep -o '[0-9]*' | sed 's/.$//') | |
| } | |
| getb() { | |
| b=() | |
| while read -d $'\n'; do | |
| b+=("$REPLY") | |
| done < <(echo "$@" | tail -n 6 | grep $vg | awk '{ print $3 }' |sed 's/...$//') | |
| } | |
| getc() { | |
| c=() | |
| while read -d $'\n'; do | |
| c+=("$REPLY") | |
| done < <(echo "$@" | tail -n 6 | grep $vg | awk '{ print $4 }' |sed 's/...$//') | |
| } | |
| zz=0 | |
| while (( zz < $numlines )); | |
| do | |
| x="$(iostat 1 2 -N $vg)" | |
| geta "$x" | |
| getb "$x" | |
| getc "$x" | |
| echo "reads "${b[@]}" iowait "${a[@]}" writes "${c[@]}"" | |
| (( zz++ )) | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment