From 97d71ed1306bf2a26a43e344cbfaa5f735e6d802 Mon Sep 17 00:00:00 2001 From: Jordan Sissel <jls@semicomplete.com> Date: Sun, 31 Oct 2010 08:17:47 +0000 Subject: [PATCH] - Add script to hackily check for progress on a long import. --- misc/rate.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 misc/rate.sh diff --git a/misc/rate.sh b/misc/rate.sh new file mode 100755 index 00000000000..5d01129a3e2 --- /dev/null +++ b/misc/rate.sh @@ -0,0 +1,21 @@ +#!/bin/zsh + +if [ "$#" -ne 1 ] ; then + echo "Usage; $0 logfile" + exit 1 +fi +logfile="$1" + +pid=$(ps -u $USER -f | awk '/bin.logstash -[f]/ {print $2}') +fileno=$(lsof -nPp $pid | grep -F "$logfile" | awk '{ print int($4) }') +pos=$(awk '/pos:/ {print $2}' /proc/$pid/fdinfo/$fileno) +starttime=$(awk '{print $22}' /proc/$pid/stat) +curtime=$(awk '{print $1}' /proc/uptime) +lines=$(dd if="$logfile" bs=$pos count=1 | wc -l) + +duration=$(($curtime - ($starttime / 100.))) +rate=$(( $lines / (0.0 + $duration) )) + +echo "Duration: $duration" +echo "Rate: $rate" +