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