• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3#log script, by john stultz (jstultz@us.ibm.com)
4# other bits by darrick wong (djwong@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
24trap 'exit 0' 15
25
26function 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
37INFOFILE=info
38#generic system info
39function sysinfo() {
40	uname -a >> $INFOFILE
41	printf "\n[cpuinfo]=================\n" >>$INFOFILE
42	cat /proc/cpuinfo >> $INFOFILE
43	printf "\n[meminfo]=================\n" >>$INFOFILE
44	cat /proc/meminfo >> $INFOFILE
45	printf "\n[ifinfo]=================\n" >>$INFOFILE
46	/sbin/ifconfig >> $INFOFILE
47	printf "\n[sysctl]=================\n" >>$INFOFILE
48	sysctl -a >> $INFOFILE
49}
50
51PROC_ENTRIES="buddyinfo diskstats meminfo slabinfo net/netstat net/snmp"
52function procinfo() {
53	#get a timestamp
54	NOW=`date`
55	for i in $PROC_ENTRIES
56	do
57		logfile=`basename $i`
58		printf "\n$NOW\n" >> $logfile.log
59		cat /proc/$i >> $logfile.log
60		sleep 1
61	done
62}
63
64# ten second delay; run 150s before outputting timestamp
65DELAY=10
66COUNT=15
67
68#single shot logging apps
69function singleshots(){
70	echo > vmstat.log
71	echo > iostat.log
72
73	while true; do
74		vmstat $DELAY $COUNT >> vmstat.log
75		NOW=`date`
76		printf "\n$NOW\n\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			printf "\n$NOW\n\n" >> iostat.log
85		done &
86	fi
87}
88
89# periodically run apps & functions
90function 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
103trap 'exit 0' 15
104
105startup $*
106sysinfo
107singleshots
108tail -f /var/log/messages /var/log/syslog /var/log/daemon.log /var/log/kern.log /var/log/warn /var/log/faillog > system_logs &
109cp -pRdu $POUNDER_HOME/README .
110runlogging
111
112exit 0
113