Sponsored Content
Top Forums Shell Programming and Scripting Bash script affect load average Post 302817597 by capilla on Thursday 6th of June 2013 05:30:24 AM
Old 06-06-2013
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
Code:
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
Code:
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:
Code:
#!/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!!!!!
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

load average

we have an unix system which has load average normally about 20. but while i am running a particular unix batch which performs heavy operations on filesystem and database average load reduces to 15. how can we explain this situation? while running that batch idle cpu time is about %60-65... (0 Replies)
Discussion started by: gfhgfnhhn
0 Replies

2. UNIX for Dummies Questions & Answers

Load Average

Hello all, I have a question about load averages. I've read the man pages for the uptime and w command for two or three different flavors of Unix (Red Hat, Tru64, Solaris). All of them agree that in the output of the 2 aforementioned commands, you are given the load average for the box, but... (3 Replies)
Discussion started by: Heathe_Kyle
3 Replies

3. Shell Programming and Scripting

Determening load average.

Hi, I'm new to shell scripting. I need to make a script to add on to my cronjobs. The script must get the value of load average from my server and if its greater than 10 it should stop my apache service. I cant find a way to get the value of load average in integer type to do the check. Any... (4 Replies)
Discussion started by: jibsonline
4 Replies

4. UNIX for Dummies Questions & Answers

top - Load average

Hello, Here is the output of top command. My understanding here is, the load average 0.03 in last 1 min, 0.02 is in last 5 min, 0.00 is in last 15 min. By seeing this load average, When can we say that, the system load averge is too high? When can we say that, load average is medium/low??... (8 Replies)
Discussion started by: govindts
8 Replies

5. Solaris

load average query.

Hi, i have installed solaris 10 on t-5120 sparc enterprise. I am little surprised to see load average of 2 or around on this OS. when checked with ps command following process is using highest CPU. looks like it is running for long time and does not want to stop, but I do not know... (5 Replies)
Discussion started by: upengan78
5 Replies

6. UNIX for Dummies Questions & Answers

Please Help me in my load average

Hello AlL,.. I want from experts to help me as my load average is increased and i dont know where is the problem !! this is my top result : root@a4s # top top - 11:30:38 up 40 min, 1 user, load average: 3.06, 2.49, 4.66 Mem: 8168788k total, 2889596k used, 5279192k free, 47792k... (3 Replies)
Discussion started by: black-code
3 Replies

7. Shell Programming and Scripting

30 Load average with fping script

Hi! I've make a script that gets a list of 200 Ip's and calls another script once per ip in a infinite loop with a pause of 10 seconds. So It calls over 200 times every 10 seconds the second script (that makes a fping). But this cause a load average of 30. I've been reading about this and I... (4 Replies)
Discussion started by: charlscross
4 Replies

8. UNIX for Dummies Questions & Answers

Help with load average?

how load average is calculated and what exactly is it difference between cpu% and load average (9 Replies)
Discussion started by: robo
9 Replies

9. HP-UX

Load average unit

Hi, On load average graph, unit is 100m, 200m, 300...800m. I don't understand what it means. Thx for helping (3 Replies)
Discussion started by: Michenux
3 Replies

10. Shell Programming and Scripting

Script to load daily average I/O stats from a .ksh file into Oracle db

Hi can anyone help me with a script to load output of the .ksh file into an Oracle database. I have attached sample output of the information that i need to load to the database (2 Replies)
Discussion started by: LucyYani
2 Replies
SLEEPENH(1)						      General Commands Manual						       SLEEPENH(1)

NAME
sleepenh - an enhanced sleep program. SYNOPSIS
sleepenh [initial-time] sleep-time DESCRIPTION
sleepenh is a program that can be used when there is a need to execute some functions periodically in a shell script. It was not designed to be accurate for a single sleep, but to be accurate in a sequence of consecutive sleeps. After a successful execution, it returns to stdout the timestamp it finished running, that can be used as initial-time to a successive exe- cution of sleepenh. OPTIONS
There are no command line options. Run it without any option to get a brief help and version. ARGUMENTS
sleep-time is a real number in seconds, with microseconds resolution (1 minute, 20 seconds and 123456 microseconds would be 80.123456). initial-time is a real number in seconds, with microseconds resolution. This number is system dependent. In GNU/Linux systems, it is the number of seconds since midnight 1970-01-01 GMT. Do not try to get a good value of initial-time. Use the value supplied by a previous exe- cution of sleepenh. If you don't specify initial-time, it is assumed the current-time. EXIT STATUS
An exit status greater or equal to 10 means failure. Known exit status: 0 Success. 1 Success. There was no need to sleep. (means that initial-time + sleep-time was greater than current-time). 10 Failure. Missing command line arguments. 11 Failure. Did not receive SIGALRM. 12 Failure. Argument is not a number. 13 Failure. System error, could not get current time. USAGE EXAMPLE
Suppose you need to send the char 'A' to the serial port ttyS0 every 4 seconds. This will do that: #!/bin/sh TIMESTAMP=`sleepenh 0` while true; do # send the byte to ttyS0 echo -n "A" > /dev/ttyS0; # just print a nice message on screen echo -n "I sent 'A' to ttyS0, time now is "; sleepenh 0; # wait the required time TIMESTAMP=`sleepenh $TIMESTAMP 4.0`; done HINT
This program can be used to get the current time. Just execute: sleepenh 0 BUGS
It is not accurate for a single sleep. Short sleep-times will also not be accurate. SEE ALSO
date(1), sleep(1). AUTHOR
This manual page was written by Pedro Zorzenon Neto. 2008/04/20 SLEEPENH(1)
All times are GMT -4. The time now is 10:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy