Advertisement
Guest User

httping_test

a guest
Jun 28th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.55 KB | None | 0 0
  1. #!/bin/bash
  2. # Author: p4u
  3. # Licence: GPLv3
  4.  
  5. avg=0
  6. i=0
  7. for h in $@; do
  8.     r=$(httping $h -Z -c1 --user-agent='Mozilla/5.0 (X11; Linux x86_64; rv:21.0) Gecko/20100101irefox/21.0' 2>/dev/null)
  9.     if [ $? -eq 0 ]; then
  10.         t=$(echo -e "$r" | grep round-trip  | cut -d = -f2 | cut -d / -f2 | tr , .)
  11.         echo "$h -> $t"
  12.         avg=$(echo "$avg + $t" | bc -l)
  13.         i=$(($i+1))
  14.         [ $(($i%5)) -eq 0 ] && echo "AVG: $(echo $avg/$i | bc -l)"
  15.     else
  16.         echo "Failed ping to: $h"
  17.     fi
  18. done
  19.  
  20. echo ""
  21. echo "Successful HTTP replies: $i"
  22. echo "FINAL AVG: $(echo $avg/$i | bc -l)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement