2 # Copyright (c) 2004-2017 Apple Inc.
6 # Collect system & network configuration information.
9 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
15 while getopts f
:PT OPTION
; do
19 if [ ! -d "${OUTDIR}" ]; then
20 echo "# ${PROGNAME}: \"${OUTDIR}\" is not a directory"
38 cat <<_END_OF_DISCLAIMER
40 This diagnostic tool generates files that allow Apple to investigate issues
41 with your computer and help Apple to improve its products. The generated files
42 may contain some of your personal information, which may include, but not be
43 limited to, the serial number or similar unique number for your device, your
44 user name, or your computer name. The information is used by Apple in
45 accordance with its privacy policy (www.apple.com/privacy) and is not shared
46 with any third party. By enabling this diagnostic tool and sending a copy of
47 the generated files to Apple, you are consenting to Apple's use of the content
52 /bin
/echo "Press 'Enter' to continue."
59 if [ ${EUID} -ne 0 ]; then
63 if [ -x /usr
/bin
/tail ]; then
64 TAIL_2000
="/usr/bin/tail -n 2000"
65 TAIL_25000
="/usr/bin/tail -n 25000"
71 OUT
="mobility-info-`date +'%Y.%m.%d.%H%M%S'`"
73 if [ -z $OUTDIR ]; then
75 if [ -d ~
/Desktop
]; then
77 elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
78 OUTDIR
=/Library
/Logs
/DiagnosticReports
79 if [ ! -d /Library
/Logs
/DiagnosticReports
-a -d /Library
/Logs
/CrashReporter
]; then
80 OUTDIR
=/Library
/Logs
/CrashReporter
88 WORKDIR
=`mktemp -d -q "/tmp/${OUT}"`
90 echo "Could not create snapshot directory"
94 if [ $NO_TAR -eq 0 ]; then
97 if [ -x /usr
/bin
/gzip ]; then
102 ARCHIVE
=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
103 if [ $?
-ne 0 ]; then
104 echo "Could not create snapshot archive"
113 echo "Please wait, collecting information and statistics"
117 # collect packet capture with kernel ring buffer if available
121 # Stop the packet capture
123 if [ ${PCAP_STARTED} -ne 0 ]; then
125 /usr
/local
/bin
/netdiagnose stop packetcapture
2>&1
131 if [ -x /usr
/local
/bin
/netdiagnose
-a ${NO_PCAP} -ne 1 ]; then
132 trap stop_pcap SIGINT
133 /usr
/local
/bin
/netdiagnose
-p "${WORKDIR}" start packetcapture
2>&1
140 if [ -x /System
/Library
/Frameworks
/SystemConfiguration.framework
/Resources
/get
-network-info ]; then
141 /bin
/sh
/System
/Library
/Frameworks
/SystemConfiguration.framework
/Resources
/get
-network-info -s -c -P "${WORKDIR}"
142 elif [ -x /System
/Library
/Frameworks
/SystemConfiguration.framework
/get
-network-info ]; then
143 /bin
/sh
/System
/Library
/Frameworks
/SystemConfiguration.framework
/get
-network-info -s -c -P "${WORKDIR}"
144 elif [ -x /System
/Library
/PrivateFrameworks
/SystemConfiguration.framework
/get
-network-info ]; then
145 /bin
/sh
/System
/Library
/PrivateFrameworks
/SystemConfiguration.framework
/get
-network-info -s -c -P "${WORKDIR}"
151 if [ -x /bin
/ps
]; then
152 /bin
/ps axlww
> ps
2>&1
158 if [ -x /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
]; then
159 /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
--getinfo \
166 if [ -x /usr
/bin
/wdutil
-a -x /bin
/ls ]; then
167 ${PRIV} /usr
/bin
/wdutil dump
169 /bin
/ls -1 /private
/tmp
/wifi
-* 2>/dev
/null \
172 if [ -f "${log}" ]; then
173 b
="`basename ${log}`"
174 ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1
182 if [ -e /System
/Library
/CoreServices
/SystemVersion.plist
]; then
183 cat /System
/Library
/CoreServices
/SystemVersion.plist \
184 > SystemVersion.plist
2>&1
190 if [ -x /usr
/sbin
/ioreg
]; then
191 /usr
/sbin
/ioreg
-i -l -w 0 > ioreg
2>&1
192 /usr
/sbin
/ioreg
-i -l -p IODeviceTree
-w 0 >> ioreg
2>&1
196 # Power Management info
198 if [ -x /usr
/bin
/pmset
]; then
200 echo "# pmset -g everything" >> pmset
202 /usr
/bin
/pmset
-g everything
2>/dev
/null
| ${TAIL_25000} >> pmset
208 if [ -x /usr
/bin
/hostinfo
]; then
209 /usr
/bin
/hostinfo
> hostinfo
2>&1
211 if [ -e /etc
/hostconfig
]; then
212 cat /etc
/hostconfig
> etc.hostconfig
2>&1
216 # System / network preferences
219 /Library
/Preferences
/SystemConfiguration
/com.apple.PowerManagement.plist \
220 /Library
/Preferences
/SystemConfiguration
/com.apple.airport.preferences.plist \
221 /Library
/Preferences
/SystemConfiguration
/com.apple.wifi.plist \
222 /Library
/Preferences
/com.apple.alf.plist \
223 /Library
/Preferences
/com.apple.sharing.firewall.plist \
224 /Library
/Preferences
/com.apple.wwand.plist \
227 if [ -e "${f}" ]; then
229 cat "${f}" > "${b}" 2>&1
236 if [ -e /var
/log
/install.log
]; then
237 cat /var
/log
/install.log
> install.log
2>&1
241 # System / network preferences (from other volumes)
243 mount
-t hfs
| grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \
246 V_PATH
="/Volumes/${volume}"
247 if [ -h "${V_PATH}" ]; then
248 # if the path is a symlink
253 /Library
/Preferences
/SystemConfiguration
/Networkinterfaces.plist \
254 /Library
/Preferences
/SystemConfiguration
/preferences.plist \
257 if [ -f "${V_PATH}/${f}" ]; then
258 mkdir -p "OtherPreferences/${volume}"
260 cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1
268 if [ -e /etc
/bootpd.plist
]; then
269 cat /etc
/bootpd.plist
> bootpd.plist
2>&1
270 cat /etc
/com.apple.named.proxy.conf
> com.apple.named.proxy.conf
2>/dev
/null
271 elif [ -e /Library
/Preferences
/SystemConfiguration
/bootpd.plist
]; then
272 cat /Library
/Preferences
/SystemConfiguration
/bootpd.plist
> bootpd.plist
2>&1
273 cat /Library
/Preferences
/SystemConfiguration
/com.apple.named.proxy.conf
> com.apple.named.proxy.conf
2>/dev
/null
277 # mounted filesystems
279 mount
> mounted
-filesystems 2>&1
281 ${PRIV} cat /etc
/hosts
> etc.hosts
2>/dev
/null
284 # kernel extensions statistic
286 if [ -x /usr
/sbin
/kextstat
]; then
287 /usr
/sbin
/kextstat
> kextstat
2>&1
290 if [ -x /sbin
/pfctl
]; then
292 echo "# pfctl -s all" >> pf
294 ${PRIV} /sbin
/pfctl
-s all
>> pf
2>&1
295 echo "==============================" >> pf
297 echo "# pfctl -s References" >> pf
299 ${PRIV} /sbin
/pfctl
-s References
>> pf
2>&1
300 for ANCHOR
in `${PRIV} pfctl -s Anchors -v 2>/dev/null`
302 echo "==============================" >> pf
304 echo "# pfctl -a ${ANCHOR} -s all" >> pf
306 ${PRIV} /sbin
/pfctl
-a ${ANCHOR} -s all
>> pf
2>&1
313 if [ -x /usr
/local
/bin
/lsmp
]; then
314 ${PRIV} /usr
/local
/bin
/lsmp
-a -v > lsmp
2>&1
320 if [ -x /usr
/sbin
/lsof
]; then
321 ${PRIV} /usr
/sbin
/lsof
+c
0 -n -O -P -T q
> lsof
2>&1 &
323 # Init a watchdog for lsof
326 while [ $WAIT_TIME -gt 0 ]
328 ${PRIV} kill -0 ${LSOF_PID} 2>/dev
/null
329 if [ $?
-eq 0 ]; then
331 # lsof is gathering data..
332 WAIT_TIME
=$((WAIT_TIME-1))
336 # lsof completed gathering data
340 if [ $WAIT_TIME -eq 0 ]; then
342 ${PRIV} kill ${LSOF_PID} 2>/dev
/null
350 if [ -x /usr
/local
/bin
/ddt
]; then
351 /bin
/echo -n "" > dispatch
-info
357 echo "#" >> dispatch
-info
358 echo "# ddt -vkp ${BIN}" >> dispatch
-info
359 echo "#" >> dispatch
-info
360 ${PRIV} /usr
/local
/bin
/ddt
-vkp ${BIN} >> dispatch
-info 2>&1
367 if [ -x /usr
/bin
/odutil
]; then
369 echo "# odutil show all" >> od-info
371 ${PRIV} /usr
/bin
/odutil show all
>> od-info 2>&1
375 # Kerberos configuration
377 if [ -x /usr
/bin
/klist
]; then
379 echo "# klist --verbose --all-content" >> kerberos
381 klist
--verbose --all-content >> kerberos
2>&1
384 echo "# ktutil list" >> kerberos
386 ${PRIV} /usr
/sbin
/ktutil
--verbose list
>> kerberos
2>&1
389 echo "# gsstool list --verbose" >> kerberos
391 /System
/Library
/PrivateFrameworks
/Heimdal.framework
/Helpers
/gsstool list
--verbose >> kerberos
2>&1
397 if [ -x /usr
/sbin
/system_profiler
]; then
398 system_profiler
-xml SPEthernetDataType \
399 SPFibreChannelDataType \
404 SPThunderboltDataType \
406 SPAirPortDataType
> system_profiler.spx
2>/dev
/null
410 # system usage statistics
412 /bin
/echo -n "" > system
-statistics
414 if [ -x /usr
/bin
/uptime
]; then
415 echo "#" >> system
-statistics
416 echo "# uptime" >> system
-statistics
417 echo "#" >> system
-statistics
418 /usr
/bin
/uptime
>> system
-statistics 2>&1
421 if [ -x /usr
/sbin
/sysctl
]; then
422 echo "#" >> system
-statistics
423 echo "# sysctl kern hw net debug" >> system
-statistics
424 echo "#" >> system
-statistics
425 /usr
/sbin
/sysctl kern hw net debug
>> system
-statistics 2>&1
428 if [ -x /usr
/bin
/zprint
]; then
429 echo "#" >> system
-statistics
430 echo "# zprint" >> system
-statistics
431 echo "#" >> system
-statistics
432 ${PRIV} /usr
/bin
/zprint
>> system
-statistics 2>&1
435 if [ -x /usr
/sbin
/lsof
-a -x /bin
/ls ]; then
437 /bin
/ls -1 /Library
/Preferences
/SystemConfiguration
/*-lock \
441 if [ ${N} -eq 0 ]; then
442 echo "#" >> system
-statistics
443 echo "# lsof [SCPreferences lock files]" >> system
-statistics
447 echo "#" >> system
-statistics
448 ${PRIV} /usr
/sbin
/lsof
+c
0 -- ${lock} >> system
-statistics 2>&1
453 # collect executable and plugin info
457 if [ ! -f "${1}" ]; then
461 VERSION
=`what "${1}"`
462 echo "${VERSION}" >> versions
2>&1
465 echo "\tsum: ${SUM}" >> versions
2>&1
467 LSINFO
=`ls -lu "${1}"`
468 echo "\tadditional info: ${LSINFO}" >> versions
2>&1
470 echo "" >> versions
2>&1
476 /usr
/libexec
/bootpd \
477 /usr
/libexec
/configd \
478 /usr
/libexec
/discoveryd \
480 /usr
/sbin
/mDNSResponder \
484 /usr
/libexec
/InternetSharing \
485 /System
/Library
/Frameworks
/SystemConfiguration.framework
/SystemConfiguration \
488 report_binary_info
"${BIN}"
491 if [ -x /usr
/bin
/xcode
-select -a -x /usr
/bin
/xcodebuild
-a -x /usr
/bin
/xcrun
]; then
492 SDKPATH
="`xcode-select --print-path 2>/dev/null`"
493 if [ $?
-eq 0 -a -n "${SDKPATH}" ]; then
494 /usr
/bin
/xcodebuild
-showsdks 2>/dev
/null \
496 | awk '{ print $NF }' \
499 SDKPATH
="`xcrun --sdk $SDK --show-sdk-path`"
501 /usr
/libexec
/configd_sim \
502 /System
/Library
/Frameworks
/SystemConfiguration.framework
/SystemConfiguration \
505 report_binary_info
"${SDKPATH}${BIN}"
509 echo "*** NO SDKs ***" >> versions
518 cd /System
/Library
/SystemConfiguration
519 for PLUGIN
in *.bundle
521 plugins
[$num]="${PLUGIN}"
527 for PLUGIN
in "${plugins[@]}"
529 PLUGIN_DIR
="/System/Library/SystemConfiguration/${PLUGIN}"
530 PLUGIN_INF
="${PLUGIN_DIR}/Contents/Info.plist"
531 if [ ! -f "${PLUGIN_INF}" ]; then
532 PLUGIN_INF
="${PLUGIN_DIR}/Info.plist"
533 if [ ! -f "${PLUGIN_INF}" ]; then
534 echo "${PLUGIN_INF}: No Info.plist" >> versions
2>&1
538 echo "${PLUGIN}" >> versions
2>&1
541 BOOL
=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null`
542 if [ $?
-eq 0 ]; then
543 if [ ${BOOL} = "TRUE" ]; then
549 echo "\t${ENABLED}" >> versions
2>&1
552 BOOL
=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null`
553 if [ $?
-eq 0 ]; then
554 if [ ${BOOL} = "TRUE" ]; then
558 if [ -n "${VERBOSE}" ]; then
559 echo "\t${VERBOSE}" >> versions
2>&1
562 VERSION
=`scutil --get "${PLUGIN_INF}" / CFBundleVersion 2>/dev/null`
563 if [ $?
-eq 1 ]; then
564 VERSION
=`scutil --get "${PLUGIN_INF}" / CFBundleShortVersionString 2>/dev/null`
566 echo "\tVersion: ${VERSION}" >> versions
2>&1
568 if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then
569 SUM
=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
570 echo "\tsum: ${SUM}" >> versions
2>&1
572 LSINFO
=`ls -lu "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
573 echo "\tadditional info: ${LSINFO}" >> versions
2>&1
574 elif [ -f "${PLUGIN_DIR}/${PLUGIN%.*}" ]; then
575 SUM
=`sum "${PLUGIN_DIR}/${PLUGIN%.*}"`
576 echo "\tsum: ${SUM}" >> versions
2>&1
578 LSINFO
=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"`
579 echo "\tadditional info: ${LSINFO}" >> versions
2>&1
582 echo "" >> versions
2>&1
586 if [ -x /usr
/bin
/what
-a -x /usr
/bin
/sum -a -x /bin
/ls ]; then
592 # collect the logarchive
594 if [ -x /usr
/bin
/log
]; then
595 LOGARCHIVE_START_TIME
=`date -v -1d +"%Y-%m-%d %H:%M:%S"`
596 LOGARCHIVE_OUTPUT
="system_logs.logarchive"
597 ${PRIV} /usr
/bin
/log collect
--livedata --output "${LOGARCHIVE_OUTPUT}" --start "${LOGARCHIVE_START_TIME}" 2>/dev
/null
598 if [ -d ${LOGARCHIVE_OUTPUT} ]; then
599 ${PRIV} chown
-R ${UID} "${LOGARCHIVE_OUTPUT}"
606 if [ -x /sbin
/dmesg
]; then
607 ${PRIV} /sbin
/dmesg
> dmesg
613 scutil
<<_END_OF_INPUT \
617 if (index($2, "/") == 1) { print $2 } \
618 else { print "/var/log/ppp/" $2 } \
621 print "/tmp/pppotcp.log" \
627 show Setup:/Network/Service/[^/]+/PPP pattern
631 if [ -f "${logFile}" ]; then
632 b
="`basename ${logFile}`"
633 cat "${logFile}" > "${b}" 2>&1
637 if [ -x /bin
/ls ]; then
639 # collect crash reports
652 mDNSResponderHelper \
658 /bin
/ls -1 /Library
/Logs
/DiagnosticReports
/${daemon}_
*.crash \
659 /Library
/Logs
/DiagnosticReports
/${daemon}_
*.ips \
660 /Library
/Logs
/CrashReporter
/${daemon}_
*.crash \
661 /Library
/Logs
/CrashReporter
/${daemon}_
*.ips \
662 /Library
/Logs
/CrashReporter
/${daemon}_
*.plist \
666 if [ -f "${log}" ]; then
667 b
="`basename ${log}`"
668 ${PRIV} cat "${log}" > "${b}" 2>&1
677 if [ -x /usr
/local
/bin
/crstackshot
]; then
678 /usr
/local
/bin
/crstackshot
2>/dev
/null
682 # wait for background activity (eg: lsof)
687 # Stop the packet capture
691 if [ $NO_TAR -eq 0 ]; then
693 # collect everything into a single archive
696 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
699 if [ ${UID} -eq 0 ]; then
700 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
701 if [ ${UID} -ne ${SUDO_UID} ]; then
702 chown
${SUDO_UID}:${SUDO_GID} "${ARCHIVE}"
707 echo "Network data collected to \"${ARCHIVE}\""
709 mv "${WORKDIR}" "${OUTDIR}"
711 if [ ${UID} -eq 0 ]; then
712 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
713 if [ ${UID} -ne ${SUDO_UID} ]; then
714 chown
-R ${SUDO_UID}:${SUDO_GID} "${OUTDIR}/${OUT}"
718 echo "Network data collected to \"${OUTDIR}/${OUT}\""