Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Last active May 2, 2024 14:04
Show Gist options
  • Save HirbodBehnam/bbf44bef7cfd15c523ff9ec66434762c to your computer and use it in GitHub Desktop.
Save HirbodBehnam/bbf44bef7cfd15c523ff9ec66434762c to your computer and use it in GitHub Desktop.
Get stats of xray in style
xray api statsquery --server=127.0.0.1:10085 | jq -r '.stat | (.[].value |= (. // "0" | tonumber)) | (.[].name |= split(">>>")) | group_by(.name[1]) | (.[] |= {download: (if .[0].name[3] == "downlink" then .[0].value else .[1].value end), upload: (if .[0].name[3] == "downlink" then .[1].value else .[0].value end), name: .[0].name[1], total: (.[0].value + .[1].value)}) | sort_by(.total) | reverse | .[] | .name + " ↓" + (.download / 1024 / 1024 | floor | tostring) + "MB ↑" + (.upload / 1024 / 1024 | floor | tostring) + "MB ↕" + (.total / 1024 / 1024 | floor | tostring) + "MB"' | column -t -s' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment