this repo has no description
at fixPythonPipStalling 719 lines 16 kB view raw
1#!/bin/sh 2# Copyright (c) 2004-2017 Apple Inc. 3# 4# get-mobility-info 5# 6# Collect system & network configuration information. 7# 8 9PATH=/bin:/usr/bin:/sbin:/usr/sbin 10 11OUTDIR="" 12NO_PCAP=0 13NO_TAR=0 14 15while getopts f:PT OPTION ; do 16 case ${OPTION} in 17 f) 18 OUTDIR="${OPTARG}" 19 if [ ! -d "${OUTDIR}" ]; then 20 echo "# ${PROGNAME}: \"${OUTDIR}\" is not a directory" 21 exit 1 22 fi 23 ;; 24 P) 25 NO_PCAP=1 26 ;; 27 T) 28 NO_TAR=1 29 ;; 30 \?) 31 ;; 32 esac 33done 34 35# 36# Disclaimer 37# 38cat <<_END_OF_DISCLAIMER 39 40This diagnostic tool generates files that allow Apple to investigate issues 41with your computer and help Apple to improve its products. The generated files 42may contain some of your personal information, which may include, but not be 43limited to, the serial number or similar unique number for your device, your 44user name, or your computer name. The information is used by Apple in 45accordance with its privacy policy (www.apple.com/privacy) and is not shared 46with any third party. By enabling this diagnostic tool and sending a copy of 47the generated files to Apple, you are consenting to Apple's use of the content 48of such files. 49 50_END_OF_DISCLAIMER 51 52/bin/echo "Press 'Enter' to continue." 53read reply 54 55# 56# Setup 57# 58PRIV="" 59if [ ${EUID} -ne 0 ]; then 60 PRIV="sudo" 61fi 62 63if [ -x /usr/bin/tail ]; then 64 TAIL_2000="/usr/bin/tail -n 2000" 65 TAIL_25000="/usr/bin/tail -n 25000" 66else 67 TAIL_2000="/bin/cat" 68 TAIL_25000="/bin/cat" 69fi 70 71OUT="mobility-info-`date +'%Y.%m.%d.%H%M%S'`" 72 73if [ -z $OUTDIR ]; then 74 OUTDIR="/var/tmp" 75 if [ -d ~/Desktop ]; then 76 OUTDIR=~/Desktop 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 81 fi 82 mkdir -p ${OUTDIR} 83 fi 84fi 85 86umask 077 87 88WORKDIR=`mktemp -d -q "/tmp/${OUT}"` 89if [ $? -ne 0 ]; then 90 echo "Could not create snapshot directory" 91 exit 1 92fi 93 94if [ $NO_TAR -eq 0 ]; then 95 GZ_EXT="" 96 GZ_OPT="" 97 if [ -x /usr/bin/gzip ]; then 98 GZ_EXT=".gz" 99 GZ_OPT="-z" 100 fi 101 102 ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"` 103 if [ $? -ne 0 ]; then 104 echo "Could not create snapshot archive" 105 rm -rf "${WORKDIR}" 106 exit 1 107 fi 108fi 109 110cd "${WORKDIR}" 111 112echo "" 113echo "Please wait, collecting information and statistics" 114echo "" 115 116# 117# collect packet capture with kernel ring buffer if available 118# 119stop_pcap () { 120 # 121 # Stop the packet capture 122 # 123 if [ ${PCAP_STARTED} -ne 0 ]; then 124 trap '' SIGINT 125 /usr/local/bin/netdiagnose stop packetcapture 2>&1 126 PCAP_STARTED=0 127 fi 128} 129 130PCAP_STARTED=0 131if [ -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 134 PCAP_STARTED=1 135fi 136 137# 138# get-network-info 139# 140if [ -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}" 142elif [ -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}" 144elif [ -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}" 146fi 147 148# 149# processes 150# 151if [ -x /bin/ps ]; then 152 /bin/ps axlww > ps 2>&1 153fi 154 155# 156# AirPort info 157# 158if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then 159 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \ 160 > airport 2>&1 161fi 162 163# 164# collect wifi dump 165# 166if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then 167 ${PRIV} /usr/bin/wdutil dump 168 mkdir -p "wifi_dump" 169 /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \ 170 | while read log 171 do 172 if [ -f "${log}" ]; then 173 b="`basename ${log}`" 174 ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1 175 fi 176 done 177fi 178 179# 180# OS info 181# 182if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then 183 cat /System/Library/CoreServices/SystemVersion.plist \ 184 > SystemVersion.plist 2>&1 185fi 186 187# 188# IOKit info 189# 190if [ -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 193fi 194 195# 196# Power Management info 197# 198if [ -x /usr/bin/pmset ]; then 199 echo "#" > pmset 200 echo "# pmset -g everything" >> pmset 201 echo "#" >> pmset 202 /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset 203fi 204 205# 206# Host configuration 207# 208if [ -x /usr/bin/hostinfo ]; then 209 /usr/bin/hostinfo > hostinfo 2>&1 210fi 211if [ -e /etc/hostconfig ]; then 212 cat /etc/hostconfig > etc.hostconfig 2>&1 213fi 214 215# 216# System / network preferences 217# 218for f in \ 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 \ 225 226do 227 if [ -e "${f}" ]; then 228 b="`basename ${f}`" 229 cat "${f}" > "${b}" 2>&1 230 fi 231done 232 233# 234# Install log 235# 236if [ -e /var/log/install.log ]; then 237 cat /var/log/install.log > install.log 2>&1 238fi 239 240# 241# System / network preferences (from other volumes) 242# 243mount -t hfs | grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \ 244| while read volume 245do 246 V_PATH="/Volumes/${volume}" 247 if [ -h "${V_PATH}" ]; then 248 # if the path is a symlink 249 continue 250 fi 251 252 for f in \ 253 /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \ 254 /Library/Preferences/SystemConfiguration/preferences.plist \ 255 256 do 257 if [ -f "${V_PATH}/${f}" ]; then 258 mkdir -p "OtherPreferences/${volume}" 259 b="`basename ${f}`" 260 cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1 261 fi 262 done 263done 264 265# 266# InternetSharing 267# 268if [ -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 271elif [ -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 274fi 275 276# 277# mounted filesystems 278# 279mount > mounted-filesystems 2>&1 280 281${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null 282 283# 284# kernel extensions statistic 285# 286if [ -x /usr/sbin/kextstat ]; then 287 /usr/sbin/kextstat > kextstat 2>&1 288fi 289 290if [ -x /sbin/pfctl ]; then 291 echo "#" > pf 292 echo "# pfctl -s all" >> pf 293 echo "#" >> pf 294 ${PRIV} /sbin/pfctl -s all >> pf 2>&1 295 echo "==============================" >> pf 296 echo "#" >> pf 297 echo "# pfctl -s References" >> pf 298 echo "#" >> pf 299 ${PRIV} /sbin/pfctl -s References >> pf 2>&1 300 for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null` 301 do 302 echo "==============================" >> pf 303 echo "#" >> pf 304 echo "# pfctl -a ${ANCHOR} -s all" >> pf 305 echo "#" >> pf 306 ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1 307 done 308fi 309 310# 311# mach port info 312# 313if [ -x /usr/local/bin/lsmp ]; then 314 ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1 315fi 316 317# 318# open files 319# 320if [ -x /usr/sbin/lsof ]; then 321 ${PRIV} /usr/sbin/lsof +c 0 -n -O -P -T q > lsof 2>&1 & 322 LSOF_PID=$! 323 # Init a watchdog for lsof 324 ( 325 WAIT_TIME=5 326 while [ $WAIT_TIME -gt 0 ] 327 do 328 ${PRIV} kill -0 ${LSOF_PID} 2>/dev/null 329 if [ $? -eq 0 ]; then 330 sleep 1 331 # lsof is gathering data.. 332 WAIT_TIME=$((WAIT_TIME-1)) 333 continue 334 fi 335 336 # lsof completed gathering data 337 break 338 done 339 340 if [ $WAIT_TIME -eq 0 ]; then 341 # lsof timed out 342 ${PRIV} kill ${LSOF_PID} 2>/dev/null 343 fi 344 ) & 345fi 346 347# 348# [lib]dispatch info 349# 350if [ -x /usr/local/bin/ddt ]; then 351 /bin/echo -n "" > dispatch-info 352 for BIN in \ 353 configd \ 354 discoveryd \ 355 356 do 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 361 done 362fi 363 364# 365# OpenDirectory info 366# 367if [ -x /usr/bin/odutil ]; then 368 echo "#" > od-info 369 echo "# odutil show all" >> od-info 370 echo "#" >> od-info 371 ${PRIV} /usr/bin/odutil show all >> od-info 2>&1 372fi 373 374# 375# Kerberos configuration 376# 377if [ -x /usr/bin/klist ]; then 378 echo "#" > kerberos 379 echo "# klist --verbose --all-content" >> kerberos 380 echo "#" >> kerberos 381 klist --verbose --all-content >> kerberos 2>&1 382 383 echo "#" >> kerberos 384 echo "# ktutil list" >> kerberos 385 echo "#" >> kerberos 386 ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1 387 388 echo "#" >> kerberos 389 echo "# gsstool list --verbose" >> kerberos 390 echo "#" >> kerberos 391 /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1 392fi 393 394# 395# system profiler 396# 397if [ -x /usr/sbin/system_profiler ]; then 398 system_profiler -xml SPEthernetDataType \ 399 SPFibreChannelDataType \ 400 SPFireWireDataType \ 401 SPFirewallDataType \ 402 SPModemDataType \ 403 SPNetworkDataType \ 404 SPThunderboltDataType \ 405 SPWWANDataType \ 406 SPAirPortDataType > system_profiler.spx 2>/dev/null 407fi 408 409# 410# system usage statistics 411# 412/bin/echo -n "" > system-statistics 413 414if [ -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 419fi 420 421if [ -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 426fi 427 428if [ -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 433fi 434 435if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then 436 N=0 437 /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \ 438 2>/dev/null \ 439 | while read lock 440 do 441 if [ ${N} -eq 0 ]; then 442 echo "#" >> system-statistics 443 echo "# lsof [SCPreferences lock files]" >> system-statistics 444 fi 445 N=`expr ${N} + 1` 446 447 echo "#" >> system-statistics 448 ${PRIV} /usr/sbin/lsof +c 0 -- ${lock} >> system-statistics 2>&1 449 done 450fi 451 452# 453# collect executable and plugin info 454# 455report_binary_info() 456{ 457 if [ ! -f "${1}" ]; then 458 return 459 fi 460 461 VERSION=`what "${1}"` 462 echo "${VERSION}" >> versions 2>&1 463 464 SUM=`sum "${1}"` 465 echo "\tsum: ${SUM}" >> versions 2>&1 466 467 LSINFO=`ls -lu "${1}"` 468 echo "\tadditional info: ${LSINFO}" >> versions 2>&1 469 470 echo "" >> versions 2>&1 471} 472 473get_binary_info() 474{ 475 for BIN in \ 476 /usr/libexec/bootpd \ 477 /usr/libexec/configd \ 478 /usr/libexec/discoveryd \ 479 /usr/sbin/awacsd \ 480 /usr/sbin/mDNSResponder \ 481 /usr/sbin/pppd \ 482 /usr/sbin/racoon \ 483 /usr/libexec/misd \ 484 /usr/libexec/InternetSharing \ 485 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ 486 487 do 488 report_binary_info "${BIN}" 489 done 490 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 \ 495 | grep iphone \ 496 | awk '{ print $NF }' \ 497 | while read SDK 498 do 499 SDKPATH="`xcrun --sdk $SDK --show-sdk-path`" 500 for BIN in \ 501 /usr/libexec/configd_sim \ 502 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ 503 504 do 505 report_binary_info "${SDKPATH}${BIN}" 506 done 507 done 508 else 509 echo "*** NO SDKs ***" >> versions 510 echo "" >> versions 511 fi 512 fi 513} 514 515get_plugins_info() 516{ 517 num=0 518 cd /System/Library/SystemConfiguration 519 for PLUGIN in *.bundle 520 do 521 plugins[$num]="${PLUGIN}" 522 num=$(( $num + 1 )) 523 done 524 525 cd "${WORKDIR}" 526 527 for PLUGIN in "${plugins[@]}" 528 do 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 535 fi 536 fi 537 538 echo "${PLUGIN}" >> versions 2>&1 539 540 ENABLED="Enabled" 541 BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null` 542 if [ $? -eq 0 ]; then 543 if [ ${BOOL} = "TRUE" ]; then 544 ENABLED="Enabled*" 545 else 546 ENABLED="Disabled" 547 fi 548 fi 549 echo "\t${ENABLED}" >> versions 2>&1 550 551 VERBOSE="" 552 BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null` 553 if [ $? -eq 0 ]; then 554 if [ ${BOOL} = "TRUE" ]; then 555 VERBOSE="Verbose" 556 fi 557 fi 558 if [ -n "${VERBOSE}" ]; then 559 echo "\t${VERBOSE}" >> versions 2>&1 560 fi 561 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` 565 fi 566 echo "\tVersion: ${VERSION}" >> versions 2>&1 567 568 if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then 569 SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` 570 echo "\tsum: ${SUM}" >> versions 2>&1 571 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 577 578 LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"` 579 echo "\tadditional info: ${LSINFO}" >> versions 2>&1 580 fi 581 582 echo "" >> versions 2>&1 583 done 584} 585 586if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then 587 get_binary_info 588 get_plugins_info 589fi 590 591# 592# collect the logarchive 593# 594if [ -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}" 600 fi 601fi 602 603# 604# dmesg 605# 606if [ -x /sbin/dmesg ]; then 607 ${PRIV} /sbin/dmesg > dmesg 608fi 609 610# 611# ppp log file(s) 612# 613scutil <<_END_OF_INPUT \ 614| awk -F' *: *' \ 615 ' \ 616 /Logfile : / { \ 617 if (index($2, "/") == 1) { print $2 } \ 618 else { print "/var/log/ppp/" $2 } \ 619 } \ 620 END { \ 621 print "/tmp/pppotcp.log" \ 622 } \ 623 ' \ 624| sort -u \ 625| while read logFile 626open 627show Setup:/Network/Service/[^/]+/PPP pattern 628quit 629_END_OF_INPUT 630do 631 if [ -f "${logFile}" ]; then 632 b="`basename ${logFile}`" 633 cat "${logFile}" > "${b}" 2>&1 634 fi 635done 636 637if [ -x /bin/ls ]; then 638 # 639 # collect crash reports 640 # 641 for daemon in \ 642 InternetSharing \ 643 SCHelper \ 644 SCMonitor \ 645 awacsd \ 646 bootpd \ 647 configd \ 648 discoveryd \ 649 discoveryd_helper \ 650 eapolclient \ 651 mDNSResponder \ 652 mDNSResponderHelper \ 653 pppd \ 654 racoon \ 655 socketfilterfw \ 656 657 do 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 \ 663 2>/dev/null \ 664 | while read log 665 do 666 if [ -f "${log}" ]; then 667 b="`basename ${log}`" 668 ${PRIV} cat "${log}" > "${b}" 2>&1 669 fi 670 done 671 done 672fi 673 674# 675# stackshot 676# 677if [ -x /usr/local/bin/crstackshot ]; then 678 /usr/local/bin/crstackshot 2>/dev/null 679fi 680 681# 682# wait for background activity (eg: lsof) 683# 684wait 685 686# 687# Stop the packet capture 688# 689stop_pcap 690 691if [ $NO_TAR -eq 0 ]; then 692 # 693 # collect everything into a single archive 694 # 695 cd "${WORKDIR}/.." 696 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}" 697 rm -rf "${WORKDIR}" 698 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}" 703 fi 704 fi 705 fi 706 707 echo "Network data collected to \"${ARCHIVE}\"" 708else 709 mv "${WORKDIR}" "${OUTDIR}" 710 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}" 715 fi 716 fi 717 fi 718 echo "Network data collected to \"${OUTDIR}/${OUT}\"" 719fi