New program to process iftop log output (#6668)

* New program to process iftop log output

* fixes

* fix shellcheck

* address review comments

* more review comments
This commit is contained in:
Pankaj Garg
2019-10-31 18:22:57 -07:00
committed by GitHub
parent d2c66c40c6
commit 2e30926ac3
7 changed files with 213 additions and 5 deletions

View File

@ -52,6 +52,7 @@ BINS=(
solana-install-init
solana-keygen
solana-ledger-tool
solana-log-analyzer
solana-archiver
solana-validator
)

32
scripts/iftop-postprocess.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# Reports network bandwidth usage
#
set -e
usage() {
echo "Usage: $0 <iftop log file> <temp file for interediate data> [optional public IP address]"
echo
echo Processes iftop log file, and extracts latest bandwidth used by each connection
echo
echo
}
if [ "$#" -lt 2 ]; then
usage
exit 1
fi
cd "$(dirname "$0")"
awk '{ if ($3 ~ "=>") { print $2, $7 } else if ($2 ~ "<=") { print $1, $6 }} ' < "$1" \
| awk 'NR%2{printf "%s ",$0;next;}1' \
| awk '{ print "{ \"a\": \""$1"\", " "\"b\": \""$3"\", \"a_to_b\": \""$2"\", \"b_to_a\": \""$4"\"}," }' > "$2"
if [ "$#" -ne 3 ]; then
solana-log-analyzer -i "$2"
else
solana-log-analyzer -i "$2" map-IP --priv "$(hostname -i)" --pub "$3"
fi
exit 1

View File

@ -8,9 +8,9 @@ set -e
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 }'
sudo=
if sudo true; then
sudo="sudo -n"
fi
exit 1
$sudo iftop -i "$(ifconfig | grep mtu | grep -iv loopback | grep -i running | awk 'BEGIN { FS = ":" } ; {print $1}')" -nNbBP -t