bash - Show active ip-addresses in linux script with % or UP/DOWN -
i have ip-address: 192.168.0.205 can ping in script:
for in 192.168.0.205 .... ping -c 1 $i done
but want script shows: 192.168.0.205 or down
is there way show in % e.g: 75% up?
what may want this:
x=0; a=1 b=5 for((i=$a;i<=$b;i++)) y=`ping -n 1 192.168.1.$i | grep unreachable | wc -l` x=$(($x + $y)) done; echo "$x $b $a" | awk '{printf "%.2f %% down\n",($1/($2-$3+1))*100}';
x: contains number of down ips
a: last octet of first ip address
b: last octet of last ip address
y: contains 0 if ip else 1
i hope helps!
ps: change -n -c or whatever option work in shell!
Comments
Post a Comment