summaryrefslogtreecommitdiff
path: root/nureadahead-collect
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-04-04 20:23:21 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-04-04 20:23:21 -0400
commit5db227b05ba316713d6793e728b21366e8337721 (patch)
tree8001f1fba5ec3c1fa37ad1aa6c55fe748880823a /nureadahead-collect
downloadnureadahead-master.tar.xz
nureadahead-master.zip
Initial commitHEADmaster
Diffstat (limited to 'nureadahead-collect')
-rwxr-xr-xnureadahead-collect36
1 files changed, 36 insertions, 0 deletions
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"