Difference between revisions of "EdgeOS Load-Balance Response Time Script"

From Michael's Information Zone
Jump to navigation Jump to search
(Created page with "<pre> #!/bin/bash ping -O yahoo.com -c 3 2>/dev/null 1>/tmp/testout.log sed -i '1d' /tmp/testout.log sed -i '4,7d' /tmp/testout.log sed -i 's|^.*time=||' /tmp/testout.log sed...")
 
 
Line 1: Line 1:
 +
==New script as of ~2018==
 +
<pre>
 +
#! /bin/bash
 +
if [ $(/bin/ping -q -c 5 -W 1 ping.ubnt.com | grep -Eo  '[0-9]{1,3}%') != '0%' ]; then exit 1; else exit 0; fi
 +
</pre>
 +
==Old Script==
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash

Latest revision as of 15:12, 13 October 2018

New script as of ~2018

#! /bin/bash
if [ $(/bin/ping -q -c 5 -W 1 ping.ubnt.com | grep -Eo  '[0-9]{1,3}%') != '0%' ]; then exit 1; else exit 0; fi

Old Script

#!/bin/bash
ping -O yahoo.com -c 3 2>/dev/null 1>/tmp/testout.log
sed -i '1d' /tmp/testout.log
sed -i '4,7d' /tmp/testout.log
sed -i 's|^.*time=||' /tmp/testout.log
sed -i 's|\ ms||' /tmp/testout.log
sed -i 's|\..*||' /tmp/testout.log
linetotal=0
while read line
do
linetotal=$(($linetotal + 1))
done < /tmp/testout.log
SUM=0
while read line
do
SUM=$(($SUM + $line))
done < /tmp/testout.log
final=$(($SUM / $linetotal))
if (("$final" > "900")); then
exit 1
else
exit 0
fi