#!/bin/sh # limitprobe.sh — INSIDE guest 9201, R-1250 diagnosis on the THROWAWAY qBittorrent only (no line test is started): the # controller's own hold value (up_limit 1024 B/s, the same app/preferences call) for 60 s, then the exact previous # value back. Each second: qBittorrent's reported limit + speed and the bytes its container sent. Q=/root/r1250/qbg.sh; PID=$(docker inspect -f '{{.State.Pid}}' qbittorrent) rd(){ sh $Q transfer/info | python3 -c 'import json,sys;d=json.load(sys.stdin);print("limit=%s speed=%.2f" % (d.get("up_rate_limit"), d.get("up_info_speed",0)*8/1e6))'; } PREV=$(sh $Q app/preferences | python3 -c 'import json,sys;print(json.loads(sys.stdin.read().replace("\\\\","/")).get("up_limit"))' 2>/dev/null) echo "previous up_limit=$PREV"; [ -n "$PREV" ] || { echo "cannot read the previous limit — no probe"; exit 1; } c0=$(awk '/eth0:/{print $10}' /proc/$PID/net/dev) echo "$(date -u +%T) set up_limit=1024: $(sh $Q app/setPreferences 'json={"up_limit":1024}'; echo ok)" i=0; while [ $i -lt 60 ]; do sleep 1; c=$(awk '/eth0:/{print $10}' /proc/$PID/net/dev); echo "$(date -u +%T) t=$((i+1))s ctr=$(( (c-c0)*8/1000 ))kbit $(rd)"; c0=$c; i=$((i+1)); done echo "$(date -u +%T) put back up_limit=$PREV: $(sh $Q app/setPreferences "json={\"up_limit\":$PREV}"; echo ok)" sleep 2; echo "after: $(rd)"