forked from ibm-s390-linux/smc-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smc_dbg
executable file
·113 lines (93 loc) · 2.13 KB
/
smc_dbg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Copyright IBM Corp. 2019
VERSION="1.8.2";
function usage() {
echo;
echo "Usage: smc_dbg [ OPTIONS ]";
echo;
echo "Collect debug information";
echo;
echo " -h, --help display this message";
echo " -t, --tgz generate .tgz file";
echo " -v, --version display version info";
echo;
}
function redirect() {
if [ "$tgz" == "on" ]; then
exec &>$tmpdir/$1;
else
echo;
fi
}
tgz="off";
ARCH=`uname -m | cut -c1-4`;
args=`getopt -u -o hvt -l help,version,tgz -- $*`;
[ $? -ne 0 ] && exit 1;
set -- $args;
while [ $# -gt 0 ]; do
case $1 in
"-h" | "--help" )
usage;
exit 0;;
"-t" | "--tgz" )
tgz="on";;
"-v" | "--version" )
echo "smc_dbg utility, smc-tools-$VERSION";
exit 0;;
* )
esac
shift;
done
if [ "$tgz" == "on" ]; then
exec 3>&1 4>&2
tmpdir=`mktemp -d /tmp/smc_dbg-XXXXXX`;
fi
redirect version.txt;
smcss -v
smc_dbg -v
smc_pnet -v
smc_rnics -v
smc_chk -v
smcd -v
smcr -v
if [ "$ARCH" == "s390" ]; then
redirect devices.txt;
echo "CCW Devices:"
printf " Device CHPID Port PNET ID\n";
echo " -------------------------------------------";
for device in `ls -1 /sys/bus/ccwgroup/devices`; do
chpid=`cat /sys/bus/ccwgroup/devices/$device/chpid | tr [A-F] [a-f]`;
osaport=`cat /sys/bus/ccwgroup/devices/$device/portno`;
iface=`cat /sys/bus/ccwgroup/devices/$device/if_name`;
printf " %8s %4s %-4s %s\n" $device 0x$chpid $osaport `smc_chk -i $iface`;
done
echo;
echo "PCI Devices:"
smc_rnics | sed 's/^/ /';
redirect smcss_smcd;
smcss --smcd;
fi
redirect smcss_all.txt;
smcss --all --debug;
redirect smcss_smcr;
smcss --smcr;
redirect pnet_table.txt;
smc_pnet --show;
redirect smcr_links.txt;
smcr -d linkgroup link-show;
redirect smcd_lgs.txt;
smcd -d linkgroup show;
redirect smcd_info.txt;
smcd info;
redirect smcd_stats.txt;
smcd -d stats;
redirect smcr_stats.txt;
smcr -d stats;
if [ "$tgz" == "on" ]; then
exec >&3 2>&4
cd /tmp;
tar cvfz $tmpdir.tgz `basename $tmpdir` >/dev/null 2>&1;
rm -rf $tmpdir;
echo "Debug output written to $tmpdir.tgz";
fi
exit 0;