| 1 | #!/bin/bash |
| 2 | #Poustime pod r00tem! |
| 3 | testbtotal=268943360; #wc -c test.bin |
| 4 | |
| 5 | list_victims() { |
| 6 | #tahle funkce zjisti a vypise IP/hostname testovanych boxu - na radku jeden |
| 7 | echo fsdfdf |
| 8 | echo strep #dostupna + test.bin k dispozici |
| 9 | echo 127.0.0.1 #dostupna |
| 10 | echo 192.168.2.1 #nedostupna sit |
| 11 | echo lollol #neexistujici dns |
| 12 | } |
| 13 | |
| 14 | ping_perc() { |
| 15 | perc=0; |
| 16 | for i in $(seq 0 99); do |
| 17 | ping -c 1 -w 0.7 "$1" &> /dev/null; |
| 18 | ret="$?"; |
| 19 | if [[ "$ret" == 0 ]]; then |
| 20 | perc=$[$perc+1]; |
| 21 | fi; |
| 22 | if [[ "$ret" == 2 ]]; then |
| 23 | echo 0; return 0; |
| 24 | fi; |
| 25 | done; |
| 26 | echo "$perc"; |
| 27 | return "$perc"; |
| 28 | } |
| 29 | |
| 30 | for victim in $(list_victims); do |
| 31 | #victim |
| 32 | echo -n "$victim - "; |
| 33 | #ping |
| 34 | echo -n "ping responses: "; |
| 35 | pings=$(ping_perc "$victim"); |
| 36 | echo -n "$pings%, "; |
| 37 | #test.bin |
| 38 | echo -n "test.bin: " |
| 39 | bytes=$(curl "http://$victim/test.bin" --stderr /dev/null|wc -c); |
| 40 | downloaded=$[$bytes*100/$testbtotal]; |
| 41 | echo -n "$downloaded% downloaded, "; |
| 42 | #endvictim |
| 43 | echo -n "; "; |
| 44 | done; |
| 45 | |
| 46 | echo; |
| 47 | |
| 48 | #rozsahu, ty pingnout -c 100, potom z nich stahnout test.bin, do nagiosu potom poslat zpravu spoj $ESSID ma $ODEZVA odezvu, $LOSS, rychlost $WGET_AVG |