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