diff --git a/net/gce.sh b/net/gce.sh index 84f083c387..ad3f226310 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -714,6 +714,7 @@ $( add-testnet-solana-user-authorized_keys.sh \ install-certbot.sh \ install-earlyoom.sh \ + install-iftop.sh \ install-libssl-compatability.sh \ install-nodejs.sh \ install-redis.sh \ diff --git a/net/net.sh b/net/net.sh index badf9b2f6f..5be1b700a1 100755 --- a/net/net.sh +++ b/net/net.sh @@ -810,7 +810,7 @@ stopNode() { PS4=\"$PS4\" set -x ! tmux list-sessions || tmux kill-session - for pid in solana/{blockexplorer,net-stats,fd-monitor,oom-monitor}.pid; do + for pid in solana/*.pid; do pgid=\$(ps opgid= \$(cat \$pid) | tr -d '[:space:]') if [[ -n \$pgid ]]; then sudo kill -- -\$pgid diff --git a/net/remote/remote-node.sh b/net/remote/remote-node.sh index e21e771f89..7f9860b1ec 100755 --- a/net/remote/remote-node.sh +++ b/net/remote/remote-node.sh @@ -138,6 +138,8 @@ cat >> ~/solana/on-reboot < fd-monitor.pid scripts/net-stats.sh > net-stats.log 2>&1 & echo \$! > net-stats.pid + scripts/iftop.sh > iftop.log 2>&1 & + echo \$! > iftop.pid if ${GPU_CUDA_OK} && [[ -e /dev/nvidia0 ]]; then echo Selecting solana-validator-cuda diff --git a/net/scripts/install-iftop.sh b/net/scripts/install-iftop.sh new file mode 100755 index 0000000000..b98345979f --- /dev/null +++ b/net/scripts/install-iftop.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +# Rsync setup +# +set -ex + +[[ $(uname) = Linux ]] || exit 1 +[[ $USER = root ]] || exit 1 + +apt-get --assume-yes install iftop diff --git a/scripts/iftop.sh b/scripts/iftop.sh new file mode 100755 index 0000000000..519b6b9016 --- /dev/null +++ b/scripts/iftop.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# Reports network bandwidth usage +# +set -e + +[[ $(uname) == Linux ]] || exit 0 + +cd "$(dirname "$0")" + +sudo iftop -i "$(ifconfig | grep mtu | grep -iv loopback | grep -i running | awk 'BEGIN { FS = ":" } ; {print $1}')" -nNbBP -t \ + | awk '{ if ($3 ~ "=>") { print $2, $7 } else if ($2 ~ "<=") { print $1, $6 }} ' \ + | awk 'NR%2{printf "%s ",$0;next;}1' \ + | awk '{ print $1, "<=>", $3, ":", $2, $4 }' + +exit 1