Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author: p4u
- # Licence: GPLv3
- avg=0
- i=0
- for h in $@; do
- r=$(httping $h -Z -c1 --user-agent='Mozilla/5.0 (X11; Linux x86_64; rv:21.0) Gecko/20100101irefox/21.0' 2>/dev/null)
- if [ $? -eq 0 ]; then
- t=$(echo -e "$r" | grep round-trip | cut -d = -f2 | cut -d / -f2 | tr , .)
- echo "$h -> $t"
- avg=$(echo "$avg + $t" | bc -l)
- i=$(($i+1))
- [ $(($i%5)) -eq 0 ] && echo "AVG: $(echo $avg/$i | bc -l)"
- else
- echo "Failed ping to: $h"
- fi
- done
- echo ""
- echo "Successful HTTP replies: $i"
- echo "FINAL AVG: $(echo $avg/$i | bc -l)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement