]> git.saurik.com Git - apple/configd.git/blobdiff - get-network-info
configd-1109.40.9.tar.gz
[apple/configd.git] / get-network-info
index 81a822992bdf6e400b1a7cb12383d75ae3fe7063..156b0c2dfc1a39f2dd25883e29d4a6035be1aa9a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-#  Copyright © 2015, 2016 Apple Inc.
+#  Copyright © 2015-2020 Apple Inc.
 #
 #  get-network-info
 #
@@ -25,6 +25,10 @@ process_opts () {
                           COLLECT_NDF_INFO="Y"
                           shift
                           ;;
+                   -P)
+                          COLLECT_PCAP="N"
+                          shift
+                          ;;
                    -s)
                           COLLECT_SENSITIVE_INFO="Y"
                           shift
@@ -66,13 +70,14 @@ setup () {
 
 # __COMMAND_ROUTINES_BEGIN__
 
-# note: the daemons dump to syslog so you need to wait a bit before
-# capturing the logs.
+#
+# mDNSResponder state dump
+# /usr/bin/dns-sd -O -stdout will print the state of mDNSResponder to STDOUT
+#
 collect_state_dump_sensitive () {
 
-       ${PRIV} /usr/bin/killall -INFO mDNSResponder                                            2>/dev/null
-
-       sleep 1                                                                                 &
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: collect_state_dump_sensitive"        >> get-network-info.txt
+       ${PRIV} /usr/bin/dns-sd -O -stdout                              > mDNSResponder_state_dump.txt          2>&1
 
 }
 
@@ -85,6 +90,7 @@ run_ifconfig () {
                return
        fi
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_ifconfig"                >> get-network-info.txt
        /sbin/ifconfig -a -L -b -m -r -v -v                             > ifconfig.txt          2>&1
        if [ $? -ne 0 ]; then
                /sbin/ifconfig -a                                       > ifconfig.txt          2>&1
@@ -101,15 +107,16 @@ run_netstat () {
                return
        fi
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_netstat"                 >> get-network-info.txt
        echo "#"                                                         > netstat.txt
        echo "# netstat -n -r -a -l"                                    >> netstat.txt
        echo "#"                                                        >> netstat.txt
        /usr/sbin/netstat -n -r -a -l                                   >> netstat.txt          2>&1
 
        echo "#"                                                        >> netstat.txt
-       echo "# netstat -A -a -l -n -v"                                 >> netstat.txt
+       echo "# netstat -A -a -l -n -v -W"                              >> netstat.txt
        echo "#"                                                        >> netstat.txt
-       /usr/sbin/netstat -A -a -l -n -v                                >> netstat.txt          2>&1
+       /usr/sbin/netstat -A -a -l -n -v -W                             >> netstat.txt          2>&1
 
        echo "#"                                                        >> netstat.txt
        echo "# netstat -s"                                             >> netstat.txt
@@ -154,6 +161,11 @@ run_netstat () {
        if [ -x /sbin/ifconfig ]; then
                for if in ${IF_LIST}
                do
+                       echo "#"                                        >> netstat.txt
+                       echo "# netstat -n -s -I ${if}"                 >> netstat.txt
+                       echo "#"                                        >> netstat.txt
+                       /usr/sbin/netstat -n -s -I ${if}                >> netstat.txt          2>&1
+
                        IF_INFO=`/sbin/ifconfig -v ${if}`
                        `echo $IF_INFO | grep -q TXSTART`
                        if [ $? -eq 0 ]; then
@@ -162,6 +174,7 @@ run_netstat () {
                                echo "#"                                >> netstat.txt
                                /usr/sbin/netstat -qq -I ${if}          >> netstat.txt          2>&1
                        fi
+
                        `echo $IF_INFO | grep -q RXPOLL`
                        if [ $? -eq 0 ]; then
                                echo "#"                                >> netstat.txt
@@ -183,6 +196,7 @@ run_ndp () {
                return
        fi
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_ndp"                     >> get-network-info.txt
        echo "#"                                                         > ndp-info.txt
        echo "# ndp -n -a"                                              >> ndp-info.txt
        echo "#"                                                        >> ndp-info.txt
@@ -219,6 +233,7 @@ run_arp () {
                return
        fi
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_arp"                     >> get-network-info.txt
        echo "#"                                                         > arp-info.txt
        echo "# arp -n -a"                                              >> arp-info.txt
        echo "#"                                                        >> arp-info.txt
@@ -235,6 +250,7 @@ run_ipconfig () {
                return
        fi
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_ipconfig"                >> get-network-info.txt
        for if in ${IF_LIST}
        do
                case ${if} in
@@ -265,6 +281,17 @@ run_ipconfig () {
                                echo "not available"                    >> ipconfig-info.txt
                        fi
 
+                       echo""                                          >> ipconfig-info.txt
+
+                       echo "IPv6 information:"                        >> ipconfig-info.txt
+
+                       IPCONFIG_INFO=`/usr/sbin/ipconfig getra ${if}`
+                       if [ "${IPCONFIG_INFO}" != "" ]; then
+                               echo "${IPCONFIG_INFO}"                 >> ipconfig-info.txt
+                       else
+                               echo "not available"                    >> ipconfig-info.txt
+                       fi
+
                        echo""                                          >> ipconfig-info.txt
                        ;;
                esac
@@ -281,9 +308,10 @@ run_setkey () {
                return
        fi
 
-       echo "#"                                                                        >  ipsec.txt
-       echo "# setkey -D"                                                              >> ipsec.txt
-       echo "#"                                                                        >> ipsec.txt
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_setkey"                  >> get-network-info.txt
+       echo "#"                                                        >  ipsec.txt
+       echo "# setkey -D"                                              >> ipsec.txt
+       echo "#"                                                        >> ipsec.txt
        ${PRIV} /usr/sbin/setkey -D                             \
        | /usr/bin/perl -l -n -e '
                if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) {
@@ -291,13 +319,13 @@ run_setkey () {
                } else {
                        printf "%s\n", $_;
                }
-       '                                                                               >> ipsec.txt
+       '                                                               >> ipsec.txt
 
-       echo ""                                                                         >> ipsec.txt
-       echo "#"                                                                        >> ipsec.txt
-       echo "# setkey -Pp -D"                                                          >> ipsec.txt
-       echo "#"                                                                        >> ipsec.txt
-       ${PRIV} /usr/sbin/setkey -Pp -D                                                 >> ipsec.txt
+       echo ""                                                         >> ipsec.txt
+       echo "#"                                                        >> ipsec.txt
+       echo "# setkey -Pp -D"                                          >> ipsec.txt
+       echo "#"                                                        >> ipsec.txt
+       ${PRIV} /usr/sbin/setkey -Pp -D                                 >> ipsec.txt
 
        for CF in /var/run/racoon/*.conf
        do
@@ -305,10 +333,10 @@ run_setkey () {
                        continue
                fi
 
-               echo ""                                                                 >> ipsec.txt
-               echo "#"                                                                >> ipsec.txt
-               echo "# ${CF}"                                                          >> ipsec.txt
-               echo "#"                                                                >> ipsec.txt
+               echo ""                                                 >> ipsec.txt
+               echo "#"                                                >> ipsec.txt
+               echo "# ${CF}"                                          >> ipsec.txt
+               echo "#"                                                >> ipsec.txt
                ${PRIV} cat ${CF}                               \
                | /usr/bin/perl -l -n -e '
                        if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) {
@@ -316,20 +344,117 @@ run_setkey () {
                        } else {
                                printf "%s\n", $_;
                        }
-               '                                                                       >> ipsec.txt
+               '                                                       >> ipsec.txt
        done
 
 }
 
+#
+# skywalk configuration and statistics
+#
+run_skywalk () {
+
+       if [ ! -x /usr/sbin/skywalkctl ]; then
+               return
+       fi
+
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_skywalk"                 >> get-network-info.txt
+       echo "#"                                                         > skywalk.txt
+       echo "# skywalkctl show"                                        >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl show                                       >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl flow -n"                                     >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl flow -n                                    >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl flow-route -n"                               >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl flow-route -n                              >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl flow-switch"                                 >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl flow-switch                                >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl flow-owner"                                  >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl flow-owner                                 >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl flow-adv"                                    >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl flow-adv                                   >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl netstat -s"                                  >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl netstat -s                                 >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl netstat -s --global"                         >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl netstat -s --global                        >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl interface"                                   >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl interface                                  >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl channel"                                     >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl channel                                    >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl provider -D"                                 >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl provider -D                                >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl netns -a"                                    >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl netns -a                                   >> skywalk.txt          2>&1
+
+       echo "#"                                                        >> skywalk.txt
+       echo "# skywalkctl memory"                                      >> skywalk.txt
+       echo "#"                                                        >> skywalk.txt
+       /usr/sbin/skywalkctl memory                                     >> skywalk.txt          2>&1
+
+}
+
+#
+# skywalk configuration and statistics
+#
+run_nettop () {
+
+       if [ ! -x /usr/bin/nettop ]; then
+               return
+       fi
+
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_nettop"                  >> get-network-info.txt
+       echo "#"                                                         > nettop.txt
+       echo "# nettop -n -l 1"                                         >> nettop.txt
+       echo "#"                                                        >> nettop.txt
+       /usr/bin/nettop -n -l 1                                         >> nettop.txt           2>&1
+
+}
+
 #
 # Network preferences
 #
 collect_configuration_files () {
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: collect_configuration_files" >> get-network-info.txt
        for f in                                                                                \
                /Library/Preferences/com.apple.networkextension.plist                           \
                /Library/Preferences/com.apple.networkextension.control.plist                   \
                /Library/Preferences/com.apple.networkextension.necp.plist                      \
+               /Library/Preferences/com.apple.networkextension.cache.plist                     \
+               /Library/Preferences/com.apple.networkextension.uuidcache.plist                 \
                /Library/Preferences/SystemConfiguration/com.apple.nat.plist                    \
                /Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist    \
                /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist             \
@@ -340,18 +465,30 @@ collect_configuration_files () {
        do
                if [ -e "${f}" ]; then
                        b="`basename ${f}`"
-                       cat "${f}"                                                      > "${b}"                        2>&1
+                       cat "${f}"                                      > "${b}"                        2>&1
                fi
        done
 
        if [ -e /etc/resolv.conf ]; then
-               cat /etc/resolv.conf                                                    > etc-resolv-conf.txt           2>&1
+               cat /etc/resolv.conf                                    > etc-resolv-conf.txt           2>&1
        fi
        if [ -e /var/run/resolv.conf ]; then
-               cat /var/run/resolv.conf                                                > var-run-resolv-conf.txt       2>&1
+               cat /var/run/resolv.conf                                > var-run-resolv-conf.txt       2>&1
        fi
        if [ -e /etc/resolver ]; then
-               tar -c -H /etc/resolver                                                 > etc-resolver.tar              2>/dev/null
+               tar -c -H /etc/resolver                                 > etc-resolver.tar              2>/dev/null
+       elif [ -e /Library/Preferences/SystemConfiguration/resolver ]; then
+               tar -c -H /Library/Preferences/SystemConfiguration/resolver > LPS-resolver.tar          2>/dev/null
+       fi
+
+       MIGRATION_FILES=$(/bin/ls -1                                                            \
+               /Library/Preferences/SystemConfiguration/preferences-pre-*.plist                \
+               /Library/Preferences/SystemConfiguration/NetworkInterfaces-pre-*.plist          \
+               2>/dev/null)
+       if [ -n "${MIGRATION_FILES}" ]; then
+               MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/preferences.plist"
+               MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist"
+               tar -c -H ${MIGRATION_FILES}                            > migration.tar                 2>/dev/null
        fi
 }
 
@@ -360,6 +497,7 @@ collect_configuration_files () {
 #
 collect_vpn_logs () {
 
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: collect_vpn_logs"            >> get-network-info.txt
        for f in                                                                                \
                /var/log/vpnd.log                                                               \
                /var/log/racoon.log                                                             \
@@ -367,7 +505,7 @@ collect_vpn_logs () {
        do
                if [ -e "${f}" ]; then
                        b="`basename ${f}`"
-                       ${PRIV} cat "${f}"                                                      > "${b}".txt    2>&1
+                       ${PRIV} cat "${f}"                              > "${b}".txt    2>&1
                fi
        done
 }
@@ -381,16 +519,22 @@ run_neutil () {
                return
        fi
 
-       echo "#"                                                                >  necp.txt
-       echo "# neutil policy dump"                                             >> necp.txt
-       echo "#"                                                                >> necp.txt
-       /usr/local/bin/neutil policy dump                                       >> necp.txt             2>&1
-
-       echo "#"                                                                >  network-agents.txt
-       echo "# neutil agent dump"                                              >> network-agents.txt
-       echo "#"                                                                >> network-agents.txt
-       /usr/local/bin/neutil agent dump                                        >> network-agents.txt   2>&1
-
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_neutil"                  >> get-network-info.txt
+       (
+               echo "#"                                                >  necp.txt
+               echo "# neutil policy dump"                             >> necp.txt
+               echo "#"                                                >> necp.txt
+               /usr/local/bin/neutil policy dump                       >> necp.txt             2>&1
+
+               echo "#"                                                >  network-agents.txt
+               echo "# neutil agent dump"                              >> network-agents.txt
+               echo "#"                                                >> network-agents.txt
+               /usr/local/bin/neutil agent dump                        >> network-agents.txt   2>&1
+
+               # Generates a default-level log message containing the current file handles that UserEventAgent has
+               /usr/local/bin/neutil session log-file-handles
+               sleep 1 &
+       ) &
 }
 
 #
@@ -402,7 +546,8 @@ run_network_test () {
                return
        fi
 
-       /usr/local/bin/network_test path_watcher                                > nw_path.txt   2>&1
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_network_test"            >> get-network-info.txt
+       /usr/local/bin/network_test path_watcher -dump                  > nw_path.txt   2>&1
 
 }
 
@@ -415,62 +560,51 @@ run_scutil () {
                return
        fi
 
-       echo "#"                                                                >  network-information.txt
-       echo "# scutil -d -v --nwi"                                             >> network-information.txt
-       echo "#"                                                                >> network-information.txt
-       /usr/sbin/scutil -d -v --nwi                                            >> network-information.txt      2>&1
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_scutil"                  >> get-network-info.txt
+       echo "#"                                                        >  network-information.txt
+       echo "# scutil -d -v --nwi"                                     >> network-information.txt
+       echo "#"                                                        >> network-information.txt
+       /usr/sbin/scutil -d -v --nwi                                    >> network-information.txt      2>&1
        for if in ${IF_LIST}
        do
-               echo ""                                                         >> network-information.txt
-               echo "#"                                                        >> network-information.txt
-               echo "# scutil --nwi ${if}"                                     >> network-information.txt
-               echo "#"                                                        >> network-information.txt
-               scutil --nwi ${if}                                              >> network-information.txt      2>&1
+               echo ""                                                 >> network-information.txt
+               echo "#"                                                >> network-information.txt
+               echo "# scutil --nwi ${if}"                             >> network-information.txt
+               echo "#"                                                >> network-information.txt
+               scutil --nwi ${if}                                      >> network-information.txt      2>&1
        done
 
-       echo "#"                                                                >  dns-configuration.txt
-       echo "# scutil -d -v --dns"                                             >> dns-configuration.txt
-       echo "#"                                                                >> dns-configuration.txt
-       /usr/sbin/scutil -d -v --dns                                            >> dns-configuration.txt        2>&1
+       echo "#"                                                        >  dns-configuration.txt
+       echo "# scutil -d -v --dns"                                     >> dns-configuration.txt
+       echo "#"                                                        >> dns-configuration.txt
+       /usr/sbin/scutil -d -v --dns                                    >> dns-configuration.txt        2>&1
 
-       echo "#"                                                                >  proxy-configuration.txt
-       echo "# scutil -d -v --proxy"                                           >> proxy-configuration.txt
-       echo "#"                                                                >> proxy-configuration.txt
-       /usr/sbin/scutil -d -v --proxy                                          >> proxy-configuration.txt      2>&1
+       echo "#"                                                        >  proxy-configuration.txt
+       echo "# scutil -d -v --proxy"                                   >> proxy-configuration.txt
+       echo "#"                                                        >> proxy-configuration.txt
+       /usr/sbin/scutil -d -v --proxy                                  >> proxy-configuration.txt      2>&1
 
-       echo "#"                                                                >  reachability-info.txt
-       echo '# scutil -d -v -r www.apple.com'                                  >> reachability-info.txt
-       echo "#"                                                                >> reachability-info.txt
-       /usr/sbin/scutil -d -v -r www.apple.com                                 >> reachability-info.txt        2>&1
+       echo "#"                                                        >  reachability-info.txt
+       echo '# scutil -d -v -r www.apple.com'                          >> reachability-info.txt
+       echo "#"                                                        >> reachability-info.txt
+       /usr/sbin/scutil -d -v -r www.apple.com                         >> reachability-info.txt        2>&1
 
-       echo "#"                                                                >> reachability-info.txt
-       echo '# scutil -d -v -r 0.0.0.0'                                        >> reachability-info.txt
-       echo "#"                                                                >> reachability-info.txt
-       /usr/sbin/scutil -d -v -r 0.0.0.0                                       >> reachability-info.txt        2>&1
+       echo "#"                                                        >> reachability-info.txt
+       echo '# scutil -d -v -r 0.0.0.0'                                >> reachability-info.txt
+       echo "#"                                                        >> reachability-info.txt
+       /usr/sbin/scutil -d -v -r 0.0.0.0                               >> reachability-info.txt        2>&1
 
-       echo "#"                                                                >> reachability-info.txt
-       echo '# scutil -d -v -r 169.254.0.0'                                    >> reachability-info.txt
-       echo "#"                                                                >> reachability-info.txt
-       /usr/sbin/scutil -d -v -r 169.254.0.0                                   >> reachability-info.txt        2>&1
+       echo "#"                                                        >> reachability-info.txt
+       echo '# scutil -d -v -r 169.254.0.0'                            >> reachability-info.txt
+       echo "#"                                                        >> reachability-info.txt
+       /usr/sbin/scutil -d -v -r 169.254.0.0                           >> reachability-info.txt        2>&1
 
-       echo "#"                                                                >  nc-info.txt
-       echo '# scutil --nc list'                                               >> nc-info.txt
-       echo "#"                                                                >> nc-info.txt
-       /usr/sbin/scutil --nc list                                              >> nc-info.txt                  2>&1
+       echo "#"                                                        >  nc-info.txt
+       echo '# scutil --nc list'                                       >> nc-info.txt
+       echo "#"                                                        >> nc-info.txt
+       /usr/sbin/scutil --nc list                                      >> nc-info.txt                  2>&1
 
-       ${PRIV} /usr/sbin/scutil -p --snapshot
-       if [ -f /var/tmp/configd-store.plist ]; then
-               cat /var/tmp/configd-store.plist                                > configd-store.plist           2>&1
-       fi
-       if [ -f /var/tmp/configd-pattern.plist ]; then
-               cat /var/tmp/configd-pattern.plist                              > configd-pattern.plist         2>&1
-       fi
-       if [ -f /var/tmp/configd-session.plist ]; then
-               cat /var/tmp/configd-session.plist                              > configd-session.plist         2>&1
-       fi
-       if [ -f /var/tmp/configd-state ]; then
-               cat /var/tmp/configd-state                                      > configd-state                 2>&1
-       fi
+       /usr/sbin/scutil -p --snapshot                                  SCDynamicStore.plist            2>&1
 
 }
 
@@ -483,15 +617,16 @@ run_route () {
                return
        fi
 
-       echo "#"                                                                >  route-info.txt
-       echo '# route -n -v get www.apple.com'                                  >> route-info.txt
-       echo "#"                                                                >> route-info.txt
-       /sbin/route -n -v get www.apple.com                                     >> route-info.txt       2>&1
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_route"                   >> get-network-info.txt
+       echo "#"                                                        >  route-info.txt
+       echo '# route -n -v get www.apple.com'                          >> route-info.txt
+       echo "#"                                                        >> route-info.txt
+       /sbin/route -n -v get www.apple.com                             >> route-info.txt       2>&1
 
-       echo "#"                                                                >> route-info.txt
-       echo '# route -n -v get 0.0.0.0'                                        >> route-info.txt
-       echo "#"                                                                >> route-info.txt
-       /sbin/route -n -v get 0.0.0.0                                           >> route-info.txt       2>&1
+       echo "#"                                                        >> route-info.txt
+       echo '# route -n -v get 0.0.0.0'                                >> route-info.txt
+       echo "#"                                                        >> route-info.txt
+       /sbin/route -n -v get 0.0.0.0                                   >> route-info.txt       2>&1
 
 }
 
@@ -504,10 +639,11 @@ run_dig () {
                return
        fi
 
-       echo "#"                                                                >  dig-info.txt
-       echo '# dig -t any -c any www.apple.com'                                >> dig-info.txt
-       echo "#"                                                                >> dig-info.txt
-       /usr/bin/dig +time=2 -t any -c any www.apple.com                        >> dig-info.txt         2>/dev/null
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_dig"                     >> get-network-info.txt
+       echo "#"                                                        >  dig-info.txt
+       echo '# dig -t any -c any www.apple.com'                        >> dig-info.txt
+       echo "#"                                                        >> dig-info.txt
+       /usr/bin/dig +time=2 -t any -c any www.apple.com                >> dig-info.txt         2>/dev/null
 
 }
 
@@ -520,7 +656,8 @@ run_hostname () {
                return
        fi
 
-       /bin/hostname                                                           > hostname.txt          2>&1
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_hostname"                >> get-network-info.txt
+       /bin/hostname                                                   > hostname.txt          2>&1
 
 }
 
@@ -533,14 +670,15 @@ run_lsof () {
                return
        fi
 
-       ${PRIV} /usr/sbin/lsof -i -n -O -P -T q                                 > lsof.txt              2>&1    &
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_lsof"                    >> get-network-info.txt
+       ${PRIV} /usr/sbin/lsof +c 0 -X -n -O -P -T q            > lsof.txt              2>&1    &
        LSOF_PID=$!
        # start a watchdog for lsof
        (
                WAIT_TIME=5
                while [ $WAIT_TIME -gt 0 ]
                do
-                       ${PRIV} kill -0 ${LSOF_PID}                                                     2>/dev/null
+                       ${PRIV} kill -0 ${LSOF_PID}                                             2>/dev/null
                        if [ $? -eq 0 ]; then
                                # lsof is [still] gathering data...
                                sleep 1
@@ -554,21 +692,62 @@ run_lsof () {
 
                if [ $WAIT_TIME -eq 0 ]; then
                        # lsof timed out
-                       ${PRIV} kill ${LSOF_PID}                                                        2>/dev/null
+                       ${PRIV} kill ${LSOF_PID}                                                2>/dev/null
                fi
        ) &
 
 }
 
+#
+# sysctl
+#
+run_sysctl () {
+
+       if [ ! -x /usr/sbin/sysctl ]; then
+               return
+       fi
+
+       echo "`date +"%Y-%m-%d %H:%M:%S"`: run_sysctl"                  >> get-network-info.txt
+       ${PRIV} /usr/sbin/sysctl -a                                     > sysctl.txt    2>&1    &
+
+}
+
+start_pcap() {
+       #
+       # collect a packet capture if netdiagnose is available
+       #
+       if [ -x /usr/local/bin/netdiagnose ]; then
+               echo "`date +"%Y-%m-%d %H:%M:%S"`: start_pcap"          >> get-network-info.txt
+               trap stop_pcap SIGINT
+               /usr/local/bin/netdiagnose -p "${REQUESTED_OUTDIR}" start sysdiagpcap           2>&1    1>/dev/null
+               PCAP_STARTED=1
+       fi
+}
+
+stop_pcap () {
+       if [ ${PCAP_STARTED} -ne 0 ]; then
+               trap '' SIGINT
+               /usr/local/bin/netdiagnose stop sysdiagpcap                                     2>&1    1>/dev/null
+               echo "`date +"%Y-%m-%d %H:%M:%S"`: stop_pcap"           >> get-network-info.txt
+       fi
+}
+
 collect_ndf_info () {
        run_lsof
+       run_sysctl
 }
 
 collect_sensitive_info () {
+
+       if [ "${COLLECT_PCAP}" == "Y" ]; then
+               start_pcap
+       fi
+
        collect_state_dump_sensitive
        run_ndp
        run_arp
        run_neutil
+       run_nettop
        run_network_test
 }
 
@@ -588,6 +767,7 @@ collect_info () {
        run_netstat
        run_ipconfig
        run_setkey
+       run_skywalk
        collect_vpn_logs
        run_route
        run_hostname
@@ -595,6 +775,8 @@ collect_info () {
        if [ "${COLLECT_CONFIGURATION_FILES}" == "Y" ]; then
                collect_configuration_files
        fi
+
+       stop_pcap
 }
 
 # __COMMAND_ROUTINES_END__
@@ -606,6 +788,7 @@ usage () {
        echo "Usage: get-network-info [-c] [-n] [-s] <info-directory>"
        echo "          -c                  collects system configuration files"
        echo "          -n                  collects NDF information (lsof)"
+       echo "          -P                  do not collect a packet capture"
        echo "          -s                  collects sensitive information (ARP/NDP/mDNS cache)"
        echo "          <info-directory>    path to directory where all the information will be collected"
 
@@ -613,12 +796,16 @@ usage () {
 
 is_outdir_valid () {
 
-       if [ ! -d ${REQUESTED_OUTDIR} ] ||
-          [ "${REQUESTED_OUTDIR}" = "" ]; then
+       if [ "${REQUESTED_OUTDIR}" = "" ]; then
                usage
                exit 1
        fi
 
+       if [ ! -d ${REQUESTED_OUTDIR} ]; then
+               echo "${REQUESTED_OUTDIR} does not exist"
+               exit 1
+       fi
+
        if [ ! -w ${REQUESTED_OUTDIR} ]; then
                echo "${REQUESTED_OUTDIR} is write-protected"
                exit 1
@@ -642,6 +829,9 @@ init_globals () {
        REQUESTED_OUTDIR=""
        COLLECT_SENSITIVE_INFO=""
        COLLECT_CONFIGURATION_FILES=""
+       COLLECT_PCAP="Y"
+       PCAP_STARTED=0
+
 }
 
 # __HELPER_ROUTINES_END__
@@ -649,7 +839,7 @@ init_globals () {
 #
 # __MAIN__
 #
-ARGS=`getopt cns $*`
+ARGS=`getopt cnPs $*`
 if [ $? != 0 ]; then
        usage
        exit 1