Getting live network bandwidth numbers on SolarisAfter I wrote netvolmon for Linux,
I started getting curious about how much bandwidth our current Solaris
NFS servers were using. Unfortunately, Solaris's version of The magic Armed with this we can write the obvious Solaris version of
#!/bin/sh
# usage: netvolmon DEV [INTERVAL]
DEV=$1
IVAL=${2:-5}
getrxtx() {
kstat -p "*:*:$1:*bytes64" |
awk '{print $2}'
}
rxtx=`getrxtx $DEV`
while sleep $IVAL; do
nrxtx=`getrxtx $DEV`
(echo $IVAL $rxtx $nrxtx) |
awk 'BEGIN {
msg = "%6.2f MB/s RX %6.2f MB/s TX\n"}
{rxd = ($4 - $2) / (1024*1024*$1);
txd = ($5 - $3) / (1024*1024*$1);
printf msg, rxd, txd}'
rxtx="$nrxtx"
done
Vaguely to my surprise, it turns out that Solaris 8 awk doesn't allow
you to split (This can easily be extended to report packets per second as well; the device counters you want are 'opackets64' and 'rpackets64'. I didn't put it in this version for a petty reason, namely that it would make this entry too wide, but you can get the full versions for both Solaris and Linux here.) (One comment.)
|
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 |