Linux Performance metrics info collector Shell Scripts
The shell script can help to collect Linux related performance matrics. It will execute the Linux built-in performance tools such as top, vmstat, iostat and then collect related results into log.
Code Source : http://people.redhat.com/mbehm/
if [ “$1” == “”]; then echo “Usage: ./perf1.sh<logfile-name>” exit 1 fiFILE=$1 ITER=10if [test -e $FILE]; then echo “WARNING: $FILE exists — will NOT overwrite” exit 1 fifunction log () { d=’date’ echo “$d: $1” echo “==================================================” >> $FILE echo “$d: $1″ >> $FILEif test x”$2″ != x””; then shift fi $* >> $FILE 2>&1 }function logi () { d=’date’ printf “$d: %-20.20s (PASS $1 of $ITER)\n” $2 echo “==================================================” >> $FILE printf “$d: %-20.20s (PASS $1 of $ITER)\n” $2 >> $FILE shift if test x”$2″ != x””; then shift fi $* >> $FILE 2>&1 }function ccc () { log $1 cat $1 }function ccci () { logi $1 $2 cat $2 } function note () { echo “‘date’: (NOTE: $*)” } function banner () { d=’date’ echo “==================================================” echo “===== $d: $* =====” echo “==================================================” >> $FILE echo “===== $d: $* =====” >> $FILE } banner “Start of Testing ($FILE)” banner General System Information log uname uname -a log free log df df -h log mount log lsmod log lspci lspci -v log dmidecode log route route -n log ifconfig log “ip rule ls” ip rule ls log “ip route ls” ip route ls log iptables “iptables -L -n -v” log sysctl sysctl -a ccc /proc/cpuinfo ccc /proc/meminfo ccc /proc/net/dev ccc /proc/interrupts ccc /proc/devices ccc /proc/cmdline ccc /proc/scsi/scsi ccc /etc/modules.conf ccc /var/log/dmesg banner Performance Snapshot log ps ps auxwww log sar sar -A let t=”10*$ITER” note “The following takes about $t seconds”log “vmstat” vmstat $ITER 10 note “The following takes about $t seconds” log “iostat” iostat -k $ITER 10 note “Each pass takes 10 seconds” for i in ‘seq 1 $ITER’; do note “**** PASS $i of $ITER” logi $i uptime logi $i free ccci $i /proc/interrupts ccci $i /proc/stat logi $i ifconfig ifconfig -a sleep 10 done banner “End of Testing ($FILE)”
|