From 6162960230636655187ecfc04a16247689651226 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Mon, 16 May 2022 14:38:58 -0700 Subject: [PATCH] add script to display how fast a file is being appended to... useful for monitoring speed when a program doesn't have it's output, or you silenced it's status for reasons.. --- filespeed | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 filespeed diff --git a/filespeed b/filespeed new file mode 100755 index 0000000..2aefd25 --- /dev/null +++ b/filespeed @@ -0,0 +1,38 @@ +#!/bin/sh - + +if [ x"$#" = x"2" -a x"$1" = x"-c" ]; then + continueous=1 + shift +fi + +if [ x"$#" != x"1" ]; then + echo "Usage: $0 " + exit 2 +fi + +if ! [ -f "$1" ]; then + echo "$1" does not exist! + exit 1 +fi + +if [ $continueous = 1 ]; then + lastls=$(ls -l "$1") + while sleep 1; do + nextls=$(ls -l "$1") + ( echo "$lastls"; echo "$nextls") | + grep -v '^total' | + awk '{ ar[NR] = $5 } + END { bytes = ar[2] - ar[1]; + bytespersec = bytes; + print bytespersec / 1024 / 1024 }' + + lastls="$nextls" + done +else + ( ls -l "$1"; sleep 5; ls -l "$1") | + grep -v '^total' | + awk '{ ar[NR] = $5 } + END { bytes = ar[2] - ar[1]; + bytespersec = bytes / 5; + print bytespersec / 1024 / 1024 }' +fi