| 1 | #!/bin/sh |
| 2 | # Copyright (c) 2004-2015 Apple Inc. |
| 3 | # |
| 4 | # get-mobility-info |
| 5 | # |
| 6 | # Collect system & network configuration information. |
| 7 | # |
| 8 | |
| 9 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
| 10 | |
| 11 | # |
| 12 | # Disclaimer |
| 13 | # |
| 14 | cat <<_END_OF_DISCLAIMER |
| 15 | |
| 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 |
| 24 | of such files. |
| 25 | |
| 26 | _END_OF_DISCLAIMER |
| 27 | |
| 28 | /bin/echo "Press 'Enter' to continue." |
| 29 | read reply |
| 30 | |
| 31 | # |
| 32 | # Setup |
| 33 | # |
| 34 | PRIV="" |
| 35 | if [ ${EUID} -ne 0 ]; then |
| 36 | PRIV="sudo" |
| 37 | fi |
| 38 | |
| 39 | if [ -x /usr/bin/tail ]; then |
| 40 | TAIL_2000="/usr/bin/tail -n 2000" |
| 41 | TAIL_25000="/usr/bin/tail -n 25000" |
| 42 | else |
| 43 | TAIL_2000="/bin/cat" |
| 44 | TAIL_25000="/bin/cat" |
| 45 | fi |
| 46 | |
| 47 | OUT="mobility-info-`date +'%Y.%m.%d.%H%M%S'`" |
| 48 | OUTDIR="/var/tmp" |
| 49 | if [ -d ~/Desktop ]; then |
| 50 | OUTDIR=~/Desktop |
| 51 | elif [ "`readlink /tmp`" = "private/var/tmp" ]; then |
| 52 | OUTDIR=/Library/Logs/CrashReporter |
| 53 | mkdir -p ${OUTDIR} |
| 54 | fi |
| 55 | |
| 56 | umask 077 |
| 57 | |
| 58 | WORKDIR=`mktemp -d -q "/tmp/${OUT}"` |
| 59 | if [ $? -ne 0 ]; then |
| 60 | echo "Could not create snapshot directory" |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | GZ_EXT="" |
| 65 | GZ_OPT="" |
| 66 | if [ -x /usr/bin/gzip ]; then |
| 67 | GZ_EXT=".gz" |
| 68 | GZ_OPT="-z" |
| 69 | fi |
| 70 | |
| 71 | ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"` |
| 72 | if [ $? -ne 0 ]; then |
| 73 | echo "Could not create snapshot archive" |
| 74 | rm -rf "${WORKDIR}" |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | cd "${WORKDIR}" |
| 79 | |
| 80 | echo "" |
| 81 | echo "Please wait, collecting information and statistics" |
| 82 | echo "" |
| 83 | |
| 84 | # |
| 85 | # get-network-info |
| 86 | # |
| 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}" |
| 93 | fi |
| 94 | |
| 95 | # |
| 96 | # processes |
| 97 | # |
| 98 | if [ -x /bin/ps ]; then |
| 99 | /bin/ps axlww > ps 2>&1 |
| 100 | fi |
| 101 | |
| 102 | # |
| 103 | # AirPort info |
| 104 | # |
| 105 | if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then |
| 106 | /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \ |
| 107 | > airport 2>&1 |
| 108 | fi |
| 109 | |
| 110 | # |
| 111 | # collect wifi dump |
| 112 | # |
| 113 | if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then |
| 114 | ${PRIV} /usr/bin/wdutil dump |
| 115 | mkdir -p "wifi_dump" |
| 116 | /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \ |
| 117 | | while read log |
| 118 | do |
| 119 | if [ -f "${log}" ]; then |
| 120 | b="`basename ${log}`" |
| 121 | ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1 |
| 122 | fi |
| 123 | done |
| 124 | fi |
| 125 | |
| 126 | # |
| 127 | # OS info |
| 128 | # |
| 129 | if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then |
| 130 | cat /System/Library/CoreServices/SystemVersion.plist \ |
| 131 | > SystemVersion.plist 2>&1 |
| 132 | fi |
| 133 | |
| 134 | # |
| 135 | # IOKit info |
| 136 | # |
| 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 |
| 140 | fi |
| 141 | |
| 142 | # |
| 143 | # Power Management info |
| 144 | # |
| 145 | if [ -x /usr/bin/pmset ]; then |
| 146 | echo "#" > pmset |
| 147 | echo "# pmset -g everything" >> pmset |
| 148 | echo "#" >> pmset |
| 149 | /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset |
| 150 | fi |
| 151 | |
| 152 | # |
| 153 | # Host configuration |
| 154 | # |
| 155 | if [ -x /usr/bin/hostinfo ]; then |
| 156 | /usr/bin/hostinfo > hostinfo 2>&1 |
| 157 | fi |
| 158 | if [ -e /etc/hostconfig ]; then |
| 159 | cat /etc/hostconfig > etc.hostconfig 2>&1 |
| 160 | fi |
| 161 | |
| 162 | # |
| 163 | # System / network preferences |
| 164 | # |
| 165 | for f in \ |
| 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 \ |
| 172 | |
| 173 | do |
| 174 | if [ -e "${f}" ]; then |
| 175 | b="`basename ${f}`" |
| 176 | cat "${f}" > "${b}" 2>&1 |
| 177 | fi |
| 178 | done |
| 179 | |
| 180 | # |
| 181 | # Install log |
| 182 | # |
| 183 | if [ -e /var/log/install.log ]; then |
| 184 | cat /var/log/install.log > install.log 2>&1 |
| 185 | fi |
| 186 | |
| 187 | # |
| 188 | # System / network preferences (from other volumes) |
| 189 | # |
| 190 | mount -t hfs | grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \ |
| 191 | | while read volume |
| 192 | do |
| 193 | V_PATH="/Volumes/${volume}" |
| 194 | if [ -h "${V_PATH}" ]; then |
| 195 | # if the path is a symlink |
| 196 | continue |
| 197 | fi |
| 198 | |
| 199 | for f in \ |
| 200 | /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \ |
| 201 | /Library/Preferences/SystemConfiguration/preferences.plist \ |
| 202 | |
| 203 | do |
| 204 | if [ -f "${V_PATH}/${f}" ]; then |
| 205 | mkdir -p "OtherPreferences/${volume}" |
| 206 | b="`basename ${f}`" |
| 207 | cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1 |
| 208 | fi |
| 209 | done |
| 210 | done |
| 211 | |
| 212 | # |
| 213 | # InternetSharing |
| 214 | # |
| 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 |
| 221 | fi |
| 222 | |
| 223 | # |
| 224 | # mounted filesystems |
| 225 | # |
| 226 | mount > mounted-filesystems 2>&1 |
| 227 | |
| 228 | ${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null |
| 229 | |
| 230 | # |
| 231 | # kernel extensions statistic |
| 232 | # |
| 233 | if [ -x /usr/sbin/kextstat ]; then |
| 234 | /usr/sbin/kextstat > kextstat 2>&1 |
| 235 | fi |
| 236 | |
| 237 | if [ -x /sbin/pfctl ]; then |
| 238 | echo "#" > pf |
| 239 | echo "# pfctl -s all" >> pf |
| 240 | echo "#" >> pf |
| 241 | ${PRIV} /sbin/pfctl -s all >> pf 2>&1 |
| 242 | echo "==============================" >> pf |
| 243 | echo "#" >> pf |
| 244 | echo "# pfctl -s References" >> pf |
| 245 | echo "#" >> pf |
| 246 | ${PRIV} /sbin/pfctl -s References >> pf 2>&1 |
| 247 | for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null` |
| 248 | do |
| 249 | echo "==============================" >> pf |
| 250 | echo "#" >> pf |
| 251 | echo "# pfctl -a ${ANCHOR} -s all" >> pf |
| 252 | echo "#" >> pf |
| 253 | ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1 |
| 254 | done |
| 255 | fi |
| 256 | |
| 257 | # |
| 258 | # mach port info |
| 259 | # |
| 260 | if [ -x /usr/local/bin/lsmp ]; then |
| 261 | ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1 |
| 262 | fi |
| 263 | |
| 264 | # |
| 265 | # open files |
| 266 | # |
| 267 | if [ -x /usr/sbin/lsof ]; then |
| 268 | ${PRIV} /usr/sbin/lsof -n -O -P -T q > lsof 2>&1 & |
| 269 | LSOF_PID=$! |
| 270 | # Init a watchdog for lsof |
| 271 | ( |
| 272 | WAIT_TIME=5 |
| 273 | while [ $WAIT_TIME -gt 0 ] |
| 274 | do |
| 275 | ${PRIV} kill -0 ${LSOF_PID} 2>/dev/null |
| 276 | if [ $? -eq 0 ]; then |
| 277 | sleep 1 |
| 278 | # lsof is gathering data.. |
| 279 | WAIT_TIME=$((WAIT_TIME-1)) |
| 280 | continue |
| 281 | fi |
| 282 | |
| 283 | # lsof completed gathering data |
| 284 | break |
| 285 | done |
| 286 | |
| 287 | if [ $WAIT_TIME -eq 0 ]; then |
| 288 | # lsof timed out |
| 289 | ${PRIV} kill ${LSOF_PID} 2>/dev/null |
| 290 | fi |
| 291 | ) & |
| 292 | fi |
| 293 | |
| 294 | # |
| 295 | # [lib]dispatch info |
| 296 | # |
| 297 | if [ -x /usr/local/bin/ddt ]; then |
| 298 | /bin/echo -n "" > dispatch-info |
| 299 | for BIN in \ |
| 300 | configd \ |
| 301 | discoveryd \ |
| 302 | |
| 303 | do |
| 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 |
| 308 | done |
| 309 | fi |
| 310 | |
| 311 | # |
| 312 | # OpenDirectory info |
| 313 | # |
| 314 | if [ -x /usr/bin/odutil ]; then |
| 315 | echo "#" > od-info |
| 316 | echo "# odutil show all" >> od-info |
| 317 | echo "#" >> od-info |
| 318 | ${PRIV} /usr/bin/odutil show all >> od-info 2>&1 |
| 319 | fi |
| 320 | |
| 321 | # |
| 322 | # Kerberos configuration |
| 323 | # |
| 324 | if [ -x /usr/bin/klist ]; then |
| 325 | echo "#" > kerberos |
| 326 | echo "# klist --verbose --all-content" >> kerberos |
| 327 | echo "#" >> kerberos |
| 328 | klist --verbose --all-content >> kerberos 2>&1 |
| 329 | |
| 330 | echo "#" >> kerberos |
| 331 | echo "# ktutil list" >> kerberos |
| 332 | echo "#" >> kerberos |
| 333 | ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1 |
| 334 | |
| 335 | echo "#" >> kerberos |
| 336 | echo "# gsstool list --verbose" >> kerberos |
| 337 | echo "#" >> kerberos |
| 338 | /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1 |
| 339 | fi |
| 340 | |
| 341 | # |
| 342 | # system profiler |
| 343 | # |
| 344 | if [ -x /usr/sbin/system_profiler ]; then |
| 345 | system_profiler -xml SPEthernetDataType \ |
| 346 | SPFibreChannelDataType \ |
| 347 | SPFireWireDataType \ |
| 348 | SPFirewallDataType \ |
| 349 | SPModemDataType \ |
| 350 | SPNetworkDataType \ |
| 351 | SPThunderboltDataType \ |
| 352 | SPWWANDataType \ |
| 353 | SPAirPortDataType > system_profiler.spx 2>/dev/null |
| 354 | fi |
| 355 | |
| 356 | # |
| 357 | # system usage statistics |
| 358 | # |
| 359 | /bin/echo -n "" > system-statistics |
| 360 | |
| 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 |
| 366 | fi |
| 367 | |
| 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 |
| 373 | fi |
| 374 | |
| 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 |
| 380 | fi |
| 381 | |
| 382 | if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then |
| 383 | N=0 |
| 384 | /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \ |
| 385 | 2>/dev/null \ |
| 386 | | while read lock |
| 387 | do |
| 388 | if [ ${N} -eq 0 ]; then |
| 389 | echo "#" >> system-statistics |
| 390 | echo "# lsof [SCPreferences lock files]" >> system-statistics |
| 391 | fi |
| 392 | N=`expr ${N} + 1` |
| 393 | |
| 394 | echo "#" >> system-statistics |
| 395 | ${PRIV} /usr/sbin/lsof -- ${lock} >> system-statistics 2>&1 |
| 396 | done |
| 397 | fi |
| 398 | |
| 399 | # |
| 400 | # collect executable and plugin info |
| 401 | # |
| 402 | report_binary_info() |
| 403 | { |
| 404 | if [ ! -f "${1}" ]; then |
| 405 | return |
| 406 | fi |
| 407 | |
| 408 | VERSION=`what "${1}"` |
| 409 | echo "${VERSION}" >> versions 2>&1 |
| 410 | |
| 411 | SUM=`sum "${1}"` |
| 412 | echo "\tsum: ${SUM}" >> versions 2>&1 |
| 413 | |
| 414 | LSINFO=`ls -lu "${1}"` |
| 415 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
| 416 | |
| 417 | echo "" >> versions 2>&1 |
| 418 | } |
| 419 | |
| 420 | get_binary_info() |
| 421 | { |
| 422 | for BIN in \ |
| 423 | /usr/libexec/bootpd \ |
| 424 | /usr/libexec/configd \ |
| 425 | /usr/libexec/discoveryd \ |
| 426 | /usr/sbin/awacsd \ |
| 427 | /usr/sbin/mDNSResponder \ |
| 428 | /usr/sbin/pppd \ |
| 429 | /usr/sbin/racoon \ |
| 430 | /usr/libexec/misd \ |
| 431 | /usr/libexec/InternetSharing \ |
| 432 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ |
| 433 | |
| 434 | do |
| 435 | report_binary_info "${BIN}" |
| 436 | done |
| 437 | |
| 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 \ |
| 442 | | grep iphone \ |
| 443 | | awk '{ print $NF }' \ |
| 444 | | while read SDK |
| 445 | do |
| 446 | SDKPATH="`xcrun --sdk $SDK --show-sdk-path`" |
| 447 | for BIN in \ |
| 448 | /usr/libexec/configd_sim \ |
| 449 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ |
| 450 | |
| 451 | do |
| 452 | report_binary_info "${SDKPATH}${BIN}" |
| 453 | done |
| 454 | done |
| 455 | else |
| 456 | echo "*** NO SDKs ***" >> versions |
| 457 | echo "" >> versions |
| 458 | fi |
| 459 | fi |
| 460 | } |
| 461 | |
| 462 | get_plugins_info() |
| 463 | { |
| 464 | num=0 |
| 465 | cd /System/Library/SystemConfiguration |
| 466 | for PLUGIN in *.bundle |
| 467 | do |
| 468 | plugins[$num]="${PLUGIN}" |
| 469 | num=$(( $num + 1 )) |
| 470 | done |
| 471 | |
| 472 | cd "${WORKDIR}" |
| 473 | |
| 474 | for PLUGIN in "${plugins[@]}" |
| 475 | do |
| 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 |
| 482 | fi |
| 483 | fi |
| 484 | |
| 485 | echo "${PLUGIN}" >> versions 2>&1 |
| 486 | |
| 487 | ENABLED="Enabled" |
| 488 | BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null` |
| 489 | if [ $? -eq 0 ]; then |
| 490 | if [ ${BOOL} = "TRUE" ]; then |
| 491 | ENABLED="Enabled*" |
| 492 | else |
| 493 | ENABLED="Disabled" |
| 494 | fi |
| 495 | fi |
| 496 | echo "\t${ENABLED}" >> versions 2>&1 |
| 497 | |
| 498 | VERBOSE="" |
| 499 | BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null` |
| 500 | if [ $? -eq 0 ]; then |
| 501 | if [ ${BOOL} = "TRUE" ]; then |
| 502 | VERBOSE="Verbose" |
| 503 | fi |
| 504 | fi |
| 505 | if [ -n "${VERBOSE}" ]; then |
| 506 | echo "\t${VERBOSE}" >> versions 2>&1 |
| 507 | fi |
| 508 | |
| 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` |
| 512 | fi |
| 513 | echo "\tVersion: ${VERSION}" >> versions 2>&1 |
| 514 | |
| 515 | if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then |
| 516 | SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` |
| 517 | echo "\tsum: ${SUM}" >> versions 2>&1 |
| 518 | |
| 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 |
| 524 | |
| 525 | LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"` |
| 526 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
| 527 | fi |
| 528 | |
| 529 | echo "" >> versions 2>&1 |
| 530 | done |
| 531 | } |
| 532 | |
| 533 | if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then |
| 534 | get_binary_info |
| 535 | get_plugins_info |
| 536 | fi |
| 537 | |
| 538 | # |
| 539 | # collect the logarchive |
| 540 | # |
| 541 | if [ -x /usr/bin/log ]; then |
| 542 | LOGARCHIVE_START_TIME=`date -v -1d +"%Y-%m-%d %H:%M:%S"` |
| 543 | LOGARCHIVE_OUTPUT="system_logs.logarchive" |
| 544 | ${PRIV} /usr/bin/log collect --livedata --output "${LOGARCHIVE_OUTPUT}" --start "${LOGARCHIVE_START_TIME}" 2>/dev/null |
| 545 | if [ -d ${LOGARCHIVE_OUTPUT} ]; then |
| 546 | ${PRIV} chown -R ${UID} "${LOGARCHIVE_OUTPUT}" |
| 547 | fi |
| 548 | fi |
| 549 | |
| 550 | # |
| 551 | # dmesg |
| 552 | # |
| 553 | if [ -x /sbin/dmesg ]; then |
| 554 | ${PRIV} /sbin/dmesg > dmesg |
| 555 | fi |
| 556 | |
| 557 | # |
| 558 | # ppp log file(s) |
| 559 | # |
| 560 | scutil <<_END_OF_INPUT \ |
| 561 | | awk -F' *: *' \ |
| 562 | ' \ |
| 563 | /Logfile : / { \ |
| 564 | if (index($2, "/") == 1) { print $2 } \ |
| 565 | else { print "/var/log/ppp/" $2 } \ |
| 566 | } \ |
| 567 | END { \ |
| 568 | print "/tmp/pppotcp.log" \ |
| 569 | } \ |
| 570 | ' \ |
| 571 | | sort -u \ |
| 572 | | while read logFile |
| 573 | open |
| 574 | show Setup:/Network/Service/[^/]+/PPP pattern |
| 575 | quit |
| 576 | _END_OF_INPUT |
| 577 | do |
| 578 | if [ -f "${logFile}" ]; then |
| 579 | b="`basename ${logFile}`" |
| 580 | cat "${logFile}" > "${b}" 2>&1 |
| 581 | fi |
| 582 | done |
| 583 | |
| 584 | if [ -x /bin/ls ]; then |
| 585 | # |
| 586 | # collect crash reports |
| 587 | # |
| 588 | for daemon in \ |
| 589 | InternetSharing \ |
| 590 | SCHelper \ |
| 591 | SCMonitor \ |
| 592 | awacsd \ |
| 593 | bootpd \ |
| 594 | configd \ |
| 595 | discoveryd \ |
| 596 | discoveryd_helper \ |
| 597 | eapolclient \ |
| 598 | mDNSResponder \ |
| 599 | mDNSResponderHelper \ |
| 600 | pppd \ |
| 601 | racoon \ |
| 602 | socketfilterfw \ |
| 603 | |
| 604 | do |
| 605 | /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \ |
| 606 | /Library/Logs/DiagnosticReports/${daemon}_*.ips \ |
| 607 | /Library/Logs/CrashReporter/${daemon}_*.crash \ |
| 608 | /Library/Logs/CrashReporter/${daemon}_*.ips \ |
| 609 | /Library/Logs/CrashReporter/${daemon}_*.plist \ |
| 610 | 2>/dev/null \ |
| 611 | | while read log |
| 612 | do |
| 613 | if [ -f "${log}" ]; then |
| 614 | b="`basename ${log}`" |
| 615 | ${PRIV} cat "${log}" > "${b}" 2>&1 |
| 616 | fi |
| 617 | done |
| 618 | done |
| 619 | fi |
| 620 | |
| 621 | # |
| 622 | # stackshot |
| 623 | # |
| 624 | if [ -x /usr/local/bin/crstackshot ]; then |
| 625 | /usr/local/bin/crstackshot 2>/dev/null |
| 626 | fi |
| 627 | |
| 628 | # |
| 629 | # wait for background activity (eg: lsof) |
| 630 | # |
| 631 | wait |
| 632 | |
| 633 | # |
| 634 | # collect everything into a single archive |
| 635 | # |
| 636 | cd "${WORKDIR}/.." |
| 637 | tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}" |
| 638 | rm -rf "${WORKDIR}" |
| 639 | |
| 640 | if [ ${UID} -eq 0 ]; then |
| 641 | if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then |
| 642 | if [ ${UID} -ne ${SUDO_UID} ]; then |
| 643 | chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}" |
| 644 | fi |
| 645 | fi |
| 646 | fi |
| 647 | |
| 648 | echo "Network data collected to \"${ARCHIVE}\"" |
| 649 | |