The little things give you away... A collection of various small helper stuff
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

24 lignes
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