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:
32
scripts/iftop-postprocess.sh
Executable file
32
scripts/iftop-postprocess.sh
Executable 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
|
Reference in New Issue
Block a user