- 论坛徽章:
- 1
|
- #!/bin/ksh
- interget tot=0 ave=0
- set -A line # Variable 'line' is an array
- date > stats # Put date in stats file
- vmstat 2 5 >> stats # Put vmstat output in stats file,
- # repeats every 2 seconds, does it 5 times
- exec 3< stats # open access to stats on file descriptor 3
- exec 4> summary # open write access to summary file on fd 4
- read -u3 line # Read date into variable line
- print -u4 $line # Write contents of line to fd 4
- read -u3; read -u3; read -u3; read -u3 # Eliminate header lines
- while read -A -ue line # Read second vmstat line in array
- do
- tot=tot+${line[12]} # Access interrupt count in field 12
- done
- ave=tot/4 # Calculate average
- print "Average number of interrupts during the last 10 seconds is $ave ." # To stdout
- print -u4 "Average number of interrupts during the last 10 seconds is $ave ."
- exit
复制代码 |
|