Created
April 7, 2022 18:30
-
-
Save M4GNV5/30d0d39c0d13e6d1484e72a481d1c129 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
function analyzeFileForDay | |
{ | |
local dateStr=$(date '+%d/%b' --date="$1 day ago") | |
local count=$(grep "$dateStr" /mnt/docker-apps/traefik/logs/access.log* \ | |
| grep '"proxy@docker"' \ | |
| awk '{ print $1; }' \ | |
| sort \ | |
| uniq -c \ | |
| sort --numeric \ | |
| wc -l \ | |
) | |
# currently 6500 enrolled students (src: https://www.thi.de/hochschule/ueber-uns/zahlen-und-fakten/) | |
local percent=$(echo "$count / (6500 / 100)" | bc -l) | |
printf "Unique IPs on %s: %4d or %6.3f%% market share\n" "$dateStr" "$count" "$percent" | |
} | |
for i in $(seq 0 10) | |
do | |
analyzeFileForDay "$i" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment