Last active
April 29, 2021 20:58
-
-
Save yonixw/4b06392bb0742903e7569a3f4378c908 to your computer and use it in GitHub Desktop.
Get nginx users per day
This file contains 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
cat nginx_logs.txt // (docker logs with timestamps, so first col ($1) is time) | |
| tr -cd '\11\12\15\40-\176' // filter non ascii from bot requests | |
| grep "/202" // get rows with time like Apr/2021 or Jul/2020 | |
| grep 'qp.png' // get rows which will called once per real user | |
| awk '{split($5,a,":"); print a[1] "\t" $2}' // print time of day and ip | |
| uniq -c | |
| sort -rn | |
| awk '{arr[$2]+=1} END {for (i in arr) {print substr(i,2),arr[i]}}' // Group IPs per day |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awk '{arr[$2]+=$1}
for adding same ip more than once, orawk '{arr[$2]+=1}
(add 1) per ip in the same day