Last active
October 8, 2016 09:25
-
-
Save yszheda/999fd330d0a00866eb7e1ea13d70b4a9 to your computer and use it in GitHub Desktop.
count nginx requests by a certain POST pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# The POST string is like | |
# \"id\"=<some number> | |
# Count the requests by mid | |
# The result is like: | |
# count id | |
# ... ... | |
# known search patterns: | |
# %22mid%22%2A | |
# %2522mid%2522%253A | |
access_log=$1 | |
grep -oP '%[^%]+mid%[^%]+%[^%]+[0-9]*' $access_log | sed -ne 's/%\([^%]\+\)mid%\([^%]\+\)%\([^%]\+\)3A\([0-9]\+\)/\4/p' | sort | uniq -c | sort -rn | awk 'BEGIN{print "count", "mid"};{printf("%d 0x%04x\n", $1, $2)};' | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment