]>
Commit | Line | Data |
---|---|---|
dbf6a266 | 1 | #!/bin/sh |
78403150 | 2 | # Copyright (c) 2004-2014 Apple Inc. |
edebe297 | 3 | # |
dbf6a266 A |
4 | # get-mobility-info |
5 | # | |
6 | # Collect system & network configuration information. | |
7 | # | |
8 | ||
dbf6a266 A |
9 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
10 | ||
085a2e6a A |
11 | # |
12 | # Disclaimer | |
13 | # | |
14 | cat <<_END_OF_DISCLAIMER | |
15 | ||
16 | This diagnostic tool generates files that allow Apple to investigate issues | |
17 | with your computer and help Apple to improve its products. The generated files | |
18 | may contain some of your personal information, which may include, but not be | |
19 | limited to, the serial number or similar unique number for your device, your | |
20 | user name, or your computer name. The information is used by Apple in | |
21 | accordance with its privacy policy (www.apple.com/privacy) and is not shared | |
22 | with any third party. By enabling this diagnostic tool and sending a copy of | |
78403150 | 23 | the generated files to Apple, you are consenting to Apple's use of the content |
085a2e6a A |
24 | of such files. |
25 | ||
26 | _END_OF_DISCLAIMER | |
27 | ||
28 | /bin/echo "Press 'Enter' to continue." | |
29 | read reply | |
30 | ||
31 | # | |
32 | # Setup | |
33 | # | |
dbf6a266 A |
34 | PRIV="" |
35 | if [ ${EUID} -ne 0 ]; then | |
36 | PRIV="sudo" | |
37 | fi | |
38 | ||
5e9ce69e A |
39 | if [ -x /usr/bin/tail ]; then |
40 | TAIL_2000="/usr/bin/tail -n 2000" | |
41 | TAIL_25000="/usr/bin/tail -n 25000" | |
42 | else | |
43 | TAIL_2000="/bin/cat" | |
44 | TAIL_25000="/bin/cat" | |
45 | fi | |
46 | ||
edebe297 A |
47 | OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`" |
48 | OUTDIR="/var/tmp" | |
49 | if [ -d ~/Desktop ]; then | |
50 | OUTDIR=~/Desktop | |
a40a14f8 | 51 | elif [ "`readlink /tmp`" = "private/var/tmp" ]; then |
5e9ce69e | 52 | OUTDIR=/Library/Logs/CrashReporter |
a40a14f8 | 53 | mkdir -p ${OUTDIR} |
edebe297 A |
54 | fi |
55 | ||
56 | umask 077 | |
57 | ||
58 | WORKDIR=`mktemp -d -q "/tmp/${OUT}"` | |
59 | if [ $? -ne 0 ]; then | |
60 | echo "Could not create snapshot directory" | |
61 | exit 1 | |
62 | fi | |
63 | ||
a40a14f8 A |
64 | GZ_EXT="" |
65 | GZ_OPT="" | |
66 | if [ -x /usr/bin/gzip ]; then | |
67 | GZ_EXT=".gz" | |
68 | GZ_OPT="-z" | |
69 | fi | |
70 | ||
71 | ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"` | |
edebe297 A |
72 | if [ $? -ne 0 ]; then |
73 | echo "Could not create snapshot archive" | |
74 | rm -rf "${WORKDIR}" | |
75 | exit 1 | |
76 | fi | |
77 | ||
78 | cd "${WORKDIR}" | |
dbf6a266 | 79 | |
17d3ee29 A |
80 | echo "" |
81 | echo "Please wait, collecting information and statistics" | |
82 | echo "" | |
83 | ||
5e9ce69e | 84 | # |
78403150 | 85 | # Execute network reachability/DNS commands early |
5e9ce69e | 86 | # |
78403150 A |
87 | echo "#" > reachability-info |
88 | echo '# scutil -d -v -r www.apple.com "" no-server' >> reachability-info | |
89 | echo "#" >> reachability-info | |
90 | scutil -d -v -r www.apple.com "" no-server >> reachability-info 2>&1 | |
91 | ||
92 | echo "#" >> reachability-info | |
93 | echo '# scutil -d -v -r 0.0.0.0 no-server' >> reachability-info | |
94 | echo "#" >> reachability-info | |
95 | scutil -d -v -r 0.0.0.0 no-server >> reachability-info 2>&1 | |
96 | ||
5e9ce69e A |
97 | if [ -x /usr/bin/dig -a -f /etc/resolv.conf ]; then |
98 | /usr/bin/dig -t any -c any www.apple.com > dig-results 2>/dev/null | |
99 | fi | |
100 | ||
101 | # | |
78403150 A |
102 | # Signal "networkd" to log its "state" info. This logging will continue while |
103 | # we execute a few other commands and should be complete by the time we collect | |
104 | # the log content. | |
5e9ce69e A |
105 | # |
106 | if [ -x /usr/bin/killall ]; then | |
78403150 A |
107 | # |
108 | # request networkd state | |
109 | # | |
110 | ${PRIV} /usr/bin/killall -INFO networkd 2>/dev/null | |
111 | ||
112 | # | |
113 | # discoveryd info | |
114 | # | |
115 | if [ -x /usr/libexec/discoveryd -a -x /usr/sbin/discoveryutil ]; then | |
116 | ${PRIV} pgrep -q -x discoveryd | |
117 | if [ $? -eq 0 ]; then | |
118 | P_ARG="" | |
119 | case "`${PRIV} discoveryutil help 2>&1`" in | |
120 | Warning:* ) | |
121 | P_ARG="--priv" | |
122 | ;; | |
123 | esac | |
124 | # | |
125 | # upgrade logging (if needed) | |
126 | # | |
127 | CLASS_o=`${PRIV} discoveryutil ${P_ARG} logclass` | |
128 | CLASS_n=`${PRIV} discoveryutil ${P_ARG} logclass Cache` | |
129 | ||
130 | LEVEL_o=`${PRIV} discoveryutil ${P_ARG} loglevel | awk '{ print $5 }'` | |
131 | if [ ${LEVEL_o} -le 1 ]; then | |
132 | LEVEL_n=`${PRIV} discoveryutil ${P_ARG} loglevel Intermediate | awk '{ print $5 }'` | |
133 | else | |
134 | LEVEL_n=${LEVEL_o} | |
135 | fi | |
136 | ||
137 | cp /dev/null discoveryd-info | |
138 | for c in \ | |
139 | clientlisteners \ | |
140 | configinterfaces \ | |
141 | configresolvers \ | |
142 | dnsproxystate \ | |
143 | mdnsbrowses \ | |
144 | mdnscachecontents \ | |
145 | mdnscachestats \ | |
146 | mdnslisteners \ | |
147 | mdnsregistrations \ | |
148 | nattraversals \ | |
149 | udnscachecontents \ | |
150 | udnscachestats \ | |
151 | udnsresolvers \ | |
152 | udnsunanswered \ | |
153 | ||
154 | do | |
155 | echo "#" >> discoveryd-info | |
156 | echo "# discoveryutil ${c}" >> discoveryd-info | |
157 | echo "#" >> discoveryd-info | |
158 | ${PRIV} discoveryutil ${P_ARG} --timeout ${c} >> discoveryd-info | |
159 | done | |
160 | ||
161 | if [ "$CLASS_o" != "$CLASS_n" ]; then | |
162 | # | |
163 | # restore log settings | |
164 | # | |
165 | ${PRIV} discoveryutil ${P_ARG} lognoclass Cache >/dev/null | |
166 | fi | |
167 | ||
168 | if [ "$LEVEL_o" != "$LEVEL_n" ]; then | |
169 | ${PRIV} discoveryutil ${P_ARG} loglevel ${LEVEL_o} >/dev/null | |
170 | fi | |
171 | ||
172 | ${PRIV} cat /var/run/com.apple.discoveryd-trace.sb > com.apple.discoveryd-trace.sb 2>/dev/null | |
173 | fi | |
174 | fi | |
175 | ||
5e9ce69e A |
176 | sleep 1 |
177 | fi | |
178 | ||
dbf6a266 A |
179 | # |
180 | # processes | |
181 | # | |
5e9ce69e A |
182 | if [ -x /bin/ps ]; then |
183 | /bin/ps axlww > ps 2>&1 | |
184 | fi | |
dbf6a266 A |
185 | |
186 | # | |
187 | # network interface configuration | |
188 | # | |
5e9ce69e A |
189 | if [ -x /sbin/ifconfig ]; then |
190 | /sbin/ifconfig -a -L -b -m -r -v -v > ifconfig 2>&1 | |
191 | if [ $? -ne 0 ]; then | |
192 | /sbin/ifconfig -a > ifconfig 2>&1 | |
193 | fi | |
6bb65964 | 194 | fi |
dbf6a266 A |
195 | |
196 | # | |
197 | # network route configuration | |
198 | # | |
5e9ce69e A |
199 | if [ -x /usr/sbin/netstat ]; then |
200 | /usr/sbin/netstat -n -r -a -l > netstat 2>&1 | |
201 | fi | |
dbf6a266 A |
202 | |
203 | # | |
204 | # DHCP configuration | |
205 | # | |
5e9ce69e A |
206 | if [ -x /sbin/ifconfig ]; then |
207 | for if in `/sbin/ifconfig -l` | |
208 | do | |
209 | case ${if} in | |
210 | lo* ) ;; | |
211 | en* ) ipconfig getpacket ${if} > ipconfig-${if} 2>&1 | |
212 | ;; | |
213 | esac | |
214 | done | |
215 | fi | |
dbf6a266 | 216 | |
edebe297 A |
217 | # |
218 | # AirPort info | |
219 | # | |
220 | if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then | |
221 | /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \ | |
222 | > airport 2>&1 | |
223 | fi | |
224 | ||
5e9ce69e A |
225 | # |
226 | # collect wifi dump | |
227 | # | |
78403150 | 228 | if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then |
5e9ce69e A |
229 | ${PRIV} /usr/bin/wdutil dump |
230 | mkdir -p "wifi_dump" | |
231 | /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \ | |
232 | | while read log | |
233 | do | |
234 | if [ -f "${log}" ]; then | |
235 | b="`basename ${log}`" | |
236 | ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1 | |
237 | fi | |
238 | done | |
239 | fi | |
240 | ||
dbf6a266 A |
241 | # |
242 | # OS info | |
243 | # | |
244 | if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then | |
245 | cat /System/Library/CoreServices/SystemVersion.plist \ | |
edebe297 | 246 | > SystemVersion.plist 2>&1 |
dbf6a266 | 247 | fi |
dbf6a266 A |
248 | |
249 | # | |
250 | # IOKit info | |
251 | # | |
5e9ce69e A |
252 | if [ -x /usr/sbin/ioreg ]; then |
253 | /usr/sbin/ioreg -i -l -w 0 > ioreg 2>&1 | |
254 | /usr/sbin/ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1 | |
255 | fi | |
edebe297 | 256 | |
17d3ee29 A |
257 | # |
258 | # Power Management info | |
259 | # | |
5e9ce69e A |
260 | if [ -x /usr/bin/pmset ]; then |
261 | echo "#" > pmset | |
262 | echo "# pmset -g everything" >> pmset | |
263 | echo "#" >> pmset | |
264 | /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset | |
265 | fi | |
17d3ee29 | 266 | |
edebe297 A |
267 | # |
268 | # Host name | |
269 | # | |
5e9ce69e A |
270 | if [ -x /bin/hostname ]; then |
271 | /bin/hostname > hostname 2>&1 | |
272 | fi | |
dbf6a266 A |
273 | |
274 | # | |
275 | # Host configuration | |
276 | # | |
5e9ce69e A |
277 | if [ -x /usr/bin/hostinfo ]; then |
278 | /usr/bin/hostinfo > hostinfo 2>&1 | |
279 | fi | |
dbf6a266 | 280 | if [ -e /etc/hostconfig ]; then |
edebe297 | 281 | cat /etc/hostconfig > etc.hostconfig 2>&1 |
dbf6a266 A |
282 | fi |
283 | ||
284 | # | |
285 | # DNS configuration | |
286 | # | |
edebe297 | 287 | scutil --dns > dns-configuration 2>&1 |
dbf6a266 | 288 | if [ -e /etc/resolv.conf ]; then |
edebe297 | 289 | cat /etc/resolv.conf > etc.resolv.conf 2>&1 |
dbf6a266 A |
290 | fi |
291 | if [ -e /var/run/resolv.conf ]; then | |
edebe297 | 292 | cat /var/run/resolv.conf > var.run.resolv.conf 2>&1 |
dbf6a266 | 293 | fi |
5e9ce69e A |
294 | if [ -e /etc/resolver ]; then |
295 | tar -c -H /etc/resolver > etc.resolver.tar 2>/dev/null | |
296 | fi | |
dbf6a266 A |
297 | |
298 | # | |
edebe297 | 299 | # Proxy configuration |
dbf6a266 | 300 | # |
17d3ee29 A |
301 | scutil -d -v --proxy > proxy-configuration 2>&1 |
302 | ||
303 | # | |
304 | # Network information | |
305 | # | |
5e9ce69e A |
306 | if [ -x /sbin/ifconfig ]; then |
307 | echo "#" > network-information | |
308 | echo "# scutil --nwi" >> network-information | |
309 | echo "#" >> network-information | |
310 | scutil --nwi >> network-information 2>&1 | |
311 | for if in `/sbin/ifconfig -l` | |
312 | do | |
313 | echo "" >> network-information | |
314 | echo "#" >> network-information | |
315 | echo "# scutil --nwi ${if}" >> network-information | |
316 | echo "#" >> network-information | |
317 | scutil --nwi ${if} >> network-information 2>&1 | |
318 | done | |
319 | fi | |
dbf6a266 A |
320 | |
321 | # | |
322 | # System / network preferences | |
323 | # | |
324 | for f in \ | |
325 | /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \ | |
326 | /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \ | |
327 | /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \ | |
328 | /Library/Preferences/SystemConfiguration/com.apple.nat.plist \ | |
edebe297 | 329 | /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \ |
a40a14f8 | 330 | /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \ |
dbf6a266 | 331 | /Library/Preferences/SystemConfiguration/preferences.plist \ |
a40a14f8 | 332 | /Library/Preferences/com.apple.alf.plist \ |
dbf6a266 | 333 | /Library/Preferences/com.apple.sharing.firewall.plist \ |
78403150 A |
334 | /Library/Preferences/com.apple.networkextension.plist \ |
335 | /Library/Preferences/com.apple.networkextension.control.plist \ | |
336 | /Library/Preferences/com.apple.networkextension.necp.plist \ | |
6bb65964 | 337 | /Library/Preferences/com.apple.wwand.plist \ |
dbf6a266 A |
338 | |
339 | do | |
edebe297 A |
340 | if [ -e "${f}" ]; then |
341 | b="`basename ${f}`" | |
342 | cat "${f}" > "${b}" 2>&1 | |
dbf6a266 A |
343 | fi |
344 | done | |
345 | ||
5e9ce69e A |
346 | # |
347 | # System / network preferences (from other volumes) | |
348 | # | |
78403150 | 349 | /bin/ls /Volumes 2>/dev/null \ |
5e9ce69e A |
350 | | while read volume |
351 | do | |
352 | V_PATH="/Volumes/${volume}" | |
78403150 A |
353 | if [ -h "${V_PATH}" ]; then |
354 | # if the path is a symlink | |
355 | continue | |
356 | fi | |
5e9ce69e A |
357 | for f in \ |
358 | /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \ | |
359 | /Library/Preferences/SystemConfiguration/preferences.plist \ | |
360 | ||
361 | do | |
362 | if [ -f "${V_PATH}/${f}" ]; then | |
363 | mkdir -p "OtherPreferences/${volume}" | |
364 | b="`basename ${f}`" | |
365 | cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1 | |
366 | fi | |
367 | done | |
368 | done | |
369 | ||
6bb65964 A |
370 | # |
371 | # InternetSharing | |
372 | # | |
373 | if [ -e /etc/bootpd.plist ]; then | |
374 | cat /etc/bootpd.plist > bootpd.plist 2>&1 | |
17d3ee29 | 375 | cat /etc/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null |
6bb65964 A |
376 | elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then |
377 | cat /Library/Preferences/SystemConfiguration/bootpd.plist > bootpd.plist 2>&1 | |
17d3ee29 | 378 | cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null |
6bb65964 A |
379 | fi |
380 | ||
dbf6a266 A |
381 | # |
382 | # configd's cache | |
383 | # | |
17d3ee29 | 384 | ${PRIV} scutil -p --snapshot |
6bb65964 A |
385 | if [ -f /var/tmp/configd-store.plist ]; then |
386 | cat /var/tmp/configd-store.plist > configd-store.plist 2>&1 | |
dbf6a266 | 387 | fi |
6bb65964 A |
388 | if [ -f /var/tmp/configd-pattern.plist ]; then |
389 | cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1 | |
dbf6a266 | 390 | fi |
6bb65964 A |
391 | if [ -f /var/tmp/configd-session.plist ]; then |
392 | cat /var/tmp/configd-session.plist > configd-session.plist 2>&1 | |
edebe297 A |
393 | fi |
394 | if [ -f /var/tmp/configd-state ]; then | |
395 | cat /var/tmp/configd-state > configd-state 2>&1 | |
dbf6a266 | 396 | fi |
17d3ee29 | 397 | if [ -f /var/tmp/configd-reachability ]; then |
78403150 | 398 | cat /var/tmp/configd-reachability > configd-reachability 2>&1 |
6bb65964 A |
399 | fi |
400 | ||
dbf6a266 A |
401 | # |
402 | # mounted filesystems | |
403 | # | |
edebe297 | 404 | mount > mounted-filesystems 2>&1 |
dbf6a266 | 405 | |
5e9ce69e | 406 | ${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null |
dbf6a266 A |
407 | |
408 | # | |
409 | # kernel extensions statistic | |
410 | # | |
edebe297 | 411 | if [ -x /usr/sbin/kextstat ]; then |
5e9ce69e | 412 | /usr/sbin/kextstat > kextstat 2>&1 |
dbf6a266 A |
413 | fi |
414 | ||
415 | # | |
416 | # network statistics | |
417 | # | |
78403150 | 418 | /bin/echo -n "" > network-statistics |
5e9ce69e A |
419 | |
420 | if [ -x /usr/sbin/arp ]; then | |
421 | echo "#" >> network-statistics | |
422 | echo "# arp -n -a" >> network-statistics | |
423 | echo "#" >> network-statistics | |
424 | /usr/sbin/arp -n -a >> network-statistics 2>&1 | |
425 | fi | |
426 | ||
427 | if [ -x /usr/sbin/netstat ]; then | |
428 | echo "#" >> network-statistics | |
78403150 | 429 | echo "# netstat -A -a -l -n" >> network-statistics |
5e9ce69e | 430 | echo "#" >> network-statistics |
78403150 | 431 | /usr/sbin/netstat -A -a -l -n >> network-statistics 2>&1 |
5e9ce69e A |
432 | |
433 | echo "#" >> network-statistics | |
434 | echo "# netstat -s" >> network-statistics | |
435 | echo "#" >> network-statistics | |
436 | /usr/sbin/netstat -s >> network-statistics 2>&1 | |
437 | ||
438 | echo "#" >> network-statistics | |
439 | echo "# netstat -mmm" >> network-statistics | |
440 | echo "#" >> network-statistics | |
441 | /usr/sbin/netstat -mmm >> network-statistics 2>&1 | |
442 | ||
443 | echo "#" >> network-statistics | |
444 | echo "# netstat -i -n -d" >> network-statistics | |
445 | echo "#" >> network-statistics | |
446 | /usr/sbin/netstat -i -n -d >> network-statistics 2>&1 | |
447 | ||
448 | echo "#" >> network-statistics | |
449 | echo "# netstat -g -n -s" >> network-statistics | |
450 | echo "#" >> network-statistics | |
451 | /usr/sbin/netstat -g -n -s >> network-statistics 2>&1 | |
452 | ||
453 | echo "#" >> network-statistics | |
454 | echo "# netstat -i -x R" >> network-statistics | |
455 | echo "#" >> network-statistics | |
456 | /usr/sbin/netstat -i -x R >> network-statistics 2>&1 | |
457 | echo "#" >> network-statistics | |
458 | ||
459 | echo "# netstat -a -n -p mptcp" >> network-statistics | |
460 | echo "#" >> network-statistics | |
461 | /usr/sbin/netstat -a -n -p mptcp >> network-statistics 2>/dev/null | |
462 | ||
463 | echo "#" >> network-statistics | |
464 | echo "# netstat -s -p mptcp" >> network-statistics | |
465 | echo "#" >> network-statistics | |
466 | /usr/sbin/netstat -s -p mptcp >> network-statistics 2>/dev/null | |
467 | ||
468 | if [ -x /sbin/ifconfig ]; then | |
469 | for if in `/sbin/ifconfig -l` | |
470 | do | |
471 | `/sbin/ifconfig -v ${if} | grep -q TXSTART` | |
472 | if [ $? -eq 0 ]; then | |
473 | echo "#" >> network-statistics | |
474 | echo "# netstat -qq -I ${if}" >> network-statistics | |
475 | echo "#" >> network-statistics | |
476 | /usr/sbin/netstat -qq -I ${if} >> network-statistics 2>&1 | |
477 | fi | |
478 | `/sbin/ifconfig -v ${if} | grep -q RXPOLL` | |
479 | if [ $? -eq 0 ]; then | |
480 | echo "#" >> network-statistics | |
481 | echo "# netstat -Q -I ${if}" >> network-statistics | |
482 | echo "#" >> network-statistics | |
483 | /usr/sbin/netstat -Q -I ${if} >> network-statistics 2>&1 | |
484 | fi | |
485 | done | |
486 | fi | |
487 | fi | |
17d3ee29 | 488 | |
6bb65964 | 489 | if [ -x /usr/sbin/ndp ]; then |
a40a14f8 | 490 | echo "#" >> network-statistics |
6bb65964 | 491 | echo "# ndp -n -a" >> network-statistics |
a40a14f8 | 492 | echo "#" >> network-statistics |
5e9ce69e | 493 | /usr/sbin/ndp -n -a >> network-statistics 2>&1 |
edebe297 | 494 | |
a40a14f8 | 495 | echo "#" >> network-statistics |
6bb65964 | 496 | echo "# ndp -n -p" >> network-statistics |
a40a14f8 | 497 | echo "#" >> network-statistics |
5e9ce69e | 498 | /usr/sbin/ndp -n -p >> network-statistics 2>&1 |
dbf6a266 | 499 | |
6bb65964 A |
500 | echo "#" >> network-statistics |
501 | echo "# ndp -n -r" >> network-statistics | |
502 | echo "#" >> network-statistics | |
5e9ce69e | 503 | /usr/sbin/ndp -n -r >> network-statistics 2>&1 |
17d3ee29 | 504 | |
5e9ce69e A |
505 | if [ -x /sbin/ifconfig ]; then |
506 | for if in `/sbin/ifconfig -l` | |
507 | do | |
508 | echo "#" >> network-statistics | |
509 | echo "# ndp -i ${if}" >> network-statistics | |
510 | echo "#" >> network-statistics | |
511 | /usr/sbin/ndp -i ${if} >> network-statistics 2>&1 | |
512 | done | |
513 | fi | |
6bb65964 | 514 | fi |
edebe297 | 515 | |
6bb65964 A |
516 | if [ -x /sbin/pfctl ]; then |
517 | echo "#" > pf | |
518 | echo "# pfctl -s all" >> pf | |
519 | echo "#" >> pf | |
5e9ce69e | 520 | ${PRIV} /sbin/pfctl -s all >> pf 2>&1 |
6bb65964 A |
521 | echo "==============================" >> pf |
522 | echo "#" >> pf | |
523 | echo "# pfctl -s References" >> pf | |
524 | echo "#" >> pf | |
5e9ce69e | 525 | ${PRIV} /sbin/pfctl -s References >> pf 2>&1 |
17d3ee29 | 526 | for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null` |
6bb65964 A |
527 | do |
528 | echo "==============================" >> pf | |
529 | echo "#" >> pf | |
530 | echo "# pfctl -a ${ANCHOR} -s all" >> pf | |
531 | echo "#" >> pf | |
5e9ce69e | 532 | ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1 |
6bb65964 A |
533 | done |
534 | fi | |
edebe297 | 535 | |
78403150 A |
536 | # |
537 | # mach port info | |
538 | # | |
539 | if [ -x /usr/local/bin/lsmp ]; then | |
540 | ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1 | |
541 | fi | |
542 | ||
543 | # | |
544 | # open files | |
545 | # | |
6bb65964 | 546 | if [ -x /usr/sbin/lsof ]; then |
78403150 A |
547 | ${PRIV} /usr/sbin/lsof -n -P -T q > lsof 2>&1 |
548 | fi | |
549 | ||
550 | # | |
551 | # [lib]dispatch info | |
552 | # | |
553 | if [ -x /usr/local/bin/ddt ]; then | |
554 | /bin/echo -n "" > dispatch-info | |
555 | for BIN in \ | |
556 | configd \ | |
557 | discoveryd \ | |
558 | ||
559 | do | |
560 | echo "#" >> dispatch-info | |
561 | echo "# ddt -vkp ${BIN}" >> dispatch-info | |
562 | echo "#" >> dispatch-info | |
563 | ${PRIV} /usr/local/bin/ddt -vkp ${BIN} >> dispatch-info 2>&1 | |
564 | done | |
6bb65964 | 565 | fi |
edebe297 A |
566 | |
567 | # | |
78403150 | 568 | # OpenDirectory info |
edebe297 | 569 | # |
6bb65964 A |
570 | if [ -x /usr/bin/odutil ]; then |
571 | echo "#" > od-info | |
572 | echo "# odutil show all" >> od-info | |
573 | echo "#" >> od-info | |
5e9ce69e | 574 | ${PRIV} /usr/bin/odutil show all >> od-info 2>&1 |
edebe297 A |
575 | fi |
576 | ||
577 | # | |
578 | # IPsec configuration | |
579 | # | |
5e9ce69e A |
580 | if [ -x /usr/sbin/setkey -a -x /usr/bin/perl ]; then |
581 | echo "#" > ipsec | |
582 | echo "# setkey -D" >> ipsec | |
583 | echo "#" >> ipsec | |
584 | ${PRIV} /usr/sbin/setkey -D \ | |
585 | | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e ' | |
586 | if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) { | |
17d3ee29 | 587 | printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3; |
edebe297 A |
588 | } else { |
589 | printf "%s\n", $_; | |
590 | } | |
5e9ce69e A |
591 | ' >> ipsec |
592 | ||
593 | echo "" >> ipsec | |
594 | echo "#" >> ipsec | |
595 | echo "# setkey -Pp -D" >> ipsec | |
596 | echo "#" >> ipsec | |
597 | ${PRIV} /usr/sbin/setkey -Pp -D >> ipsec | |
598 | ||
599 | for CF in /var/run/racoon/*.conf | |
600 | do | |
601 | if [ ! -r "${CF}" ]; then | |
602 | continue | |
603 | fi | |
604 | ||
605 | echo "" >> ipsec | |
606 | echo "#" >> ipsec | |
607 | echo "# ${CF}" >> ipsec | |
608 | echo "#" >> ipsec | |
609 | ${PRIV} cat ${CF} \ | |
610 | | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e ' | |
611 | if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) { | |
612 | printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3; | |
613 | } else { | |
614 | printf "%s\n", $_; | |
615 | } | |
616 | ' >> ipsec | |
617 | done | |
618 | fi | |
edebe297 A |
619 | |
620 | # | |
621 | # Kerberos configuration | |
622 | # | |
a40a14f8 A |
623 | if [ -x /usr/bin/klist ]; then |
624 | echo "#" > kerberos | |
5e9ce69e A |
625 | echo "# klist --verbose --all-content" >> kerberos |
626 | echo "#" >> kerberos | |
627 | klist --verbose --all-content >> kerberos 2>&1 | |
628 | ||
a40a14f8 | 629 | echo "#" >> kerberos |
5e9ce69e A |
630 | echo "# ktutil list" >> kerberos |
631 | echo "#" >> kerberos | |
632 | ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1 | |
edebe297 | 633 | |
a40a14f8 | 634 | echo "#" >> kerberos |
5e9ce69e | 635 | echo "# gsstool list --verbose" >> kerberos |
a40a14f8 | 636 | echo "#" >> kerberos |
5e9ce69e | 637 | /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1 |
a40a14f8 | 638 | fi |
edebe297 A |
639 | |
640 | # | |
5e9ce69e | 641 | # system profiler |
edebe297 | 642 | # |
5e9ce69e A |
643 | if [ -x /usr/sbin/system_profiler ]; then |
644 | system_profiler -xml SPEthernetDataType \ | |
645 | SPFibreChannelDataType \ | |
646 | SPFireWireDataType \ | |
647 | SPFirewallDataType \ | |
648 | SPModemDataType \ | |
649 | SPNetworkDataType \ | |
650 | SPThunderboltDataType \ | |
651 | SPWWANDataType \ | |
652 | SPAirPortDataType > system_profiler.spx 2>/dev/null | |
653 | fi | |
6bb65964 | 654 | |
5e9ce69e A |
655 | # |
656 | # system usage statistics | |
657 | # | |
78403150 | 658 | /bin/echo -n "" > system-statistics |
6bb65964 | 659 | |
5e9ce69e A |
660 | if [ -x /usr/bin/uptime ]; then |
661 | echo "#" >> system-statistics | |
662 | echo "# uptime" >> system-statistics | |
663 | echo "#" >> system-statistics | |
664 | /usr/bin/uptime >> system-statistics 2>&1 | |
665 | fi | |
6bb65964 | 666 | |
5e9ce69e A |
667 | if [ -x /usr/sbin/sysctl ]; then |
668 | echo "#" >> system-statistics | |
78403150 | 669 | echo "# sysctl kern hw net debug" >> system-statistics |
5e9ce69e | 670 | echo "#" >> system-statistics |
78403150 | 671 | /usr/sbin/sysctl kern hw net debug >> system-statistics 2>&1 |
5e9ce69e | 672 | fi |
6bb65964 | 673 | |
5e9ce69e A |
674 | if [ -x /usr/bin/zprint ]; then |
675 | echo "#" >> system-statistics | |
676 | echo "# zprint" >> system-statistics | |
677 | echo "#" >> system-statistics | |
678 | ${PRIV} /usr/bin/zprint >> system-statistics 2>&1 | |
679 | fi | |
6bb65964 | 680 | |
78403150 A |
681 | if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then |
682 | N=0 | |
683 | /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \ | |
684 | 2>/dev/null \ | |
685 | | while read lock | |
686 | do | |
687 | if [ ${N} -eq 0 ]; then | |
688 | echo "#" >> system-statistics | |
689 | echo "# lsof [SCPreferences lock files]" >> system-statistics | |
690 | fi | |
691 | N=`expr ${N} + 1` | |
692 | ||
693 | echo "#" >> system-statistics | |
694 | ${PRIV} /usr/sbin/lsof -- ${lock} >> system-statistics 2>&1 | |
695 | done | |
696 | fi | |
697 | ||
5e9ce69e A |
698 | # |
699 | # collect executable and plugin info | |
700 | # | |
701 | report_binary_info() | |
6bb65964 | 702 | { |
78403150 | 703 | if [ ! -f "${1}" ]; then |
5e9ce69e A |
704 | return |
705 | fi | |
17d3ee29 | 706 | |
78403150 | 707 | VERSION=`what "${1}"` |
5e9ce69e | 708 | echo "${VERSION}" >> versions 2>&1 |
17d3ee29 | 709 | |
78403150 | 710 | SUM=`sum "${1}"` |
5e9ce69e | 711 | echo "\tsum: ${SUM}" >> versions 2>&1 |
17d3ee29 | 712 | |
78403150 | 713 | LSINFO=`ls -lu "${1}"` |
5e9ce69e | 714 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
17d3ee29 | 715 | |
5e9ce69e | 716 | echo "" >> versions 2>&1 |
6bb65964 A |
717 | } |
718 | ||
5e9ce69e | 719 | get_binary_info() |
6bb65964 | 720 | { |
5e9ce69e A |
721 | for BIN in \ |
722 | /usr/libexec/bootpd \ | |
723 | /usr/libexec/configd \ | |
78403150 | 724 | /usr/libexec/discoveryd \ |
5e9ce69e A |
725 | /usr/sbin/awacsd \ |
726 | /usr/sbin/pppd \ | |
727 | /usr/sbin/racoon \ | |
728 | /usr/libexec/misd \ | |
729 | /usr/libexec/InternetSharing \ | |
730 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ | |
731 | ||
732 | do | |
733 | report_binary_info "${BIN}" | |
734 | done | |
735 | ||
78403150 A |
736 | if [ -x /usr/bin/xcode-select -a -x /usr/bin/xcodebuild -a -x /usr/bin/xcrun ]; then |
737 | SDKPATH="`xcode-select --print-path 2>/dev/null`" | |
738 | if [ $? -eq 0 -a -n "${SDKPATH}" ]; then | |
739 | /usr/bin/xcodebuild -showsdks 2>/dev/null \ | |
740 | | grep iphone \ | |
741 | | awk '{ print $NF }' \ | |
742 | | while read SDK | |
5e9ce69e | 743 | do |
78403150 | 744 | SDKPATH="`xcrun --sdk $SDK --show-sdk-path`" |
5e9ce69e A |
745 | for BIN in \ |
746 | /usr/libexec/configd_sim \ | |
747 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ | |
6bb65964 | 748 | |
5e9ce69e A |
749 | do |
750 | report_binary_info "${SDKPATH}${BIN}" | |
751 | done | |
752 | done | |
78403150 A |
753 | else |
754 | echo "*** NO SDKs ***" >> versions | |
755 | echo "" >> versions | |
756 | fi | |
5e9ce69e | 757 | fi |
6bb65964 A |
758 | } |
759 | ||
5e9ce69e | 760 | get_plugins_info() |
6bb65964 | 761 | { |
5e9ce69e | 762 | num=0 |
78403150 | 763 | cd /System/Library/SystemConfiguration |
5e9ce69e A |
764 | for PLUGIN in *.bundle |
765 | do | |
78403150 | 766 | plugins[$num]="${PLUGIN}" |
5e9ce69e A |
767 | num=$(( $num + 1 )) |
768 | done | |
769 | ||
770 | cd "${WORKDIR}" | |
771 | ||
772 | for PLUGIN in "${plugins[@]}" | |
773 | do | |
78403150 A |
774 | PLUGIN_DIR="/System/Library/SystemConfiguration/${PLUGIN}" |
775 | PLUGIN_INF="${PLUGIN_DIR}/Contents/Info.plist" | |
776 | if [ ! -f "${PLUGIN_INF}" ]; then | |
777 | PLUGIN_INF="${PLUGIN_DIR}/Info.plist" | |
778 | if [ ! -f "${PLUGIN_INF}" ]; then | |
5e9ce69e A |
779 | echo "${PLUGIN_INF}: No Info.plist" >> versions 2>&1 |
780 | fi | |
6bb65964 | 781 | fi |
6bb65964 | 782 | |
5e9ce69e A |
783 | echo "${PLUGIN}" >> versions 2>&1 |
784 | ||
785 | ENABLED="Enabled" | |
78403150 | 786 | BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null` |
6bb65964 | 787 | if [ $? -eq 0 ]; then |
5e9ce69e A |
788 | if [ ${BOOL} = "TRUE" ]; then |
789 | ENABLED="Enabled*" | |
790 | else | |
791 | ENABLED="Disabled" | |
792 | fi | |
6bb65964 | 793 | fi |
5e9ce69e | 794 | echo "\t${ENABLED}" >> versions 2>&1 |
17d3ee29 | 795 | |
5e9ce69e | 796 | VERBOSE="" |
78403150 | 797 | BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null` |
5e9ce69e A |
798 | if [ $? -eq 0 ]; then |
799 | if [ ${BOOL} = "TRUE" ]; then | |
800 | VERBOSE="Verbose" | |
801 | fi | |
6bb65964 | 802 | fi |
5e9ce69e A |
803 | if [ -n "${VERBOSE}" ]; then |
804 | echo "\t${VERBOSE}" >> versions 2>&1 | |
6bb65964 | 805 | fi |
17d3ee29 | 806 | |
78403150 | 807 | VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleVersion 2>/dev/null` |
5e9ce69e | 808 | if [ $? -eq 1 ]; then |
78403150 | 809 | VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleShortVersionString 2>/dev/null` |
5e9ce69e A |
810 | fi |
811 | echo "\tVersion: ${VERSION}" >> versions 2>&1 | |
17d3ee29 | 812 | |
78403150 A |
813 | if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then |
814 | SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` | |
5e9ce69e | 815 | echo "\tsum: ${SUM}" >> versions 2>&1 |
17d3ee29 | 816 | |
78403150 | 817 | LSINFO=`ls -lu "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` |
5e9ce69e | 818 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
78403150 A |
819 | elif [ -f "${PLUGIN_DIR}/${PLUGIN%.*}" ]; then |
820 | SUM=`sum "${PLUGIN_DIR}/${PLUGIN%.*}"` | |
5e9ce69e | 821 | echo "\tsum: ${SUM}" >> versions 2>&1 |
edebe297 | 822 | |
78403150 | 823 | LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"` |
5e9ce69e | 824 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
edebe297 | 825 | fi |
17d3ee29 | 826 | |
5e9ce69e A |
827 | echo "" >> versions 2>&1 |
828 | done | |
829 | } | |
17d3ee29 | 830 | |
5e9ce69e A |
831 | if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then |
832 | get_binary_info | |
833 | get_plugins_info | |
834 | fi | |
17d3ee29 | 835 | |
5e9ce69e | 836 | # |
78403150 A |
837 | # to give a chance for "networkd" to finish dumping its state, the last |
838 | # thing we do is collect the logs | |
5e9ce69e | 839 | # |
edebe297 | 840 | |
5e9ce69e A |
841 | # |
842 | # system log, kernel.log, early boot log messages | |
843 | # | |
844 | if [ -x /usr/bin/syslog ]; then | |
78403150 | 845 | # |
5e9ce69e | 846 | # save the recent activity |
78403150 A |
847 | # |
848 | ${PRIV} /usr/bin/syslog -T local.3 \ | |
849 | | ${TAIL_25000} > syslog | |
edebe297 | 850 | |
78403150 | 851 | # |
5e9ce69e A |
852 | # save just the "kernel" activity (in case some of the |
853 | # interesting/relevant message are before the messages | |
854 | # captured above. | |
78403150 A |
855 | # |
856 | ${PRIV} /usr/bin/syslog -T local.3 -k Facility kern \ | |
857 | | ${TAIL_25000} > kernel | |
6bb65964 | 858 | |
5e9ce69e A |
859 | if [ -d /var/log/DiagnosticMessages ]; then |
860 | # save any MessageTracer activity | |
78403150 A |
861 | ${PRIV} /usr/bin/syslog -d /var/log/DiagnosticMessages \ |
862 | -F raw \ | |
863 | -T local.3 \ | |
864 | | ${TAIL_25000} > DiagnosticMessages | |
5e9ce69e A |
865 | fi |
866 | else | |
867 | if [ -f /var/log/system.log ]; then | |
78403150 | 868 | ${PRIV} ${TAIL_25000} /var/log/system.log > system.log |
5e9ce69e A |
869 | fi |
870 | if [ -f /var/log/kernel.log ]; then | |
78403150 | 871 | ${PRIV} ${TAIL_25000} /var/log/kernel.log > kernel.log |
5e9ce69e A |
872 | fi |
873 | fi | |
874 | if [ -x /sbin/dmesg ]; then | |
78403150 | 875 | ${PRIV} /sbin/dmesg > dmesg |
5e9ce69e | 876 | fi |
6bb65964 | 877 | |
5e9ce69e A |
878 | # |
879 | # IPConfiguration log | |
880 | # | |
881 | if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then | |
882 | ${PRIV} ${TAIL_2000} /var/log/com.apple.IPConfiguration.bootp \ | |
883 | > com.apple.IPConfiguration.bootp | |
884 | fi | |
885 | ||
886 | # | |
887 | # ppp log file(s) | |
888 | # | |
889 | scutil <<_END_OF_INPUT \ | |
890 | | awk -F' *: *' \ | |
891 | ' \ | |
892 | /Logfile : / { \ | |
893 | if (index($2, "/") == 1) { print $2 } \ | |
894 | else { print "/var/log/ppp/" $2 } \ | |
895 | } \ | |
896 | END { \ | |
897 | print "/tmp/pppotcp.log" \ | |
898 | } \ | |
899 | ' \ | |
900 | | sort -u \ | |
901 | | while read logFile | |
6bb65964 | 902 | open |
5e9ce69e | 903 | show Setup:/Network/Service/[^/]+/PPP pattern |
6bb65964 A |
904 | quit |
905 | _END_OF_INPUT | |
906 | do | |
5e9ce69e A |
907 | if [ -f "${logFile}" ]; then |
908 | b="`basename ${logFile}`" | |
909 | cat "${logFile}" > "${b}" 2>&1 | |
910 | fi | |
edebe297 | 911 | done |
dbf6a266 A |
912 | |
913 | # | |
5e9ce69e | 914 | # application firewall log |
dbf6a266 | 915 | # |
5e9ce69e A |
916 | if [ -f /var/log/appfirewall.log ]; then |
917 | ${PRIV} ${TAIL_2000} /var/log/appfirewall.log > appfirewall.log | |
918 | fi | |
919 | ||
920 | if [ -x /bin/ls ]; then | |
921 | # | |
922 | # collect crash reports | |
923 | # | |
924 | for daemon in \ | |
78403150 A |
925 | InternetSharing \ |
926 | SCHelper \ | |
927 | SCMonitor \ | |
928 | awacsd \ | |
5e9ce69e A |
929 | bootpd \ |
930 | configd \ | |
78403150 A |
931 | discoveryd \ |
932 | discoveryd_helper \ | |
5e9ce69e | 933 | eapolclient \ |
5e9ce69e A |
934 | pppd \ |
935 | racoon \ | |
936 | socketfilterfw \ | |
a40a14f8 | 937 | |
5e9ce69e A |
938 | do |
939 | /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \ | |
78403150 | 940 | /Library/Logs/DiagnosticReports/${daemon}_*.ips \ |
5e9ce69e | 941 | /Library/Logs/CrashReporter/${daemon}_*.crash \ |
78403150 | 942 | /Library/Logs/CrashReporter/${daemon}_*.ips \ |
5e9ce69e A |
943 | /Library/Logs/CrashReporter/${daemon}_*.plist \ |
944 | 2>/dev/null \ | |
945 | | while read log | |
946 | do | |
947 | if [ -f "${log}" ]; then | |
948 | b="`basename ${log}`" | |
949 | ${PRIV} cat "${log}" > "${b}" 2>&1 | |
950 | fi | |
951 | done | |
952 | done | |
953 | ||
954 | # | |
955 | # collect any verbose logging output | |
956 | # | |
957 | /bin/ls -1 /Library/Logs/CrashReporter/com.apple.networking.*.log* \ | |
958 | 2>/dev/null \ | |
edebe297 A |
959 | | while read log |
960 | do | |
6bb65964 A |
961 | if [ -f "${log}" ]; then |
962 | b="`basename ${log}`" | |
5e9ce69e | 963 | ${PRIV} cat "${log}" > "${b}" 2>&1 |
6bb65964 | 964 | fi |
edebe297 | 965 | done |
17d3ee29 A |
966 | fi |
967 | ||
78403150 A |
968 | # |
969 | # stackshot | |
970 | # | |
971 | if [ -x /usr/local/bin/crstackshot ]; then | |
972 | /usr/local/bin/crstackshot 2>/dev/null | |
973 | fi | |
6bb65964 | 974 | |
dbf6a266 A |
975 | # |
976 | # collect everything into a single archive | |
977 | # | |
edebe297 | 978 | cd "${WORKDIR}/.." |
5e9ce69e | 979 | tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}" |
edebe297 A |
980 | rm -rf "${WORKDIR}" |
981 | ||
982 | if [ ${UID} -eq 0 ]; then | |
983 | if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then | |
984 | if [ ${UID} -ne ${SUDO_UID} ]; then | |
985 | chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}" | |
986 | fi | |
987 | fi | |
988 | fi | |
dbf6a266 | 989 | |
edebe297 | 990 | echo "Network data collected to \"${ARCHIVE}\"" |
a40a14f8 | 991 |