]> git.saurik.com Git - apple/configd.git/blame - get-mobility-info
configd-596.15.tar.gz
[apple/configd.git] / get-mobility-info
CommitLineData
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
9PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
085a2e6a
A
11#
12# Disclaimer
13#
14cat <<_END_OF_DISCLAIMER
15
16This diagnostic tool generates files that allow Apple to investigate issues
17with your computer and help Apple to improve its products. The generated files
18may contain some of your personal information, which may include, but not be
19limited to, the serial number or similar unique number for your device, your
20user name, or your computer name. The information is used by Apple in
21accordance with its privacy policy (www.apple.com/privacy) and is not shared
22with any third party. By enabling this diagnostic tool and sending a copy of
23the generated files to Apple, you are consenting to Appleā€™s use of the content
24of such files.
25
26_END_OF_DISCLAIMER
27
28/bin/echo "Press 'Enter' to continue."
29read reply
30
31#
32# Setup
33#
dbf6a266
A
34PRIV=""
35if [ ${EUID} -ne 0 ]; then
36 PRIV="sudo"
37fi
38
5e9ce69e
A
39if [ -x /usr/bin/tail ]; then
40 TAIL_2000="/usr/bin/tail -n 2000"
41 TAIL_25000="/usr/bin/tail -n 25000"
42else
43 TAIL_2000="/bin/cat"
44 TAIL_25000="/bin/cat"
45fi
46
edebe297
A
47OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
48OUTDIR="/var/tmp"
49if [ -d ~/Desktop ]; then
50 OUTDIR=~/Desktop
a40a14f8 51elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
5e9ce69e 52 OUTDIR=/Library/Logs/CrashReporter
a40a14f8 53 mkdir -p ${OUTDIR}
edebe297
A
54fi
55
56umask 077
57
58WORKDIR=`mktemp -d -q "/tmp/${OUT}"`
59if [ $? -ne 0 ]; then
60 echo "Could not create snapshot directory"
61 exit 1
62fi
63
a40a14f8
A
64GZ_EXT=""
65GZ_OPT=""
66if [ -x /usr/bin/gzip ]; then
67 GZ_EXT=".gz"
68 GZ_OPT="-z"
69fi
70
71ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
edebe297
A
72if [ $? -ne 0 ]; then
73 echo "Could not create snapshot archive"
74 rm -rf "${WORKDIR}"
75 exit 1
76fi
77
78cd "${WORKDIR}"
dbf6a266 79
17d3ee29
A
80echo ""
81echo "Please wait, collecting information and statistics"
82echo ""
83
5e9ce69e
A
84#
85# Execute network reachability/DNS commands early as "mDNSResponder" will block while
86# logging its "state" info.
87#
88scutil -d -v -r www.apple.com "" no-server > reachability-info 2>&1
89if [ -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
91fi
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#
98if [ -x /usr/bin/killall ]; then
99 ${PRIV} /usr/bin/killall -INFO networkd
100 ${PRIV} /usr/bin/killall -INFO mDNSResponder
101 sleep 1
102fi
103
dbf6a266
A
104#
105# processes
106#
5e9ce69e
A
107if [ -x /bin/ps ]; then
108 /bin/ps axlww > ps 2>&1
109fi
dbf6a266
A
110
111#
112# network interface configuration
113#
5e9ce69e
A
114if [ -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 119fi
dbf6a266
A
120
121#
122# network route configuration
123#
5e9ce69e
A
124if [ -x /usr/sbin/netstat ]; then
125 /usr/sbin/netstat -n -r -a -l > netstat 2>&1
126fi
dbf6a266
A
127
128#
129# DHCP configuration
130#
5e9ce69e
A
131if [ -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
140fi
dbf6a266 141
edebe297
A
142#
143# AirPort info
144#
145if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
146 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \
147 > airport 2>&1
148fi
149
5e9ce69e
A
150#
151# collect wifi dump
152#
153if [ -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
164fi
165
dbf6a266
A
166#
167# OS info
168#
169if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
170 cat /System/Library/CoreServices/SystemVersion.plist \
edebe297 171 > SystemVersion.plist 2>&1
dbf6a266
A
172fi
173if [ -e /System/Library/CoreServices/ServerVersion.plist ]; then
174 cat /System/Library/CoreServices/ServerVersion.plist \
edebe297 175 > ServerVersion.plist 2>&1
dbf6a266
A
176fi
177
178#
179# IOKit info
180#
5e9ce69e
A
181if [ -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
184fi
edebe297 185
17d3ee29
A
186#
187# Power Management info
188#
5e9ce69e
A
189if [ -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
194fi
17d3ee29 195
edebe297
A
196#
197# Host name
198#
5e9ce69e
A
199if [ -x /bin/hostname ]; then
200 /bin/hostname > hostname 2>&1
201fi
dbf6a266
A
202
203#
204# Host configuration
205#
5e9ce69e
A
206if [ -x /usr/bin/hostinfo ]; then
207 /usr/bin/hostinfo > hostinfo 2>&1
208fi
dbf6a266 209if [ -e /etc/hostconfig ]; then
edebe297 210 cat /etc/hostconfig > etc.hostconfig 2>&1
dbf6a266
A
211fi
212
213#
214# DNS configuration
215#
edebe297 216scutil --dns > dns-configuration 2>&1
dbf6a266 217if [ -e /etc/resolv.conf ]; then
edebe297 218 cat /etc/resolv.conf > etc.resolv.conf 2>&1
dbf6a266
A
219fi
220if [ -e /var/run/resolv.conf ]; then
edebe297 221 cat /var/run/resolv.conf > var.run.resolv.conf 2>&1
dbf6a266 222fi
5e9ce69e
A
223if [ -e /etc/resolver ]; then
224 tar -c -H /etc/resolver > etc.resolver.tar 2>/dev/null
225fi
dbf6a266
A
226
227#
edebe297 228# Proxy configuration
dbf6a266 229#
17d3ee29
A
230scutil -d -v --proxy > proxy-configuration 2>&1
231
232#
233# Network information
234#
5e9ce69e
A
235if [ -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
248fi
dbf6a266
A
249
250#
251# System / network preferences
252#
253for 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
265do
edebe297
A
266 if [ -e "${f}" ]; then
267 b="`basename ${f}`"
268 cat "${f}" > "${b}" 2>&1
dbf6a266
A
269 fi
270done
271
5e9ce69e
A
272#
273# System / network preferences (from other volumes)
274#
275mount \
276| awk 'BEGIN { FS= "[/ \t]+" } /^\/dev\/disk.* on \/Volumes\// { print $6 }' \
277| while read volume
278do
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
291done
292
6bb65964
A
293#
294# InternetSharing
295#
296if [ -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
299elif [ -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
302fi
303
dbf6a266
A
304#
305# configd's cache
306#
17d3ee29 307${PRIV} scutil -p --snapshot
6bb65964
A
308if [ -f /var/tmp/configd-store.plist ]; then
309 cat /var/tmp/configd-store.plist > configd-store.plist 2>&1
dbf6a266 310fi
6bb65964
A
311if [ -f /var/tmp/configd-pattern.plist ]; then
312 cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1
dbf6a266 313fi
6bb65964
A
314if [ -f /var/tmp/configd-session.plist ]; then
315 cat /var/tmp/configd-session.plist > configd-session.plist 2>&1
edebe297
A
316fi
317if [ -f /var/tmp/configd-state ]; then
318 cat /var/tmp/configd-state > configd-state 2>&1
dbf6a266 319fi
17d3ee29
A
320if [ -f /var/tmp/configd-reachability ]; then
321 cat /var/tmp/configd-reachability > configd-reachability 2>&1
6bb65964
A
322fi
323
dbf6a266
A
324#
325# mounted filesystems
326#
edebe297 327mount > 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 334if [ -x /usr/sbin/kextstat ]; then
5e9ce69e 335 /usr/sbin/kextstat > kextstat 2>&1
edebe297 336elif [ -x /usr/sbin/kmodstat ]; then
5e9ce69e 337 /usr/sbin/kmodstat > kmodstat 2>&1
dbf6a266
A
338fi
339
340#
341# network statistics
342#
5e9ce69e
A
343echo -n "" > network-statistics
344
345if [ -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
350fi
351
352if [ -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
412fi
17d3ee29 413
6bb65964 414if [ -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 439fi
edebe297 440
6bb65964
A
441if [ -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 446fi
edebe297 447
17d3ee29
A
448if [ -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
453fi
454
6bb65964
A
455if [ -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
473fi
edebe297 474
6bb65964
A
475if [ -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 480fi
edebe297
A
481
482#
483# DirectoryService info
484#
6bb65964
A
485if [ -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 490elif [ -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
505fi
506
507#
508# IPsec configuration
509#
5e9ce69e
A
510if [ -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
548fi
edebe297
A
549
550#
551# Kerberos configuration
552#
a40a14f8
A
553if [ -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 568fi
edebe297
A
569
570#
5e9ce69e 571# system profiler
edebe297 572#
5e9ce69e
A
573if [ -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
583fi
6bb65964 584
5e9ce69e
A
585#
586# system usage statistics
587#
588echo -n "" > system-statistics
6bb65964 589
5e9ce69e
A
590if [ -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
595fi
6bb65964 596
5e9ce69e
A
597if [ -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
602fi
6bb65964 603
5e9ce69e
A
604if [ -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
609fi
6bb65964 610
5e9ce69e
A
611#
612# collect executable and plugin info
613#
614report_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 632get_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 667get_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
738if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then
739 get_binary_info
740 get_plugins_info
741fi
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#
751if [ -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
767else
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
774fi
775if [ -x /sbin/dmesg ]; then
776 ${PRIV} /sbin/dmesg > dmesg
777fi
6bb65964 778
5e9ce69e
A
779#
780# IPConfiguration log
781#
782if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
783 ${PRIV} ${TAIL_2000} /var/log/com.apple.IPConfiguration.bootp \
784 > com.apple.IPConfiguration.bootp
785fi
786
787#
788# ppp log file(s)
789#
790scutil <<_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 803open
5e9ce69e 804show Setup:/Network/Service/[^/]+/PPP pattern
6bb65964
A
805quit
806_END_OF_INPUT
807do
5e9ce69e
A
808 if [ -f "${logFile}" ]; then
809 b="`basename ${logFile}`"
810 cat "${logFile}" > "${b}" 2>&1
811 fi
edebe297 812done
dbf6a266
A
813
814#
5e9ce69e 815# application firewall log
dbf6a266 816#
5e9ce69e
A
817if [ -f /var/log/appfirewall.log ]; then
818 ${PRIV} ${TAIL_2000} /var/log/appfirewall.log > appfirewall.log
819fi
820
821if [ -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
865fi
866
6bb65964 867
dbf6a266
A
868#
869# collect everything into a single archive
870#
edebe297 871cd "${WORKDIR}/.."
5e9ce69e 872tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
edebe297
A
873rm -rf "${WORKDIR}"
874
875if [ ${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
881fi
dbf6a266 882
edebe297 883echo "Network data collected to \"${ARCHIVE}\""
a40a14f8 884