2 # Copyright (c) 2004-2007 Apple Inc.
6 # Collect system & network configuration information.
9 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
12 if [ ${EUID} -ne 0 ]; then
16 OUT
="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
18 if [ -d ~
/Desktop
]; then
24 WORKDIR
=`mktemp -d -q "/tmp/${OUT}"`
26 echo "Could not create snapshot directory"
30 ARCHIVE
=`mktemp -q "${OUTDIR}/${OUT}.tar.gz"`
32 echo "Could not create snapshot archive"
45 # network interface configuration
47 ifconfig
-a -b > ifconfig
2>&1
50 # network route configuration
52 netstat
-n -r -a -l > netstat
2>&1
57 for if in `ifconfig -l`
61 en
* ) ipconfig getpacket
${if} > ipconfig
-${if} 2>&1
69 if [ -x /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
]; then
70 /System
/Library
/PrivateFrameworks
/Apple80211.framework
/Resources
/airport
--getinfo \
77 if [ -e /System
/Library
/CoreServices
/SystemVersion.plist
]; then
78 cat /System
/Library
/CoreServices
/SystemVersion.plist \
79 > SystemVersion.plist
2>&1
81 if [ -e /System
/Library
/CoreServices
/ServerVersion.plist
]; then
82 cat /System
/Library
/CoreServices
/ServerVersion.plist \
83 > ServerVersion.plist
2>&1
89 ioreg
-i -l -w 0 > ioreg
2>&1
94 hostname
> hostname
2>&1
99 hostinfo
> hostinfo
2>&1
100 if [ -e /etc
/hostconfig
]; then
101 cat /etc
/hostconfig
> etc.hostconfig
2>&1
107 scutil
--dns > dns
-configuration 2>&1
108 if [ -e /etc
/resolv.conf
]; then
109 cat /etc
/resolv.conf
> etc.resolv.conf
2>&1
111 if [ -e /var
/run
/resolv.conf
]; then
112 cat /var
/run
/resolv.conf
> var.run.resolv.conf
2>&1
116 # Proxy configuration
118 scutil
--proxy > proxy
-configuration 2>&1
121 # System / network preferences
124 /Library
/Preferences
/SystemConfiguration
/NetworkInterfaces.plist \
125 /Library
/Preferences
/SystemConfiguration
/com.apple.PowerManagement.plist \
126 /Library
/Preferences
/SystemConfiguration
/com.apple.airport.preferences.plist \
127 /Library
/Preferences
/SystemConfiguration
/com.apple.nat.plist \
128 /Library
/Preferences
/SystemConfiguration
/com.apple.network.identification.plist \
129 /Library
/Preferences
/SystemConfiguration
/com.apple.smb.server.plist \
130 /Library
/Preferences
/SystemConfiguration
/preferences.plist \
131 /Library
/Preferences
/com.apple.sharing.firewall.plist \
134 if [ -e "${f}" ]; then
136 cat "${f}" > "${b}" 2>&1
143 ${PRIV} scutil
-p <<_END_OF_INPUT
148 if [ -f /var
/tmp
/configd
-store.xml
]; then
149 cat /var
/tmp
/configd
-store.xml
> configd
-store.xml
2>&1
151 if [ -f /var
/tmp
/configd
-pattern.xml
]; then
152 cat /var
/tmp
/configd
-pattern.xml
> configd
-pattern.xml
2>&1
154 if [ -f /var
/tmp
/configd
-session.xml
]; then
155 cat /var
/tmp
/configd
-session.xml
> configd
-session.xml
2>&1
157 if [ -f /var
/tmp
/configd
-state ]; then
158 cat /var
/tmp
/configd
-state > configd
-state 2>&1
162 # network reachability
164 scutil
-d -v -r www.apple.com
> reachability
-info 2>&1
165 if [ -x /usr
/bin
/dig ]; then
166 dig -t any
-c any www.apple.com
> dig-results 2>&1
170 # mounted filesystems
172 mount
> mounted
-filesystems 2>&1
177 if [ -f /var
/run
/mDNSResponder.pid
]; then
178 ${PRIV} kill -INFO `cat /var/run/mDNSResponder.pid`
182 # system log, early boot log messages
184 ${PRIV} tail -n 2000 /var
/log
/system.log
> system.log
185 ${PRIV} dmesg
> dmesg
190 scutil
<<_END_OF_INPUT \
194 if (index($2, "/") == 1) { print $2 } \
195 else { print "/var/log/ppp/" $2 } \
198 print "/tmp/pppotcp.log" \
204 show Setup:/Network/Service/[^/]+/PPP pattern
208 if [ -f "${logFile}" ]; then
209 b
="`basename ${logFile}`"
210 cat "${logFile}" > "${b}" 2>&1
215 # application firewall log
217 if [ -f /var
/log
/appfirewall.log
]; then
218 ${PRIV} tail -n 2000 /var
/log
/appfirewall.log
> appfirewall.log
222 # kernel extensions statistic
224 if [ -x /usr
/sbin
/kextstat
]; then
225 kextstat
> kextstat
2>&1
226 elif [ -x /usr
/sbin
/kmodstat
]; then
227 kmodstat
> kmodstat
2>&1
233 echo "#" > network
-statistics
234 echo "# netstat -n -a -A -f inet" >> network
-statistics
235 echo "#" >> network
-statistics
236 netstat
-n -a -A -f inet
>> network
-statistics 2>&1
238 echo "#" >> network
-statistics
239 echo "# lsof -i -n -P" >> network
-statistics
240 echo "#" >> network
-statistics
241 ${PRIV} lsof
-i -n -P >> network
-statistics 2>&1
243 echo "#" >> network
-statistics
244 echo "# netstat -s" >> network
-statistics
245 echo "#" >> network
-statistics
246 netstat
-s >> network
-statistics 2>&1
248 echo "#" >> network
-statistics
249 echo "# netstat -mmm" >> network
-statistics
250 echo "#" >> network
-statistics
251 netstat
-mmm >> network
-statistics 2>&1
253 echo "#" >> network
-statistics
254 echo "# netstat -i -n -d" >> network
-statistics
255 echo "#" >> network
-statistics
256 netstat
-i -n -d >> network
-statistics 2>&1
258 echo "#" >> network
-statistics
259 echo "# ipfw -at show" >> network
-statistics
260 echo "#" >> network
-statistics
261 ipfw
-at show
>> network
-statistics 2>&1
263 echo "#" >> network
-statistics
264 echo "# appletalk -s" >> network
-statistics
265 echo "#" >> network
-statistics
266 appletalk
-s >> network
-statistics 2>&1
269 # system usage statistics
271 echo "#" > system
-statistics
272 echo "# uptime" >> system
-statistics
273 echo "#" >> system
-statistics
274 uptime
>> system
-statistics 2>&1
276 echo "#" >> system
-statistics
277 echo "# sysctl -a" >> system
-statistics
278 echo "#" >> system
-statistics
279 sysctl
-a >> system
-statistics 2>&1
281 echo "#" >> system
-statistics
282 echo "# zprint" >> system
-statistics
283 echo "#" >> system
-statistics
284 zprint
>> system
-statistics 2>&1
286 echo "#" >> system
-statistics
287 echo "# top -l5 -s2" >> system
-statistics
288 echo "#" >> system
-statistics
290 echo "Please wait, collecting statistics"
292 top
-s 2 -l 5 >> system
-statistics 2>&1
295 # DirectoryService info
297 if [ -x /usr
/bin
/dscacheutil
]; then
299 echo "# dscacheutil -configuration" >> ds
-info
301 dscacheutil
-configuration >> ds
-info 2>&1
304 echo "# dscacheutil -statistics" >> ds
-info
306 dscacheutil
-statistics >> ds
-info 2>&1
309 echo "# dscacheutil -cachedump -entries" >> ds
-info
311 dscacheutil
-cachedump -entries >> ds
-info 2>&1
315 # IPsec configuration
318 echo "# setkey -D" >> ipsec
322 if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) {
323 chop($sha1=`echo "$2" | openssl sha1`);
324 printf "%s[SHA-1:%s]\n", $1, $sha1;
332 echo "# setkey -Pp -D" >> ipsec
334 ${PRIV} setkey
-Pp -D >> ipsec
336 for CF
in /etc
/racoon
/remote
/*.conf
340 echo "# ${CF}" >> ipsec
344 if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) {
345 chop($sha1=`echo "$2" | openssl sha1`);
346 printf "%s[SHA-1:%s]%s\n", $1, $sha1, $3;
354 # Kerberos configuration
357 echo "# klist -e -c -A -f -a -n" >> kerberos
359 ${PRIV} klist
-e -c -A -f -a -n >> kerberos
362 echo "# klist -e -k -t -K" >> kerberos
364 ${PRIV} klist
-e -k -t -K >> kerberos
371 /usr
/bin
/dig @pm
-members.mac.com
-y "${DOMAIN}:${TSIG}" +short
"${1}" "${2}"
374 scutil
<<_END_OF_INPUT \
375 | sed -n 's@.* : *\(.*\.members\.mac\.com\)$@\1@p' \
379 show Setup:/Network/BackToMyMac
384 echo "${DOMAIN}" >> btmm
386 # lookup TSIG in base64 format
388 ${PRIV} security find-generic-password \
390 -g /Library/Keychains/System.keychain 2>&1 \
391 | grep "^password: " \
395 if [ -z "$TSIG" ]; then
396 echo " No TSIG in system keychain." >> btmm
399 if [ `echo "$TSIG" | wc -l` -ne 1 ] ; then
400 echo " More than one TSIG in system keychain." >> btmm
412 DIG
"${TYPE}.${DOMAIN}" ptr \
416 /bin
/echo " ${REG}" >> btmm
419 INF_Q
=`/bin/echo "${REG}" | sed -e "s/${TYPE}/_device-info._tcp/"`
420 INF
=`DIG "${INF_Q}" txt`
421 echo " INF: ${INF}" >> btmm
424 SRV1
=`/bin/echo "${SRV}" | head -1`
425 echo " SRV: ${SRV1}" >> btmm
426 SRV2
=`/bin/echo "${SRV}" | tail +2`
427 if [ -n "${SRV2}" ]; then
429 /bin
/echo "${SRV2}" \
430 | sed -e 's/^/ *****: /' >> btmm
434 TXT1
=`/bin/echo "${TXT}" | head -1`
435 echo " TXT: ${TXT1}" >> btmm
436 TXT2
=`/bin/echo "${TXT}" | tail +2`
437 if [ -n "${TXT2}" ]; then
438 /bin
/echo "${TXT2}" \
439 | sed -e 's/^/ *****: /' >> btmm
442 HOST
=`/bin/echo "${SRV}" | cut -d ' ' -f 4-`
444 if [ -n "${V4}" ]; then
445 echo " v4: ${V4}" >> btmm
447 V6
=`DIG ${HOST} aaaa`
448 if [ -n "${V6}" ]; then
449 echo " v6: ${V6}" >> btmm
452 KRB
=`DIG _kerberos.${HOST} txt`
453 echo " KRB: ${KRB}" >> btmm
455 TUN
=`DIG _autotunnel._udp.${HOST} srv`
456 echo " TUN: ${TUN}" >> btmm
458 HOST
=`/bin/echo "${TUN}" | cut -d ' ' -f 4-`
460 if [ -n "${V4}" ]; then
461 echo " v4: ${V4}" >> btmm
463 V6
=`DIG ${HOST} aaaa`
464 if [ -n "${V6}" ]; then
465 echo " v6: ${V6}" >> btmm
472 # collect crash reports
474 CRASH_DIR
=/Library
/Logs
/CrashReporter
475 for daemon
in bootpd configd pppd
477 /bin
/ls -1 ${CRASH_DIR}/${daemon}_
*.crash
2>/dev
/null \
480 b
="`basename ${log}`"
481 ${PRIV} cat "${log}" > "${b}" 2>&1
486 # collect everything into a single archive
489 tar cfz
"${ARCHIVE}" "${OUT}"
492 if [ ${UID} -eq 0 ]; then
493 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
494 if [ ${UID} -ne ${SUDO_UID} ]; then
495 chown
${SUDO_UID}:${SUDO_GID} "${ARCHIVE}"
500 echo "Network data collected to \"${ARCHIVE}\""