#!/bin/sh Ifconfig="/sbin/ifconfig" eth="enp3s0" while true;do RXpre=$($Ifconfig ${eth} | grep bytes | awk '{printf $2}' | awk -F":" '{printf $2}') TXpre=$($Ifconfig ${eth} | grep bytes | awk '{printf $6}' | awk -F":" '{printf $2}') sleep 1 RXnext=$($Ifconfig ${eth} | grep bytes | awk '{printf $2}' | awk -F":" '{printf $2}') TXnext=$($Ifconfig ${eth} | grep bytes | awk '{printf $6}' | awk -F":" '{printf $2}') TotalRXMin=$(expr `expr ${RXnext} - ${RXpre}` / 1024) TotalTXMin=$(expr `expr ${TXnext} - ${TXpre}` / 1024) echo "$(date +'%Y-%m-%d %H:%M:%S') Total Recive: ${TotalRXMin} kB/s,Total Transfer: ${TotalTXMin} kB/s" > /tmp/e.log done
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/268263.html