Measuring log growth rate (lines per second)

From Tech-Wiki
Jump to: navigation, search

The commands below will print how many lines are being generated per second

tail -f file > /tmp/tmp.log & sleep 1; kill $! ; wc -l /tmp/tmp.log ; rm /tmp/tmp.log
tail -f file | pv -l -i10 -r > /dev/null
tail -f file | perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}'
tail -f file | perl -ne 'print time(), "\n";' | uniq -c
tail -f file | python -c 'exec("import sys,time\nl=0\ne=int(time.time())\nfor line in sys.stdin:\n\tt = int(time.time())\n\tl += 1\n\tif t > e:\n\t\te = t\n\t\tprint l\n\t\tl = 0")'