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