]> git.saurik.com Git - apple/configd.git/blame_incremental - get-mobility-info
configd-802.40.13.tar.gz
[apple/configd.git] / get-mobility-info
... / ...
CommitLineData
1#!/bin/sh
2# Copyright (c) 2004-2015 Apple Inc.
3#
4# get-mobility-info
5#
6# Collect system & network configuration information.
7#
8
9PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
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#
34PRIV=""
35if [ ${EUID} -ne 0 ]; then
36 PRIV="sudo"
37fi
38
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
47OUT="mobility-info-`date +'%Y.%m.%d.%H%M%S'`"
48OUTDIR="/var/tmp"
49if [ -d ~/Desktop ]; then
50 OUTDIR=~/Desktop
51elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
52 OUTDIR=/Library/Logs/CrashReporter
53 mkdir -p ${OUTDIR}
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
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}"`
72if [ $? -ne 0 ]; then
73 echo "Could not create snapshot archive"
74 rm -rf "${WORKDIR}"
75 exit 1
76fi
77
78cd "${WORKDIR}"
79
80echo ""
81echo "Please wait, collecting information and statistics"
82echo ""
83
84#
85# get-network-info
86#
87if [ -x /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info ]; then
88 /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info -s -c "${WORKDIR}"
89elif [ -x /System/Library/Frameworks/SystemConfiguration.framework/get-network-info ]; then
90 /System/Library/Frameworks/SystemConfiguration.framework/get-network-info -s -c "${WORKDIR}"
91elif [ -x /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info ]; then
92 /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info -s -c "${WORKDIR}"
93fi
94
95#
96# processes
97#
98if [ -x /bin/ps ]; then
99 /bin/ps axlww > ps 2>&1
100fi
101
102#
103# AirPort info
104#
105if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
106 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \
107 > airport 2>&1
108fi
109
110#
111# collect wifi dump
112#
113if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then
114 ${PRIV} /usr/bin/wdutil dump
115 mkdir -p "wifi_dump"
116 /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \
117 | while read log
118 do
119 if [ -f "${log}" ]; then
120 b="`basename ${log}`"
121 ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1
122 fi
123 done
124fi
125
126#
127# OS info
128#
129if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
130 cat /System/Library/CoreServices/SystemVersion.plist \
131 > SystemVersion.plist 2>&1
132fi
133
134#
135# IOKit info
136#
137if [ -x /usr/sbin/ioreg ]; then
138 /usr/sbin/ioreg -i -l -w 0 > ioreg 2>&1
139 /usr/sbin/ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1
140fi
141
142#
143# Power Management info
144#
145if [ -x /usr/bin/pmset ]; then
146 echo "#" > pmset
147 echo "# pmset -g everything" >> pmset
148 echo "#" >> pmset
149 /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset
150fi
151
152#
153# Host configuration
154#
155if [ -x /usr/bin/hostinfo ]; then
156 /usr/bin/hostinfo > hostinfo 2>&1
157fi
158if [ -e /etc/hostconfig ]; then
159 cat /etc/hostconfig > etc.hostconfig 2>&1
160fi
161
162#
163# System / network preferences
164#
165for f in \
166 /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \
167 /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \
168 /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \
169 /Library/Preferences/com.apple.alf.plist \
170 /Library/Preferences/com.apple.sharing.firewall.plist \
171 /Library/Preferences/com.apple.wwand.plist \
172
173do
174 if [ -e "${f}" ]; then
175 b="`basename ${f}`"
176 cat "${f}" > "${b}" 2>&1
177 fi
178done
179
180#
181# Install log
182#
183if [ -e /var/log/install.log ]; then
184 cat /var/log/install.log > install.log 2>&1
185fi
186
187#
188# System / network preferences (from other volumes)
189#
190mount -t hfs | grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \
191| while read volume
192do
193 V_PATH="/Volumes/${volume}"
194 if [ -h "${V_PATH}" ]; then
195 # if the path is a symlink
196 continue
197 fi
198
199 for f in \
200 /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \
201 /Library/Preferences/SystemConfiguration/preferences.plist \
202
203 do
204 if [ -f "${V_PATH}/${f}" ]; then
205 mkdir -p "OtherPreferences/${volume}"
206 b="`basename ${f}`"
207 cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1
208 fi
209 done
210done
211
212#
213# InternetSharing
214#
215if [ -e /etc/bootpd.plist ]; then
216 cat /etc/bootpd.plist > bootpd.plist 2>&1
217 cat /etc/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null
218elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then
219 cat /Library/Preferences/SystemConfiguration/bootpd.plist > bootpd.plist 2>&1
220 cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null
221fi
222
223#
224# mounted filesystems
225#
226mount > mounted-filesystems 2>&1
227
228${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null
229
230#
231# kernel extensions statistic
232#
233if [ -x /usr/sbin/kextstat ]; then
234 /usr/sbin/kextstat > kextstat 2>&1
235fi
236
237if [ -x /sbin/pfctl ]; then
238 echo "#" > pf
239 echo "# pfctl -s all" >> pf
240 echo "#" >> pf
241 ${PRIV} /sbin/pfctl -s all >> pf 2>&1
242 echo "==============================" >> pf
243 echo "#" >> pf
244 echo "# pfctl -s References" >> pf
245 echo "#" >> pf
246 ${PRIV} /sbin/pfctl -s References >> pf 2>&1
247 for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null`
248 do
249 echo "==============================" >> pf
250 echo "#" >> pf
251 echo "# pfctl -a ${ANCHOR} -s all" >> pf
252 echo "#" >> pf
253 ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1
254 done
255fi
256
257#
258# mach port info
259#
260if [ -x /usr/local/bin/lsmp ]; then
261 ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1
262fi
263
264#
265# open files
266#
267if [ -x /usr/sbin/lsof ]; then
268 ${PRIV} /usr/sbin/lsof -n -O -P -T q > lsof 2>&1 &
269 LSOF_PID=$!
270 # Init a watchdog for lsof
271 (
272 WAIT_TIME=5
273 while [ $WAIT_TIME -gt 0 ]
274 do
275 ${PRIV} kill -0 ${LSOF_PID} 2>/dev/null
276 if [ $? -eq 0 ]; then
277 sleep 1
278 # lsof is gathering data..
279 WAIT_TIME=$((WAIT_TIME-1))
280 continue
281 fi
282
283 # lsof completed gathering data
284 break
285 done
286
287 if [ $WAIT_TIME -eq 0 ]; then
288 # lsof timed out
289 ${PRIV} kill ${LSOF_PID} 2>/dev/null
290 fi
291 ) &
292fi
293
294#
295# [lib]dispatch info
296#
297if [ -x /usr/local/bin/ddt ]; then
298 /bin/echo -n "" > dispatch-info
299 for BIN in \
300 configd \
301 discoveryd \
302
303 do
304 echo "#" >> dispatch-info
305 echo "# ddt -vkp ${BIN}" >> dispatch-info
306 echo "#" >> dispatch-info
307 ${PRIV} /usr/local/bin/ddt -vkp ${BIN} >> dispatch-info 2>&1
308 done
309fi
310
311#
312# OpenDirectory info
313#
314if [ -x /usr/bin/odutil ]; then
315 echo "#" > od-info
316 echo "# odutil show all" >> od-info
317 echo "#" >> od-info
318 ${PRIV} /usr/bin/odutil show all >> od-info 2>&1
319fi
320
321#
322# Kerberos configuration
323#
324if [ -x /usr/bin/klist ]; then
325 echo "#" > kerberos
326 echo "# klist --verbose --all-content" >> kerberos
327 echo "#" >> kerberos
328 klist --verbose --all-content >> kerberos 2>&1
329
330 echo "#" >> kerberos
331 echo "# ktutil list" >> kerberos
332 echo "#" >> kerberos
333 ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1
334
335 echo "#" >> kerberos
336 echo "# gsstool list --verbose" >> kerberos
337 echo "#" >> kerberos
338 /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1
339fi
340
341#
342# system profiler
343#
344if [ -x /usr/sbin/system_profiler ]; then
345 system_profiler -xml SPEthernetDataType \
346 SPFibreChannelDataType \
347 SPFireWireDataType \
348 SPFirewallDataType \
349 SPModemDataType \
350 SPNetworkDataType \
351 SPThunderboltDataType \
352 SPWWANDataType \
353 SPAirPortDataType > system_profiler.spx 2>/dev/null
354fi
355
356#
357# system usage statistics
358#
359/bin/echo -n "" > system-statistics
360
361if [ -x /usr/bin/uptime ]; then
362 echo "#" >> system-statistics
363 echo "# uptime" >> system-statistics
364 echo "#" >> system-statistics
365 /usr/bin/uptime >> system-statistics 2>&1
366fi
367
368if [ -x /usr/sbin/sysctl ]; then
369 echo "#" >> system-statistics
370 echo "# sysctl kern hw net debug" >> system-statistics
371 echo "#" >> system-statistics
372 /usr/sbin/sysctl kern hw net debug >> system-statistics 2>&1
373fi
374
375if [ -x /usr/bin/zprint ]; then
376 echo "#" >> system-statistics
377 echo "# zprint" >> system-statistics
378 echo "#" >> system-statistics
379 ${PRIV} /usr/bin/zprint >> system-statistics 2>&1
380fi
381
382if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then
383 N=0
384 /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \
385 2>/dev/null \
386 | while read lock
387 do
388 if [ ${N} -eq 0 ]; then
389 echo "#" >> system-statistics
390 echo "# lsof [SCPreferences lock files]" >> system-statistics
391 fi
392 N=`expr ${N} + 1`
393
394 echo "#" >> system-statistics
395 ${PRIV} /usr/sbin/lsof -- ${lock} >> system-statistics 2>&1
396 done
397fi
398
399#
400# collect executable and plugin info
401#
402report_binary_info()
403{
404 if [ ! -f "${1}" ]; then
405 return
406 fi
407
408 VERSION=`what "${1}"`
409 echo "${VERSION}" >> versions 2>&1
410
411 SUM=`sum "${1}"`
412 echo "\tsum: ${SUM}" >> versions 2>&1
413
414 LSINFO=`ls -lu "${1}"`
415 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
416
417 echo "" >> versions 2>&1
418}
419
420get_binary_info()
421{
422 for BIN in \
423 /usr/libexec/bootpd \
424 /usr/libexec/configd \
425 /usr/libexec/discoveryd \
426 /usr/sbin/awacsd \
427 /usr/sbin/mDNSResponder \
428 /usr/sbin/pppd \
429 /usr/sbin/racoon \
430 /usr/libexec/misd \
431 /usr/libexec/InternetSharing \
432 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
433
434 do
435 report_binary_info "${BIN}"
436 done
437
438 if [ -x /usr/bin/xcode-select -a -x /usr/bin/xcodebuild -a -x /usr/bin/xcrun ]; then
439 SDKPATH="`xcode-select --print-path 2>/dev/null`"
440 if [ $? -eq 0 -a -n "${SDKPATH}" ]; then
441 /usr/bin/xcodebuild -showsdks 2>/dev/null \
442 | grep iphone \
443 | awk '{ print $NF }' \
444 | while read SDK
445 do
446 SDKPATH="`xcrun --sdk $SDK --show-sdk-path`"
447 for BIN in \
448 /usr/libexec/configd_sim \
449 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
450
451 do
452 report_binary_info "${SDKPATH}${BIN}"
453 done
454 done
455 else
456 echo "*** NO SDKs ***" >> versions
457 echo "" >> versions
458 fi
459 fi
460}
461
462get_plugins_info()
463{
464 num=0
465 cd /System/Library/SystemConfiguration
466 for PLUGIN in *.bundle
467 do
468 plugins[$num]="${PLUGIN}"
469 num=$(( $num + 1 ))
470 done
471
472 cd "${WORKDIR}"
473
474 for PLUGIN in "${plugins[@]}"
475 do
476 PLUGIN_DIR="/System/Library/SystemConfiguration/${PLUGIN}"
477 PLUGIN_INF="${PLUGIN_DIR}/Contents/Info.plist"
478 if [ ! -f "${PLUGIN_INF}" ]; then
479 PLUGIN_INF="${PLUGIN_DIR}/Info.plist"
480 if [ ! -f "${PLUGIN_INF}" ]; then
481 echo "${PLUGIN_INF}: No Info.plist" >> versions 2>&1
482 fi
483 fi
484
485 echo "${PLUGIN}" >> versions 2>&1
486
487 ENABLED="Enabled"
488 BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null`
489 if [ $? -eq 0 ]; then
490 if [ ${BOOL} = "TRUE" ]; then
491 ENABLED="Enabled*"
492 else
493 ENABLED="Disabled"
494 fi
495 fi
496 echo "\t${ENABLED}" >> versions 2>&1
497
498 VERBOSE=""
499 BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null`
500 if [ $? -eq 0 ]; then
501 if [ ${BOOL} = "TRUE" ]; then
502 VERBOSE="Verbose"
503 fi
504 fi
505 if [ -n "${VERBOSE}" ]; then
506 echo "\t${VERBOSE}" >> versions 2>&1
507 fi
508
509 VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleVersion 2>/dev/null`
510 if [ $? -eq 1 ]; then
511 VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleShortVersionString 2>/dev/null`
512 fi
513 echo "\tVersion: ${VERSION}" >> versions 2>&1
514
515 if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then
516 SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
517 echo "\tsum: ${SUM}" >> versions 2>&1
518
519 LSINFO=`ls -lu "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
520 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
521 elif [ -f "${PLUGIN_DIR}/${PLUGIN%.*}" ]; then
522 SUM=`sum "${PLUGIN_DIR}/${PLUGIN%.*}"`
523 echo "\tsum: ${SUM}" >> versions 2>&1
524
525 LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"`
526 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
527 fi
528
529 echo "" >> versions 2>&1
530 done
531}
532
533if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then
534 get_binary_info
535 get_plugins_info
536fi
537
538#
539# to give a chance for "networkd" and the DNS service to finish dumping their
540# state, the last thing we do is collect the logs
541#
542
543#
544# system log, kernel.log, early boot log messages
545#
546if [ -x /usr/bin/syslog ]; then
547 #
548 # save the recent activity
549 #
550 ${PRIV} /usr/bin/syslog -T local.3 \
551 | ${TAIL_25000} > syslog
552
553 #
554 # save just the "kernel" activity (in case some of the
555 # interesting/relevant message are before the messages
556 # captured above.
557 #
558 ${PRIV} /usr/bin/syslog -T local.3 -k Facility kern \
559 | ${TAIL_25000} > kernel
560
561 if [ -d /var/log/DiagnosticMessages ]; then
562 # save any MessageTracer activity
563 ${PRIV} /usr/bin/syslog -d /var/log/DiagnosticMessages \
564 -F raw \
565 -T local.3 \
566 | ${TAIL_25000} > DiagnosticMessages
567 fi
568else
569 if [ -f /var/log/system.log ]; then
570 ${PRIV} ${TAIL_25000} /var/log/system.log > system.log
571 fi
572 if [ -f /var/log/kernel.log ]; then
573 ${PRIV} ${TAIL_25000} /var/log/kernel.log > kernel.log
574 fi
575fi
576if [ -x /sbin/dmesg ]; then
577 ${PRIV} /sbin/dmesg > dmesg
578fi
579
580#
581# IPConfiguration log
582#
583if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
584 ${PRIV} ${TAIL_2000} /var/log/com.apple.IPConfiguration.bootp \
585 > com.apple.IPConfiguration.bootp
586fi
587
588#
589# ppp log file(s)
590#
591scutil <<_END_OF_INPUT \
592| awk -F' *: *' \
593 ' \
594 /Logfile : / { \
595 if (index($2, "/") == 1) { print $2 } \
596 else { print "/var/log/ppp/" $2 } \
597 } \
598 END { \
599 print "/tmp/pppotcp.log" \
600 } \
601 ' \
602| sort -u \
603| while read logFile
604open
605show Setup:/Network/Service/[^/]+/PPP pattern
606quit
607_END_OF_INPUT
608do
609 if [ -f "${logFile}" ]; then
610 b="`basename ${logFile}`"
611 cat "${logFile}" > "${b}" 2>&1
612 fi
613done
614
615#
616# application firewall log
617#
618if [ -f /var/log/appfirewall.log ]; then
619 ${PRIV} ${TAIL_2000} /var/log/appfirewall.log > appfirewall.log
620fi
621
622if [ -x /bin/ls ]; then
623 #
624 # collect crash reports
625 #
626 for daemon in \
627 InternetSharing \
628 SCHelper \
629 SCMonitor \
630 awacsd \
631 bootpd \
632 configd \
633 discoveryd \
634 discoveryd_helper \
635 eapolclient \
636 mDNSResponder \
637 mDNSResponderHelper \
638 pppd \
639 racoon \
640 socketfilterfw \
641
642 do
643 /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \
644 /Library/Logs/DiagnosticReports/${daemon}_*.ips \
645 /Library/Logs/CrashReporter/${daemon}_*.crash \
646 /Library/Logs/CrashReporter/${daemon}_*.ips \
647 /Library/Logs/CrashReporter/${daemon}_*.plist \
648 2>/dev/null \
649 | while read log
650 do
651 if [ -f "${log}" ]; then
652 b="`basename ${log}`"
653 ${PRIV} cat "${log}" > "${b}" 2>&1
654 fi
655 done
656 done
657
658 #
659 # collect any verbose logging output
660 #
661 /bin/ls -1 /Library/Logs/CrashReporter/com.apple.networking.*.log* \
662 2>/dev/null \
663 | while read log
664 do
665 if [ -f "${log}" ]; then
666 b="`basename ${log}`"
667 ${PRIV} cat "${log}" > "${b}" 2>&1
668 fi
669 done
670fi
671
672#
673# stackshot
674#
675if [ -x /usr/local/bin/crstackshot ]; then
676 /usr/local/bin/crstackshot 2>/dev/null
677fi
678
679#
680# wait for background activity (eg: lsof)
681#
682wait
683
684#
685# collect everything into a single archive
686#
687cd "${WORKDIR}/.."
688tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
689rm -rf "${WORKDIR}"
690
691if [ ${UID} -eq 0 ]; then
692 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
693 if [ ${UID} -ne ${SUDO_UID} ]; then
694 chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}"
695 fi
696 fi
697fi
698
699echo "Network data collected to \"${ARCHIVE}\""
700