fix xray stat

This commit is contained in:
陈浩南 2023-08-11 15:16:23 +08:00
parent baf5c5c9e4
commit 647e9b4463

View File

@ -586,9 +586,14 @@ inputs:
message='xray:\n' message='xray:\n'
for i in {0..${toString ((length userList) - 1)}} for i in {0..${toString ((length userList) - 1)}}
do do
traffic_bytes=$(${xray} api stats --server=127.0.0.1:6149 \ upload_bytes=$(${xray} api stats --server=127.0.0.1:6149 \
-name "user>>>''${i}@xray.chn.moe>>>traffic>>>uplink" | , jq '.stat.value' | sed 's/"//g')
[ -z "$upload_bytes" ] && upload_bytes=0
download_bytes=$(${xray} api stats --server=127.0.0.1:6149 \
-name "user>>>''${i}@xray.chn.moe>>>traffic>>>downlink" | , jq '.stat.value' | sed 's/"//g') -name "user>>>''${i}@xray.chn.moe>>>traffic>>>downlink" | , jq '.stat.value' | sed 's/"//g')
message=$message"$i"'\t'$(echo | ${awk} "{printf \"%.3f\",0''${traffic_bytes}/1073741824}")'G\n' [ -z "$download_bytes" ] && download_bytes=0
traffic_gb=$(echo | ${awk} "{printf \"%.3f\",(''${upload_bytes}+''${download_bytes})/1073741824}")
message="$message$i"'\t'"''${traffic_gb}"'G\n'
done done
${curl} -X POST -H 'Content-Type: application/json' \ ${curl} -X POST -H 'Content-Type: application/json' \
-d "{\"chat_id\": \"$(cat ${chat})\", \"text\": \"$message\"}" \ -d "{\"chat_id\": \"$(cat ${chat})\", \"text\": \"$message\"}" \