run.sh 617 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. SOURCE="mejis"
  3. PEERFINDER="http://172.23.184.112:8888"
  4. NB_PINGS=5
  5. SLEEP=20
  6. [ -z "$1" ] && FAMILY="ipv4" || FAMILY="ipv6"
  7. [ "$FAMILY" = "ipv4" ] && PING="ping" || PING="ping6"
  8. while :
  9. do
  10. sleep "$SLEEP"
  11. curl "$PEERFINDER"/targets/"$FAMILY" > /tmp/"$FAMILY" 2> /dev/null
  12. read -r id ip < /tmp/"$FAMILY"
  13. echo "$id $ip"
  14. [ -z "$id" -o -z "$ip" ] && continue
  15. rtt="$($PING -c "$NB_PINGS" "$ip" | grep rtt | cut -d '/' -f 5)"
  16. [ -z "$rtt" ] && continue
  17. echo "RTT to target $id ($ip) is $rtt"
  18. curl -d "target=${id}&source=${SOURCE}&rtt=${rtt}" "$PEERFINDER"/result/report
  19. done