Skip to content

Instantly share code, notes, and snippets.

@aquila0101
Forked from Atrate/snowstats.sh
Created July 19, 2024 20:28
Show Gist options
  • Save aquila0101/9cbd8b918d8158cd0a23aadeca25378b to your computer and use it in GitHub Desktop.
Save aquila0101/9cbd8b918d8158cd0a23aadeca25378b to your computer and use it in GitHub Desktop.
Quick script to get the statistics of traffic on Tor Project's Snowflake proxy instance running locally on docker
#!/bin/bash --posix
docker logs snowflake-proxy 2>&1 | grep --color=auto 'Traffic Relayed' | awk '
{
# Extract the download and upload values
down[1] = $14
down[2] = $15
gsub(/[^a-zA-Z]/, "", down[2])
up[1] = $17
up[2] = $18
gsub(/[^a-zA-Z]/, "", up[2])
# Convert to bytes
if (down[2] == "B") down_total += down[1];
else if (down[2] == "KB") down_total += down[1] * 1024;
else if (down[2] == "MB") down_total += down[1] * 1024 * 1024;
else if (down[2] == "GB") down_total += down[1] * 1024 * 1024 * 1024;
if (up[2] == "B") up_total += up[1];
else if (up[2] == "KB") up_total += up[1] * 1024;
else if (up[2] == "MB") up_total += up[1] * 1024 * 1024;
else if (up[2] == "GB") up_total += up[1] * 1024 * 1024 * 1024;
count++;
}
END {
print "Sum of down traffic on Snowflake: " down_total / 1024/ 1024 / 1024 " GB";
print "Sum of up traffic on Snowflake: " up_total / 1024 / 1024 / 1024 " GB";
print "Total connections established: " count
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment