JimDeadlock

Lag Monitoring

Nov 15th, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | Gaming | 0 0
  1. #!/bin/bash
  2.  
  3. # set the following 3 variables to reasonable values; don't break your own shit
  4. MY_STEAM_NAME=CHANGEME
  5. MY_EXPECTED_PING=150
  6. REPORT_LOCATION=~/deadlock-reports
  7.  
  8. # don't edit below
  9.  
  10. mkdir -p -- "${REPORT_LOCATION}"
  11.  
  12. while true; do
  13. REPORT_PATH="${REPORT_LOCATION}/mtr-${MY_STEAM_NAME}-$(date +%FT%R).txt"
  14. PING_RESULTS=$(ping -4 -c 3 -q play.deadlock.com | tail -n 2)
  15. PING_MS=$(echo ${PING_RESULTS} | awk -F ' ' '{print $(NF-1)}' | cut -d / -f 1 | cut -d . -f 1)
  16. PACKET_LOSS=$(echo ${PING_RESULTS} | grep "0% packet loss")
  17. if [ "${PING_MS/time/9999}" -gt "$((MY_EXPECTED_PING * 10 / 9))" -o -z "${PACKET_LOSS}" ]; then #high ping or packet loss
  18. TZ=UTC mtr -4 -b -w -c 300 play.deadlock.com | tee ${REPORT_PATH}
  19. else # things appear normal, don't hammer server
  20. echo -e "$(date):\tNo packet loss and ping(${PING_MS}) within range, sleeping..."
  21. sleep 30
  22. fi
  23. done
  24.  
Advertisement
Add Comment
Please, Sign In to add comment