Solaris Live Network Bandwidth Monitoring

When doing performance analysis the current network throughput is often interesting. The following nice script display that – even without any root permissions.

#!/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

The script is taken from here: http://utcc.utoronto.ca/~cks/space/blog/solaris/SolarisNetworkBandwidth

It produces the following output which is sufficient to get a quick overview about the current network traffic:

bash-3.2$ /export/home/oracle/net.sh igb0 5
  0.59 MB/s RX  20.54 MB/s TX
  1.17 MB/s RX  40.81 MB/s TX
  1.71 MB/s RX  59.72 MB/s TX

Leave a Reply

Your email address will not be published.