Skip to content

Instantly share code, notes, and snippets.

@M4GNV5
Created April 7, 2022 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M4GNV5/30d0d39c0d13e6d1484e72a481d1c129 to your computer and use it in GitHub Desktop.
Save M4GNV5/30d0d39c0d13e6d1484e72a481d1c129 to your computer and use it in GitHub Desktop.
#!/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