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