Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a rate calculator utility in unix/bash?

I am looking for a tool which does something similar to

tail -f /var/log/some.log | grep EVENT1 |rate

which keeps displaying the rate of the event.

like image 558
sheki Avatar asked Mar 20 '23 14:03

sheki


1 Answers

tail -f /var/log/some.log | grep --line-buffered EVENT1 | pv -l > /dev/null

pv is a pipe monitor, which outputs statistics on stderr; the -l will measure lines instead of bytes.

You'll need to use --line-buffered on your grep call, so that it doesn't buffer larger blocks, or for a general case you can use stdbuf to adjust your buffering.

like image 92
Jeff Bowman Avatar answered Apr 25 '23 03:04

Jeff Bowman