Last active
July 19, 2024 20:28
-
-
Save Atrate/be4a7d308549c7a9fe281d2cdf578d21 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
This file contains hidden or 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 --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 | |
}' |
@aquila0101 For your use-case, you'll need to change
# 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])
to
# Extract the download and upload values
down[1] = $15
down[2] = $16
gsub(/[^a-zA-Z]/, "", down[2])
up[1] = $18
up[2] = $19
gsub(/[^a-zA-Z]/, "", up[2])
I'll have to check on my server whether the log format just changed or whether for some reason yours is different than mine.
As far as I can see, my logs do not include the word "completed". I may have an older version of snowflake installed or something of that sort.
now it's correct:
root@DietPi:~# ./snowstats.sh
Sum of down traffic on Snowflake: 69.8545 GB
Sum of up traffic on Snowflake: 3.73765 GB
Total connections established: 100
I'm using this to run snowflake:
https://gitlab.torproject.org/tpo/anti-censorship/docker-snowflake-proxy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my server is debian 12 and these are the logs so far