added some more gpfs commands per-filesystem
[sahlberg/ctdb.git] / tools / ctdb_diagnostics
1 #!/bin/sh
2 # a script to test the basic setup of a CTDB/Samba install 
3 # tridge@samba.org September 2007
4
5 PATH="$PATH:/sbin:/usr/sbin:/usr/lpp/mmfs/bin"
6
7 CONFIG_FILES="/etc/krb5.conf /etc/hosts /etc/ctdb/nodes /etc/sysconfig/ctdb /etc/ctdb/public_addresses /etc/resolv.conf /etc/nsswitch.conf /etc/sysctl.conf /etc/samba/smb.conf /etc/fstab /etc/multipath.conf /etc/pam.d/system-auth /etc/sysconfig/nfs /etc/exports /etc/vsftpd/vsftpd.conf"
8
9 2>&1
10
11 cat <<EOF
12 --------------------------------------------------------------------
13 ctdb_diagnostics starting. This script will gather information about
14 your ctdb cluster. You should send the output of this script along
15 with any ctdb or clustered Samba bug reports.
16 --------------------------------------------------------------------
17 EOF
18
19 date
20
21 error() {
22     msg="$1"
23     echo "ERROR: $msg"
24     NUM_ERRORS=`expr $NUM_ERRORS + 1`
25     echo " ERROR[$NUM_ERRORS]: $msg" >> $ERRORS
26 }
27
28 show_file() {
29     fname="$1"
30     echo "  ================================"
31     echo "  File: $fname"
32     echo "  `ls -l $fname 2>&1`"
33     cat "$fname" 2>&1 | sed 's/^/  /'
34     echo "  ================================"
35 }
36
37 show_all() {
38     echo "running $1 on all nodes"
39     onnode all "hostname; date; $1 2>&1 | sed 's/^/  /'"
40 }
41
42 ERRORS="/tmp/diag_err.$$"
43 NUM_NODES=`wc -l < /etc/ctdb/nodes`
44 MAX_NODE=`expr $NUM_NODES - 1`
45 NUM_ERRORS=0
46 cat <<EOF
47 Diagnosis started on a $NUM_NODES node cluster. The following node list will be used:
48 EOF
49 show_file /etc/ctdb/nodes
50
51
52 cat <<EOF
53 --------------------------------------------------------------------
54 Comping critical config files on all nodes
55 EOF
56
57 for f in $CONFIG_FILES; do
58  [ -r "$f" ] || {
59     error "$f is missing"
60     continue;
61  }
62  show_file $f
63  for i in `seq 0 $MAX_NODE`; do
64      echo "Testing for same config file $f on node $i"
65      tmpf=/tmp/`basename $f`.node$i
66      onnode $i cat $f > $tmpf 2>&1
67      cmp $f $tmpf 2>&1 || {
68          error "File $f is different on node $i"
69          diff -u $f $tmpf
70      }
71      rm -f $tmpf
72  done
73 done
74
75 cat <<EOF
76 --------------------------------------------------------------------
77 Checking for clock drift
78 EOF
79 t=`date +%s`
80 for i in `seq 0 $MAX_NODE`; do
81     t2=`onnode $i date +%s`
82     d=`expr $t2 - $t`
83     if [ $d -gt 30 -o $d -lt -30 ]; then
84         error "time on node $i differs by $d seconds"
85     fi
86 done
87
88 cat <<EOF
89 --------------------------------------------------------------------
90 Showing software versions
91 EOF
92 show_all "uname -a"
93 [ -x /bin/rpm ] && {
94     show_all "rpm -qa | egrep 'samba|ctdb|gpfs'"
95 }
96
97
98 cat <<EOF
99 --------------------------------------------------------------------
100 Showing ctdb status and recent log entries
101 EOF
102 show_all "ctdb status; ctdb ip"
103 show_all "ctdb statistics"
104 show_all "ctdb uptime"
105
106 echo "Showing log.ctdb"
107 show_all "tail -100 /var/log/log.ctdb"
108
109 echo "Showing log.ctdb"
110 show_all "tail -100 /var/log/log.ctdb"
111
112 show_all "tail -200 /var/log/messages"
113 show_all "tail -200 /etc/ctdb/state/vacuum.log"
114 show_all "ls -lRs /var/ctdb"
115 show_all "ls -lRs /etc/ctdb"
116
117
118 cat <<EOF
119 --------------------------------------------------------------------
120 Showing system and process status
121 EOF
122 show_all "df"
123 show_all "df -i"
124 show_all "mount"
125 show_all "w"
126 show_all "ps axfwu"
127 show_all "dmesg"
128 show_all "/sbin/lspci"
129 show_all "dmidecode"
130 show_all "cat /proc/partitions"
131 show_all "cat /proc/cpuinfo"
132 show_all "cat /proc/scsi/scsi"
133 show_all "/sbin/ifconfig -a"
134 show_all "/sbin/ifconfig -a"
135 show_all "/sbin/ip addr list"
136 show_all "/sbin/route -n"
137 show_all "netstat -s"
138 show_all "free"
139 show_all "crontab -l"
140 show_all "sysctl -a"
141 show_all "/sbin/iptables -L -n"
142 show_all "/sbin/iptables -L -n -t nat"
143 show_all "/usr/sbin/rpcinfo -p"
144 show_all "/usr/sbin/showmount -a"
145 show_all "/usr/sbin/showmount -e"
146 show_all "/usr/sbin/nfsstat -v"
147 [ -x /sbin/multipath ] && {
148     show_all "/sbin/multipath -ll"
149 }
150 [ -x /sbin/chkconfig ] && {
151     show_all "/sbin/chkconfig --list"
152 }
153 [ -x /usr/sbin/getenforce ] && {
154     show_all "/usr/sbin/getenforce"
155 }
156 [ -d /proc/net/bonding ] && {
157     for f in /proc/net/bonding/*; do
158         show_all "cat $f"
159     done
160 }
161
162 [ -d /usr/lpp/mmfs ] && {
163 cat <<EOF
164 --------------------------------------------------------------------
165 Showing GPFS status and recent log entries
166 EOF
167  show_all "tail -100 /var/adm/ras/mmfs.log.latest"
168  show_all "/usr/lpp/mmfs/bin/mmlsconfig"
169  show_all "/usr/lpp/mmfs/bin/mmlsfs all"
170  show_all "/usr/lpp/mmfs/bin/mmlsnsd"
171  show_all "/usr/lpp/mmfs/bin/mmlsnsd -X"
172  show_all "/usr/lpp/mmfs/bin/mmfsadm dump version"
173  show_all "/usr/lpp/mmfs/bin/mmfsadm dump waiters"
174  show_all "/usr/lpp/mmfs/bin/mmlsmount all"
175  show_all "/usr/lpp/mmfs/bin/mmlsquota"
176  show_all "/usr/lpp/mmfs/bin/mmlscluster"
177  show_all "/usr/lpp/mmfs/bin/mmlsmgr"
178  devlist=`mmlsfs all|grep ^File.system.attributes | cut -d/ -f3 | cut -d: -f1`
179  for d in $devlist; do
180      show_all mmdf $d
181      show_all mmlsdisk $d
182      show_all mmlsfileset $d
183      show_all mmlspolicy $d
184      show_all mmlssnapshot $d
185  done
186  fslist=`mount|grep type.gpfs|awk '{print $1}'`
187  for fs in $fslist; do
188      show_all "/usr/lpp/mmfs/bin/mmlssnapshot $fs"
189      show_all "/usr/lpp/mmfs/bin/mmlsdisk $fs"
190      show_all "/usr/lpp/mmfs/bin/mmlsfileset $fs"
191  done
192 }
193
194 cat <<EOF
195 --------------------------------------------------------------------
196 Showing Samba status
197 EOF
198 show_all "smbstatus -n -B"
199 show_all "net ads testjoin"
200 show_all "lsof -n | grep smbd"
201 show_all "lsof -n | grep ctdbd"
202 show_all "netstat -tan"
203 show_all "net ads info"
204 show_all "date"
205 show_all "smbclient -U% -L 127.0.0.1"
206 WORKGROUP=`testparm -s --parameter-name=WORKGROUP 2> /dev/null`
207 show_all id "$WORKGROUP/Administrator"
208 show_all "wbinfo -p"
209 show_all "wbinfo --sequence"
210 show_all "smbd -b"
211
212 date
213 echo "Diagnostics finished with $NUM_ERRORS errors"
214
215 [ -r $ERRORS ] && {
216     cat $ERRORS
217     rm -f $ERRORS
218 }
219 exit $NUM_ERRORS
220