Getting live network bandwidth numbers on LinuxToday I got curious about a simple question: was my iSCSI target machine actually running at its full potential read speed? The machine exports individual disks to its clients, so measuring single disk performance wouldn't give me the answer. Summing up IO across all the disks would have given me a number, but so would just getting the network bandwidth utilization; if the machine was saturating its gigabit link, it was clearly running as fast as it could. There doesn't seem to be a program that will directly show this
information (at least not on Red Hat Enterprise 5), but you can get the
total byte counts for an interface from Since it may be useful for other people, here's what I'm calling
#!/bin/sh
# usage: netvolmon DEV [INTERVAL]
DEV=$1
IVAL=5
if [ "$#" -eq 2 ]; then
IVAL=$2
fi
getrxtx() {
grep "$1:" /proc/net/dev | sed 's/^.*://' |
awk '{print $1, $9}'
}
rxtx=$(getrxtx $DEV)
while sleep $IVAL; do
nrxtx=$(getrxtx $DEV)
(echo $IVAL $rxtx $nrxtx) |
awk '{rxd = ($4 - $2) / (1024*1024*$1);
txd = ($5 - $3) / (1024*1024*$1);
printf "%6.2f MB/s RX %6.2f MB/s TX\n",
rxd, txd}'
rxtx="$nrxtx"
done
Unfortunately this illustrates one reason why shell scripting is so
pervasive: it is such a convenient way of banging rocks together in a
hurry. Once I hit on the trick of using (And I have to give (8 comments.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |