]> git.saurik.com Git - apple/configd.git/blame - get-mobility-info
configd-130.tar.gz
[apple/configd.git] / get-mobility-info
CommitLineData
dbf6a266
A
1#!/bin/sh
2# get-mobility-info
3#
4# Collect system & network configuration information.
5#
6
7OUT=mobility-config-$$
8
9PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
11PRIV=""
12if [ ${EUID} -ne 0 ]; then
13 PRIV="sudo"
14fi
15
16cd /tmp
17mkdir ${OUT}
18
19#
20# processes
21#
22ps axlww > ${OUT}/ps 2>&1
23
24#
25# network interface configuration
26#
27ifconfig -a -b > ${OUT}/ifconfig 2>&1
28
29#
30# network route configuration
31#
32netstat -n -r >> ${OUT}/netstat 2>&1
33
34#
35# DHCP configuration
36#
37for if in `ifconfig -l`
38do
39 case ${if} in
40 lo* ) ;;
41 en* ) ipconfig getpacket ${if} > ${OUT}/ipconfig-${if} 2>&1
42 ;;
43 esac
44done
45
46#
47# OS info
48#
49if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
50 cat /System/Library/CoreServices/SystemVersion.plist \
51 > ${OUT}/SystemVersion.plist 2>&1
52fi
53if [ -e /System/Library/CoreServices/ServerVersion.plist ]; then
54 cat /System/Library/CoreServices/ServerVersion.plist \
55 > ${OUT}/ServerVersion.plist 2>&1
56fi
57
58#
59# IOKit info
60#
61ioreg -l > ${OUT}/ioreg 2>&1
62
63#
64# Host configuration
65#
66hostinfo > ${OUT}/hostinfo 2>&1
67if [ -e /etc/hostconfig ]; then
68 cat /etc/hostconfig > ${OUT}/etc.hostconfig 2>&1
69fi
70
71#
72# DNS configuration
73#
74scutil --dns > ${OUT}/dns-configuration 2>&1
75if [ -e /etc/resolv.conf ]; then
76 cat /etc/resolv.conf > ${OUT}/etc.resolv.conf 2>&1
77fi
78if [ -e /var/run/resolv.conf ]; then
79 cat /var/run/resolv.conf > ${OUT}/var.run.resolv.conf 2>&1
80fi
81
82#
83# NetInfo configuration
84#
85niutil -statistics . > ${OUT}/netinfo-statistics 2>&1
86if [ -f /var/run/niconfig_local.xml ]; then
87 cat /var/run/niconfig_local.xml > ${OUT}/niconfig_local.xml 2>&1
88fi
89
90#
91# System / network preferences
92#
93for f in \
94 /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \
95 /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \
96 /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \
97 /Library/Preferences/SystemConfiguration/com.apple.nat.plist \
98 /Library/Preferences/SystemConfiguration/preferences.plist \
99 /Library/Preferences/com.apple.sharing.firewall.plist \
100
101do
102 if [ -e ${f} ]; then
103 b=`basename $f`
104 cat ${f} > ${OUT}/${b} 2>&1
105 fi
106done
107
108#
109# configd's cache
110#
111${PRIV} scutil -p <<_END_OF_INPUT
112open
113snapshot
114quit
115_END_OF_INPUT
116if [ -f /var/tmp/configd-store.xml ]; then
117 cp /var/tmp/configd-store.xml ${OUT}/configd-store.xml
118fi
119if [ -f /var/tmp/configd-pattern.xml ]; then
120 cp /var/tmp/configd-pattern.xml ${OUT}/configd-pattern.xml
121fi
122if [ -f /var/tmp/configd-session.xml ]; then
123 cp /var/tmp/configd-session.xml ${OUT}/configd-session.xml
124fi
125
126#
127# network reachability
128#
129scutil -d -v -r www.apple.com > ${OUT}/reachability-info 2>&1
130if [ -f /usr/bin/dig ]; then
131 dig -t any -c any www.apple.com > ${OUT}/dig-results 2>&1
132fi
133
134#
135# mounted filesystems
136#
137mount > ${OUT}/mounted-filesystems 2>&1
138
139#
140# system log
141#
142tail -1000 /var/log/system.log > ${OUT}/system.log
143
144#
145# ppp log
146#
147if [ -f /var/log/ppp.log ]; then
148 cp /var/log/ppp.log ${OUT}/ppp.log
149fi
150
151#
152# kernel extensions statistic
153#
154if [ -f /usr/sbin/kextstat ]; then
155 kextstat > ${OUT}/kextstat 2>&1
156elif [ -f /usr/sbin/kmodstat ]; then
157 kmodstat > ${OUT}/kmodstat 2>&1
158fi
159
160#
161# network statistics
162#
163echo "#" >> ${OUT}/network-statistics
164echo "# netstat -n -a -A -f inet" >> ${OUT}/network-statistics
165echo "#" >> ${OUT}/network-statistics
166netstat -n -a -A -f inet >> ${OUT}/network-statistics 2>&1
167echo "#" >> ${OUT}/network-statistics
168echo "# lsof -n -i -P" >> ${OUT}/network-statistics
169echo "#" >> ${OUT}/network-statistics
170lsof -n -i -P >> ${OUT}/network-statistics 2>&1
171echo "#" >> ${OUT}/network-statistics
172echo "# netstat -s" >> ${OUT}/network-statistics
173echo "#" >> ${OUT}/network-statistics
174netstat -s >> ${OUT}/network-statistics 2>&1
175echo "#" >> ${OUT}/network-statistics
176echo "# netstat -m" >> ${OUT}/network-statistics
177echo "#" >> ${OUT}/network-statistics
178netstat -m >> ${OUT}/network-statistics 2>&1
179echo "#" >> ${OUT}/network-statistics
180echo "# netstat -i -n -d" >> ${OUT}/network-statistics
181echo "#" >> ${OUT}/network-statistics
182netstat -i -n -d >> ${OUT}/network-statistics 2>&1
183echo "#" >> ${OUT}/network-statistics
184echo "# ipfw -at show" >> ${OUT}/network-statistics
185echo "#" >> ${OUT}/network-statistics
186ipfw -at show >> ${OUT}/network-statistics 2>&1
187echo "#" >> ${OUT}/network-statistics
188echo "# appletalk -s" >> ${OUT}/network-statistics
189echo "#" >> ${OUT}/network-statistics
190appletalk -s >> ${OUT}/network-statistics 2>&1
191
192#
193# system usage statistics
194#
195echo "#" > ${OUT}/system-statistics
196echo "# uptime" >> ${OUT}/system-statistics
197echo "#" >> ${OUT}/system-statistics
198uptime >> ${OUT}/system-statistics 2>&1
199echo "#" >> ${OUT}/system-statistics
200echo "# pstat -t" >> ${OUT}/system-statistics
201echo "#" >> ${OUT}/system-statistics
202pstat -t >> ${OUT}/system-statistics 2>&1
203echo "#" >> ${OUT}/system-statistics
204echo "# sysctl -a" >> ${OUT}/system-statistics
205echo "#" >> ${OUT}/system-statistics
206sysctl -a >> ${OUT}/system-statistics 2>&1
207echo "#" >> ${OUT}/system-statistics
208echo "# zprint" >> ${OUT}/system-statistics
209echo "#" >> ${OUT}/system-statistics
210zprint >> ${OUT}/system-statistics 2>&1
211echo "#" >> ${OUT}/system-statistics
212echo "# top -l5 -s2" >> ${OUT}/system-statistics
213echo "#" >> ${OUT}/system-statistics
214 echo ""
215 echo "Please wait, collecting statistics"
216 echo ""
217top -s 2 -l 5 >> ${OUT}/system-statistics 2>&1
218
219#
220# collect crash reports
221#
222for daemon in bootpd configd pppd
223do
224 LOG=${daemon}.crash.log
225 if [ -e /Library/Logs/CrashReporter/${LOG} ]; then
226 cat /Library/Logs/CrashReporter/${LOG} > ${OUT}/${LOG} 2>&1
227 fi
228done
229
230#
231# collect everything into a single archive
232#
233tar cfz ${OUT}.tar.gz ${OUT}
234rm -rf ${OUT}
235
236echo "Network data collected to /tmp/${OUT}.tar.gz"