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