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