summaryrefslogtreecommitdiff
path: root/functions/tech-support
blob: 18647f1067635c512f8348d9e74e5c049d8b2c29 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# implement "show tech-support"
# usage: tech-support [ save [ <filename> ] ]
# NOTE: this file is sourced, NOT executed

function header {
    echo
    echo ----------------
    echo "$*"
    echo ----------------
}

# by default send to stdout
OUT=1

DEFAULT_PATH=/opt/vyatta/etc/config/support
DEFAULT_GROUP=users

do_rotate ()
{
  local count=`ls -t $DEFAULT_PATH/*.tech-support.* 2>/dev/null |wc -l`
  if (( count >= 10 )); then
    local dfile=`ls -t $DEFAULT_PATH/*.tech-support.* 2>/dev/null |tail -1`
    rm -f $dfile >&/dev/null \
      && echo "Removed old tech-support output file '$dfile'"
  fi
}

HOSTNAME=`hostname`
CURTIME=`date +%F-%H%M%S`
if [ "$1" == "save" ]; then
  # "save" is specified. save output to file.
  if [ -n "$2" ]; then
    # "<filename>" is specified. use it as the prefix.
    OUT="$2.$HOSTNAME.tech-support.$CURTIME"
  else
    OUT="$HOSTNAME.tech-support.$CURTIME"
  fi
  if [[ $OUT != /* ]]; then
    # it's not absolute path. save in default path.
    mkdir -p $DEFAULT_PATH >& /dev/null
    chgrp $DEFAULT_GROUP $DEFAULT_PATH >& /dev/null
    chmod 775 $DEFAULT_PATH >& /dev/null
    OUT="$DEFAULT_PATH/$OUT"
    do_rotate
  fi
  if ! touch $OUT >& /dev/null; then
    echo "Cannot create tech-support file '$OUT'"
    exit 1
  fi
  echo "Saving output to '$OUT'..."
fi

(
export PATH=/sbin:/usr/sbin:$PATH

header Current time
date

header OFR Version and Package Changes
show version all

header Installed Packages
dpkg -l

header Modules
cat /proc/modules

header "Kernel messages at boot time (/var/log/dmesg)"
cat /var/log/dmesg

header "Recent Kernel messages (dmesg)"
dmesg

header CPU Info
cat /proc/cpuinfo

header Mem Info
cat /proc/meminfo

header PCI Info
lspci

header System Info
${vyatta_bindir}/vyatta-show-dmi

header Interfaces
show interfaces

header Devices
cat /proc/devices

header Partitions
cat /proc/partitions

header Mounts
cat /proc/mounts

header Diskstats
cat /proc/diskstats

header Kernel command line
cat /proc/cmdline

header Interrupts
cat /proc/interrupts

header Load Average
cat /proc/loadavg

header /opt/vyatta/etc/config/config.boot
cat /opt/vyatta/etc/config/config.boot

header Running configuration
show configuration

header \''ps -ef'\'
ps -ef

header \''df -h -x squashfs'\'
df -h -x squashfs

header \''lsof -Pi'\'
lsof -Pi

header \'free\'
free

header /etc/apt/sources.list
cat /etc/apt/sources.list

header /etc/ipsec.conf
cat /etc/ipsec.conf

if [ -r /etc/ipsec.secrets ]; then
    header /etc/ipsec.secrets
    cat /etc/ipsec.secrets
fi

header \''ls -l /etc/rc?.d'\'
ls -l /etc/rc?.d

header /etc/rc.local
cat /etc/rc.local

header \''iptables -L -vn'\'
sudo /sbin/iptables -L -vn

header \''iptables -t nat -L -vn'\'
sudo /sbin/iptables -t nat -L -vn

header \''iptables -t mangle -L -vn'\'
sudo /sbin/iptables -t mangle -L -vn

header \''iptables -t raw -L -vn'\'
sudo /sbin/iptables -t raw -L -vn

header \''show ip route'\'
show ip route

header $HOME/.bash_history
cat $HOME/.bash_history

header \''show vrrp'\'
show vrrp

header \''last -ix'\'
last -ix

header wanrouter hwprobe
wanrouter hwprobe

header wanrouter version
wanrouter version

header wanrouter debug
wanrouter debug

header wanrouter summary
wanrouter summary

header wanrouter status
wanrouter status

header wanrouter modules
wanrouter modules

if [ -e /etc/wanpipe/wanrouter.rc ]; then
   header /etc/wanpipe/wanrouter.rc
   cat /etc/wanpipe/wanrouter.rc
fi

for i in /etc/wanpipe/interfaces/* ; do
    if [ -e $i ]; then
       ifname=`basename $i`
       header "wanpipemon -i $ifname -c sc"
       wanpipemon -i $ifname -c sc

       header "wanpipemon -i $ifname -c so"
       wanpipemon -i $ifname -c so

       header "wanpipemon -i $ifname -c xcv"
       wanpipemon -i $ifname -c xcv

       header "wanpipemon -i $ifname -c xru"
       wanpipemon -i $ifname -c xru

       header "wanpipemon -i $ifname -c xm"
       wanpipemon -i $ifname -c xm

       header "wanpipemon -i $ifname -c xl"
       wanpipemon -i $ifname -c xl

       header "wanpipemon -i $ifname -c Ta"
       wanpipemon -i $ifname -c Ta
   fi
done

for i in /etc/wanpipe/wanpipe*.conf ; do
    if [ -e $i ]; then
       header $i
       cat $i
    fi
done

header wanrouter conflog
wanrouter conflog

header "END OF TECH-SUPPORT FILE"
) 1>&$OUT 2>&1

if [ $OUT != "1" ]; then
  chgrp $DEFAULT_GROUP $OUT >& /dev/null
  chmod 664 $OUT >& /dev/null
  echo "Done"
fi