Skip to content

Instantly share code, notes, and snippets.

@amazingandyyy
Last active April 9, 2019 02:36
Show Gist options
  • Save amazingandyyy/55a48fa82777d6887803eee74a1ed490 to your computer and use it in GitHub Desktop.
Save amazingandyyy/55a48fa82777d6887803eee74a1ed490 to your computer and use it in GitHub Desktop.
# https://stackoverflow.com/questions/41573277/extract-count-of-a-string-in-log-file-using-grep
while sleep 1; do
attemps=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_ATTEMPT" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_ATTEMPT")
sent=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_GOOD" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_GOOD")
fail=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_BAD" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_BAD")
echo $sent / $attemps
done;
@amazingandyyy
Copy link
Author

the result looks like this:

(mono-venv) root@web-devxenial:/home/vagrant# sudo service uwsgi restart
(mono-venv) root@web-devxenial:/home/vagrant# while sleep 1; do   attemps=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_ATTEMPT" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_ATTEMPT");   sent=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_GOOD" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_GOOD");   fail=$(grep -A 2 "KAFKA_CLIENT_PRODUCER_BAD" /srv/minted/logs/www-wsgi.log | grep -c "KAFKA_CLIENT_PRODUCER_BAD");   echo $sent / $attemps; done;
11 / 13
11 / 13
12 / 14
13 / 15
20 / 22
20 / 22
23 / 25
28 / 30
29 / 31
31 / 33
31 / 33
34 / 36
35 / 37
35 / 37
35 / 37
35 / 37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment