1 #!/bin/sh 2 3 #log script, by john stultz (jstultz (at] us.ibm.com) 4 # other bits by darrick wong (djwong (at] us.ibm.com) 5 6 # Copyright (C) 2003-2006 IBM 7 # 8 # This program is free software; you can redistribute it and/or 9 # modify it under the terms of the GNU General Public License as 10 # published by the Free Software Foundation; either version 2 of the 11 # License, or (at your option) any later version. 12 # 13 # This program is distributed in the hope that it will be useful, but 14 # WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 # General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program; if not, write to the Free Software 20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 21 # 02111-1307, USA. 22 23 24 trap 'exit 0' 15 25 26 function startup() { 27 # change into the pounder log dir 28 if [ -x $POUNDER_LOGDIR ]; then 29 cd $POUNDER_LOGDIR 30 fi 31 #create log dir 32 mkdir statlogs 33 cd statlogs 34 } 35 36 37 INFOFILE=info 38 #generic system info 39 function sysinfo() { 40 uname -a >> $INFOFILE 41 echo -e "\n[cpuinfo]=================" >>$INFOFILE 42 cat /proc/cpuinfo >> $INFOFILE 43 echo -e "\n[meminfo]=================" >>$INFOFILE 44 cat /proc/meminfo >> $INFOFILE 45 echo -e "\n[ifinfo]=================" >>$INFOFILE 46 /sbin/ifconfig >> $INFOFILE 47 echo -e "\n[sysctl]=================" >>$INFOFILE 48 sysctl -a >> $INFOFILE 49 } 50 51 PROC_ENTRIES="buddyinfo diskstats meminfo slabinfo net/netstat net/snmp" 52 function procinfo() { 53 #get a timestamp 54 NOW=`date` 55 for i in $PROC_ENTRIES 56 do 57 logfile=`basename $i` 58 echo -e "\n$NOW" >> $logfile.log 59 cat /proc/$i >> $logfile.log 60 sleep 1 61 done 62 } 63 64 # ten second delay; run 150s before outputting timestamp 65 DELAY=10 66 COUNT=15 67 68 #single shot logging apps 69 function singleshots(){ 70 echo > vmstat.log 71 echo > iostat.log 72 73 while true; do 74 vmstat $DELAY $COUNT >> vmstat.log 75 NOW=`date` 76 echo -e "\n$NOW\n" >> vmstat.log 77 done & 78 79 IOSTAT=`which iostat 2> /dev/null` 80 if [ -n "$IOSTAT" -a -x "$IOSTAT" ]; then 81 while true; do 82 iostat -x $DELAY $COUNT >> iostat.log 83 NOW=`date` 84 echo -e "\n$NOW\n" >> iostat.log 85 done & 86 fi 87 } 88 89 # periodically run apps & functions 90 function runlogging() { 91 CMDS="procinfo" 92 while true 93 do 94 for i in $CMDS 95 do 96 $i 97 sleep 1 98 done 99 sleep $DELAY 100 done 101 } 102 103 trap 'exit 0' 15 104 105 startup $* 106 sysinfo 107 singleshots 108 tail -f /var/log/messages /var/log/syslog /var/log/daemon.log /var/log/kern.log /var/log/warn /var/log/faillog > system_logs & 109 cp -pRdu $POUNDER_HOME/README . 110 runlogging 111 112 exit 0 113