Browse Source

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..
main
John-Mark Gurney 1 year ago
parent
commit
6162960230
1 changed files with 38 additions and 0 deletions
  1. +38
    -0
      filespeed

+ 38
- 0
filespeed View File

@@ -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 <file>"
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

Loading…
Cancel
Save