From 5db227b05ba316713d6793e728b21366e8337721 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Sat, 4 Apr 2020 20:23:21 -0400 Subject: Initial commit --- nureadahead-collect | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 nureadahead-collect (limited to 'nureadahead-collect') diff --git a/nureadahead-collect b/nureadahead-collect new file mode 100755 index 0000000..9cf17fe --- /dev/null +++ b/nureadahead-collect @@ -0,0 +1,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" -- cgit v1.2.3-70-g09d2