2 # Copyright (c) 2004-2015 Apple Inc.
6 # Collect system & network configuration information.
9 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
14 cat <<_END_OF_DISCLAIMER
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
28 /bin
/echo "Press 'Enter' to continue."
35 if [ ${EUID} -ne 0 ]; then
39 if [ -x /usr
/bin
/tail ]; then
40 TAIL_2000
="/usr/bin/tail -n 2000"
41 TAIL_25000
="/usr/bin/tail -n 25000"
47 OUT
="mobility-info-`date +'%Y.%m.%d.%H%M%S'`"
49 if [ -d ~
/Desktop
]; then
51 elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
52 OUTDIR
=/Library
/Logs
/CrashReporter
58 WORKDIR
=`mktemp -d -q "/tmp/${OUT}"`
60 echo "Could not create snapshot directory"
66 if [ -x /usr
/bin
/gzip ]; then
71 ARCHIVE
=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
73 echo "Could not create snapshot archive"
81 echo "Please wait, collecting information and statistics"
87 if [ -x /System
/Library
/Frameworks
/SystemConfiguration.framework
/Resources
/get
-network-info ]; then
88 /System
/Library
/Frameworks
/SystemConfiguration.framework
/Resources
/get
-network-info -s -c "${WORKDIR}"
89 elif [ -x /System
/Library
/Frameworks
/SystemConfiguration.framework
/get
-network-info ]; then
90 /System
/Library
/Frameworks
/SystemConfiguration.framework
/get
-network-info -s -c "${WORKDIR}"
91 elif [ -x /System
/Library
/PrivateFrameworks
/SystemConfiguration.framework
/get
-network-info ]; then
92 /System
/Library
/PrivateFrameworks
/SystemConfiguration.framework
/get
-network-info -s -c "${WORKDIR}"
98 if [ -x /bin
/ps
]; then
99 /bin
/ps axlww
> ps
2>&1
105 if [ -x /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
]; then
106 /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
--getinfo \
113 if [ -x /usr
/bin
/wdutil
-a -x /bin
/ls ]; then
114 ${PRIV} /usr
/bin
/wdutil dump
116 /bin
/ls -1 /private
/tmp
/wifi
-* 2>/dev
/null \
119 if [ -f "${log}" ]; then
120 b
="`basename ${log}`"
121 ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1
129 if [ -e /System
/Library
/CoreServices
/SystemVersion.plist
]; then
130 cat /System
/Library
/CoreServices
/SystemVersion.plist \
131 > SystemVersion.plist
2>&1
137 if [ -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
143 # Power Management info
145 if [ -x /usr
/bin
/pmset
]; then
147 echo "# pmset -g everything" >> pmset
149 /usr
/bin
/pmset
-g everything
2>/dev
/null
| ${TAIL_25000} >> pmset
155 if [ -x /usr
/bin
/hostinfo
]; then
156 /usr
/bin
/hostinfo
> hostinfo
2>&1
158 if [ -e /etc
/hostconfig
]; then
159 cat /etc
/hostconfig
> etc.hostconfig
2>&1
163 # System / network preferences
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 \
174 if [ -e "${f}" ]; then
176 cat "${f}" > "${b}" 2>&1
183 if [ -e /var
/log
/install.log
]; then
184 cat /var
/log
/install.log
> install.log
2>&1
188 # System / network preferences (from other volumes)
190 mount
-t hfs
| grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \
193 V_PATH
="/Volumes/${volume}"
194 if [ -h "${V_PATH}" ]; then
195 # if the path is a symlink
200 /Library
/Preferences
/SystemConfiguration
/Networkinterfaces.plist \
201 /Library
/Preferences
/SystemConfiguration
/preferences.plist \
204 if [ -f "${V_PATH}/${f}" ]; then
205 mkdir -p "OtherPreferences/${volume}"
207 cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1
215 if [ -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
218 elif [ -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
224 # mounted filesystems
226 mount
> mounted
-filesystems 2>&1
228 ${PRIV} cat /etc
/hosts
> etc.hosts
2>/dev
/null
231 # kernel extensions statistic
233 if [ -x /usr
/sbin
/kextstat
]; then
234 /usr
/sbin
/kextstat
> kextstat
2>&1
237 if [ -x /sbin
/pfctl
]; then
239 echo "# pfctl -s all" >> pf
241 ${PRIV} /sbin
/pfctl
-s all
>> pf
2>&1
242 echo "==============================" >> pf
244 echo "# pfctl -s References" >> pf
246 ${PRIV} /sbin
/pfctl
-s References
>> pf
2>&1
247 for ANCHOR
in `${PRIV} pfctl -s Anchors -v 2>/dev/null`
249 echo "==============================" >> pf
251 echo "# pfctl -a ${ANCHOR} -s all" >> pf
253 ${PRIV} /sbin
/pfctl
-a ${ANCHOR} -s all
>> pf
2>&1
260 if [ -x /usr
/local
/bin
/lsmp
]; then
261 ${PRIV} /usr
/local
/bin
/lsmp
-a -v > lsmp
2>&1
267 if [ -x /usr
/sbin
/lsof
]; then
268 ${PRIV} /usr
/sbin
/lsof
-n -O -P -T q
> lsof
2>&1 &
270 # Init a watchdog for lsof
273 while [ $WAIT_TIME -gt 0 ]
275 ${PRIV} kill -0 ${LSOF_PID} 2>/dev
/null
276 if [ $?
-eq 0 ]; then
278 # lsof is gathering data..
279 WAIT_TIME
=$((WAIT_TIME-1))
283 # lsof completed gathering data
287 if [ $WAIT_TIME -eq 0 ]; then
289 ${PRIV} kill ${LSOF_PID} 2>/dev
/null
297 if [ -x /usr
/local
/bin
/ddt
]; then
298 /bin
/echo -n "" > dispatch
-info
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
314 if [ -x /usr
/bin
/odutil
]; then
316 echo "# odutil show all" >> od-info
318 ${PRIV} /usr
/bin
/odutil show all
>> od-info 2>&1
322 # Kerberos configuration
324 if [ -x /usr
/bin
/klist
]; then
326 echo "# klist --verbose --all-content" >> kerberos
328 klist
--verbose --all-content >> kerberos
2>&1
331 echo "# ktutil list" >> kerberos
333 ${PRIV} /usr
/sbin
/ktutil
--verbose list
>> kerberos
2>&1
336 echo "# gsstool list --verbose" >> kerberos
338 /System
/Library
/PrivateFrameworks
/Heimdal.framework
/Helpers
/gsstool list
--verbose >> kerberos
2>&1
344 if [ -x /usr
/sbin
/system_profiler
]; then
345 system_profiler
-xml SPEthernetDataType \
346 SPFibreChannelDataType \
351 SPThunderboltDataType \
353 SPAirPortDataType
> system_profiler.spx
2>/dev
/null
357 # system usage statistics
359 /bin
/echo -n "" > system
-statistics
361 if [ -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
368 if [ -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
375 if [ -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
382 if [ -x /usr
/sbin
/lsof
-a -x /bin
/ls ]; then
384 /bin
/ls -1 /Library
/Preferences
/SystemConfiguration
/*-lock \
388 if [ ${N} -eq 0 ]; then
389 echo "#" >> system
-statistics
390 echo "# lsof [SCPreferences lock files]" >> system
-statistics
394 echo "#" >> system
-statistics
395 ${PRIV} /usr
/sbin
/lsof
-- ${lock} >> system
-statistics 2>&1
400 # collect executable and plugin info
404 if [ ! -f "${1}" ]; then
408 VERSION
=`what "${1}"`
409 echo "${VERSION}" >> versions
2>&1
412 echo "\tsum: ${SUM}" >> versions
2>&1
414 LSINFO
=`ls -lu "${1}"`
415 echo "\tadditional info: ${LSINFO}" >> versions
2>&1
417 echo "" >> versions
2>&1
423 /usr
/libexec
/bootpd \
424 /usr
/libexec
/configd \
425 /usr
/libexec
/discoveryd \
427 /usr
/sbin
/mDNSResponder \
431 /usr
/libexec
/InternetSharing \
432 /System
/Library
/Frameworks
/SystemConfiguration.framework
/SystemConfiguration \
435 report_binary_info
"${BIN}"
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 \
443 | awk '{ print $NF }' \
446 SDKPATH
="`xcrun --sdk $SDK --show-sdk-path`"
448 /usr
/libexec
/configd_sim \
449 /System
/Library
/Frameworks
/SystemConfiguration.framework
/SystemConfiguration \
452 report_binary_info
"${SDKPATH}${BIN}"
456 echo "*** NO SDKs ***" >> versions
465 cd /System
/Library
/SystemConfiguration
466 for PLUGIN
in *.bundle
468 plugins
[$num]="${PLUGIN}"
474 for PLUGIN
in "${plugins[@]}"
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
485 echo "${PLUGIN}" >> versions
2>&1
488 BOOL
=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null`
489 if [ $?
-eq 0 ]; then
490 if [ ${BOOL} = "TRUE" ]; then
496 echo "\t${ENABLED}" >> versions
2>&1
499 BOOL
=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null`
500 if [ $?
-eq 0 ]; then
501 if [ ${BOOL} = "TRUE" ]; then
505 if [ -n "${VERBOSE}" ]; then
506 echo "\t${VERBOSE}" >> versions
2>&1
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`
513 echo "\tVersion: ${VERSION}" >> versions
2>&1
515 if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then
516 SUM
=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
517 echo "\tsum: ${SUM}" >> versions
2>&1
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
525 LSINFO
=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"`
526 echo "\tadditional info: ${LSINFO}" >> versions
2>&1
529 echo "" >> versions
2>&1
533 if [ -x /usr
/bin
/what
-a -x /usr
/bin
/sum -a -x /bin
/ls ]; then
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
544 # system log, kernel.log, early boot log messages
546 if [ -x /usr
/bin
/syslog
]; then
548 # save the recent activity
550 ${PRIV} /usr
/bin
/syslog
-T local.3 \
551 | ${TAIL_25000} > syslog
554 # save just the "kernel" activity (in case some of the
555 # interesting/relevant message are before the messages
558 ${PRIV} /usr
/bin
/syslog
-T local.3 -k Facility kern \
559 | ${TAIL_25000} > kernel
561 if [ -d /var
/log
/DiagnosticMessages
]; then
562 # save any MessageTracer activity
563 ${PRIV} /usr
/bin
/syslog
-d /var
/log
/DiagnosticMessages \
566 | ${TAIL_25000} > DiagnosticMessages
569 if [ -f /var
/log
/system.log
]; then
570 ${PRIV} ${TAIL_25000} /var
/log
/system.log
> system.log
572 if [ -f /var
/log
/kernel.log
]; then
573 ${PRIV} ${TAIL_25000} /var
/log
/kernel.log
> kernel.log
576 if [ -x /sbin
/dmesg
]; then
577 ${PRIV} /sbin
/dmesg
> dmesg
581 # IPConfiguration log
583 if [ -f /var
/log
/com.apple.IPConfiguration.bootp
]; then
584 ${PRIV} ${TAIL_2000} /var
/log
/com.apple.IPConfiguration.bootp \
585 > com.apple.IPConfiguration.bootp
591 scutil
<<_END_OF_INPUT \
595 if (index($2, "/") == 1) { print $2 } \
596 else { print "/var/log/ppp/" $2 } \
599 print "/tmp/pppotcp.log" \
605 show Setup:/Network/Service/[^/]+/PPP pattern
609 if [ -f "${logFile}" ]; then
610 b
="`basename ${logFile}`"
611 cat "${logFile}" > "${b}" 2>&1
616 # application firewall log
618 if [ -f /var
/log
/appfirewall.log
]; then
619 ${PRIV} ${TAIL_2000} /var
/log
/appfirewall.log
> appfirewall.log
622 if [ -x /bin
/ls ]; then
624 # collect crash reports
637 mDNSResponderHelper \
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 \
651 if [ -f "${log}" ]; then
652 b
="`basename ${log}`"
653 ${PRIV} cat "${log}" > "${b}" 2>&1
659 # collect any verbose logging output
661 /bin
/ls -1 /Library
/Logs
/CrashReporter
/com.apple.networking.
*.log
* \
665 if [ -f "${log}" ]; then
666 b
="`basename ${log}`"
667 ${PRIV} cat "${log}" > "${b}" 2>&1
675 if [ -x /usr
/local
/bin
/crstackshot
]; then
676 /usr
/local
/bin
/crstackshot
2>/dev
/null
680 # wait for background activity (eg: lsof)
685 # collect everything into a single archive
688 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
691 if [ ${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}"
699 echo "Network data collected to \"${ARCHIVE}\""