summaryrefslogtreecommitdiff
path: root/nureadahead-collect
blob: 9cf17fea39c39bb6de450f1bd9d7f2b91ac8aa8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

usage() {
    echo "usage: nureadahead-collect DEVICE TIMEOUT > file" >&2
}

case "$1" in
    -*) usage; exit 1
esac

case "$#" in
    2) device=$1 timeout=$2;;
    *) usage; exit 1
esac

awk_prog2='
$1 <= end && $2 > end {
    end = $2
}
$1 > end && NR != 1 {
    print start " " end
}
$1 > end {
    start = $1
    end = $2
}
END {
    print start " " end
}
'

blktrace -a read -d "$1" -w "$timeout" -o - \
    | blkparse -f "%a %d %e %n %S\n" -i - \
    | awk '$1 == "C" && $2 ~ /R/ && $2 !~ /A/ && $3 == 0 { print $5 " " $5 + $4 - 1 }' \
    | sort -n -k1,1 -k2,2 \
    | awk "$awk_prog2"