Bash script affect load average

Hello
I have created next scritpt to do the next: chekp if host is alive. When the host down, launch telnet other equip to do checks.
When execute the script the load average of the machines increase. For example:
Before launch script

top - 11:14:56 up 14 days, 18:06,  3 users,  load average: 2.66, 2.52, 2.26
Tasks: 251 total,   2 running, 234 sleeping,   0 stopped,  15 zombie
Cpu(s):  7.0%us, 10.3%sy, 25.7%ni, 56.9%id,  0.0%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   3097180k total,  2782136k used,   315044k free,   182920k buffers
Swap:  3903480k total,      624k used,  3902856k free,  2064220k cached

After 10 min launch the script

top - 11:24:09 up 14 days, 18:15,  3 users,  load average: 3.88, 3.48, 2.85
Tasks: 250 total,   2 running, 230 sleeping,   0 stopped,  18 zombie
Cpu(s): 20.5%us, 25.3%sy,  0.2%ni, 53.8%id,  0.0%wa,  0.1%hi,  0.2%si,  0.0%st
Mem:   3097180k total,  2797204k used,   299976k free,   183912k buffers
Swap:  3903480k total,      624k used,  3902856k free,  2067728k cached

After 3 hours the load average can be 17 or more.
What is the problem with the script? It's the | ? the sleps??
The script:

#!/bin/bash
HOSTS="198.19.1.174"
COUNT=1
COUNT2=1
COUNT3=0
USER="****"
PASS="****"
#touch result$COUNT3.txt
function bucle(){
while [  $COUNT2 -lt 10 ];
do
  count=$(ping -c $COUNT $HOSTS | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
    # 100% failed
    echo "Host : $myHost is down (ping failed) at $(date)"
( echo open 198.19.1.174
sleep 2;
echo ${USER}
sleep 2;
echo ${PASS}
sleep 2;
echo "sh clock"
sleep 2;
echo "ping vrf OOB 198.19.1.175"
sleep 2;
echo "ping vrf OOB 198.19.1.176"
sleep 2;
echo "sh ip arp vrf OOB vlan 1307 | i 198.19.1.175"
sleep 2;
echo "sh ip arp vrf OOB vlan 1307 | i 198.19.1.176"
sleep 2;
echo "sh mac-address-table interface gigabitEthernet 7/29"
sleep 2;
echo "sh mac-address-table interface gigabitEthernet 7/33"
sleep 2;
echo "sh clock"
sleep 2;) |telnet
( echo open 198.18.1.174
sleep 3;
echo ${USER}
sleep 3;
echo ${PASS}
echo "ping vrf OOB 198.19.1.175 source vlan 1207"
sleep 10;
echo "ping vrf OOB 198.19.1.176 source vlan 1207"
sleep 10;) |telnet
COUNT3=COUNT3+1
#echo $COUNT3
fi
done
}

bucle

Thanks!!!!!

It looks like your code never sets COUNT2 to zero...

Yes
Because is a bucle. I need to do ping all the time
Thanks

---------- Post updated 06-07-13 at 04:45 AM ---------- Previous update was 06-06-13 at 08:25 AM ----------

It's possible the loop or bucle it's the cause of the problem with the load average?
Thanks

Finaly I change the script

#!/bin/bash HOSTS="198.19.1.174" COUNT=1 COUNT2=1 COUNT3=0 USER="****" PASS="****" #touch result$COUNT3.txt function bucle(){{
while [  $COUNT2 -lt 10 ];
do
# count=$(ping -c $COUNT $HOSTS | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
 # if [ $count -eq 0 ]; then
# 100% failed
ping -c 1 -t 10 $HOSTS  > /dev/null 2> /dev/null
 if [ $? -eq 0 ]; then
bucle
else
( echo open 198.19.253.49
sleep 2;
echo ${USER}
sleep 2;
echo ${PASS}
sleep 2;
echo "sh ip arp vrf OOB | i .129"
sleep 2;) |telnet
fi
done
}
bucle

This script doesn't up the load average, but the process kill with:
kernel: [2094147.207333] test_ping.sh[31552]: segfault at 7fffcc7f3f88 ip 48f62a sp 7fffcc7f3f70 error 6 in bash[400000+ba000]
It's possible the loop generate the error??
I continue investigating.........
I tried to change the loop (change the While for the command for)
for (( ; ; )) do with the same result :frowning:
ontinue investigating.........
test_ping.sh[15343]: segfault at 7fff76f16fc8 ip 48f62a sp 7fff76f16fb0 error 6 in bash[400000+ba000]
Saludations

---------- Post updated at 03:56 AM ---------- Previous update was at 02:17 AM ----------

Hi!!
Finally I find the solution.
The problem is :
ping -c 1
This ping and the bucle provocate overload of the system, Changing to
ping -c 3 (or put a delay)
the problem has been solved
Thanks!!!!