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!!!!!