The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
914 B

  1. #!/bin/bash
  2. if [[ $# -ne 2 || "$1" == '--help' ]]
  3. then
  4. echo "Usage: $0 PROJECT DURATION" >&2
  5. echo 'Requests the PROJECT statistics from the AT tracker twice DURATION seconds apart, and calculates the average returned item size for each user within that window.' >&2
  6. echo 'Output consists of lines of username SPACE SIZE, sorted by size ascending.' >&2
  7. exit 1
  8. fi
  9. project="$1"
  10. declare -i duration="$2"
  11. {
  12. curl -s "https://legacy-api.arpa.li/${project}/stats.json" | tr -d '\n'
  13. echo
  14. sleep ${duration}
  15. curl -s "https://legacy-api.arpa.li/${project}/stats.json" | tr -d '\n'
  16. echo
  17. } \
  18. | python3 -c 'import json,sys;o0=json.loads(sys.stdin.readline());o1=json.loads(sys.stdin.readline());[print(k,(o1["downloader_bytes"][k]-o0["downloader_bytes"][k])/(o1["downloader_count"][k]-o0["downloader_count"][k])) for k in o0["downloaders"] if o1["downloader_count"][k] != o0["downloader_count"][k]]' \
  19. | sort -k2,2n