From fe963127c5cd85f282a37962f984cd866e5a1837 Mon Sep 17 00:00:00 2001 From: Newnius Date: Fri, 3 Jul 2020 15:04:36 +0800 Subject: [PATCH] update, add monitor scripts --- bin/monitor_bw.sh | 25 +++++++++++++++++++++++++ bin/monitor_gpu_util.sh | 9 +++++++++ 2 files changed, 34 insertions(+) create mode 100755 bin/monitor_bw.sh create mode 100755 bin/monitor_gpu_util.sh diff --git a/bin/monitor_bw.sh b/bin/monitor_bw.sh new file mode 100755 index 0000000..7be105a --- /dev/null +++ b/bin/monitor_bw.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +IF=$1 +if [[ -z "$IF" ]]; then + IF=`ls -1 /sys/class/net/ | head -1` +fi +RX_PREV=-1 +TX_PREV=-1 + +echo "Listening $IF..." + +while [[ 1 == 1 ]] ; do + RX=`cat /sys/class/net/${IF}/statistics/rx_bytes` + TX=`cat /sys/class/net/${IF}/statistics/tx_bytes` + if [ ${RX_PREV} -ne -1 ] ; then + let BWRX=($RX-$RX_PREV)/1024/1024/3 + let BWTX=($TX-$TX_PREV)/1024/1024/3 + #echo "Received: $BWRX MB/s Sent: $BWTX MB/s" + date=`date` + echo "$date:${BWRX},${BWTX}" + fi + RX_PREV=${RX} + TX_PREV=${TX} + sleep 3 +done \ No newline at end of file diff --git a/bin/monitor_gpu_util.sh b/bin/monitor_gpu_util.sh new file mode 100755 index 0000000..1b1d9f7 --- /dev/null +++ b/bin/monitor_gpu_util.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +while true +do + utils=`nvidia-smi -q -x | grep gpu_util | awk '{print $1}' | awk -F'>' '{print $2}' | xargs echo` + + echo "$(date):${utils}" + sleep 1 +done \ No newline at end of file