[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

Console Bandwidth Monitoring?



We have hacked together this script below in order to monitor our
current bandwidth usage on our public FTP server.  Unfortunately, it
appears to be gravely inaccurate.  Does anyone have a better method that
is accurate?  I wish to know my bandwidth usage in bytes/sec.

#!/bin/zsh

if [ $# -eq 0 ]; then
    echo "$0 <interface>"
    exit
fi

clear
BYTES_RECEIVED=$(cat /proc/net/dev | grep $1 | awk '{print $9}')
BYTES_SENT=$(cat /proc/net/dev | grep $1 | awk -F: '{print $2}' | awk
'{print $1}')

echo "Bytes Received: $BYTES_RECEIVED"
echo "Bytes Sent: $BYTES_SENT"

if [ $# -gt 1 ]; then
    echo "Receiving: $(( $BYTES_RECEIVED - $2 ))B/sec"
    echo "Sending: $(( $BYTES_SENT - $3))B/sec"
fi
sleep 1
exec $0 $1 $BYTES_RECEIVED $BYTES_SENT
_______________________________________________
LinuxManagers mailing list - http://www.linuxmanagers.org
submissions: LinuxManagers@linuxmanagers.org
subscribe/unsubscribe: http://www.linuxmanagers.org/mailman/listinfo/linuxmanagers

[Home]     [Kernel List]     [Linux SCSI]     [Video 4 Linux]     [Linux Admin]     [Yosemite News]     [Motherboards]

Powered by Linux