38 lines
1021 B
Bash
38 lines
1021 B
Bash
#!/bin/bash
|
|
|
|
docker logs snowflake-proxy 2>&1 | awk '
|
|
function human_readable(kb, units, size, i) {
|
|
split("KB MB GB TB PB", units)
|
|
size = kb
|
|
for (i = 1; size >= 1024 && i < 5; i++) {
|
|
size = size / 1024
|
|
}
|
|
return sprintf("%.2f %s", size, units[i])
|
|
}
|
|
|
|
{
|
|
# Datumserkennung und Formatierung
|
|
if (split($1, date_part, "/") == 3) {
|
|
current_date = $1
|
|
gsub(/\//, "-", current_date) # Ersetze / durch -
|
|
if (!first_date) first_date = current_date
|
|
last_date = current_date
|
|
}
|
|
}
|
|
|
|
/Traffic Relayed ↓ [0-9]+ KB .*↑ [0-9]+ KB/ {
|
|
for (i = 1; i <= NF; i++) {
|
|
if ($i == "↓") { down += $(i+1) }
|
|
if ($i == "↑") { up += $(i+1) }
|
|
}
|
|
}
|
|
|
|
END {
|
|
printf "Statistik-Zeitraum:\n"
|
|
printf "Erster Eintrag: %s\n", first_date
|
|
printf "Letzter Eintrag: %s\n\n", last_date
|
|
|
|
printf "Gesamte Datenmengen:\n"
|
|
printf "Download: %d KB (%s)\n", down, human_readable(down)
|
|
printf "Upload: %d KB (%s)\n", up, human_readable(up)
|
|
}' |