unicast octets statistics

Eugene Grosbein eugen at kuzbass.ru
Wed Jul 9 19:05:35 PDT 2003


Milan Obuch wrote:

> > ifInOctets counts broadcasts too.
> > I finished with ipfw2, thank you all.

> Maybe you could 'advertise' your solution :)

I use ipfw2 to count packets:

from any to any in recv ep0 mac $mymac any
and
from any to any out xmit ep0.

I know my router sends only unicast traffic to uplink
so the second rule is simple. Then I use dirty ;) but simple
script for net-snmp/pass_persist. Mrtg draws graphic of unicast
traffic, asking snmp agent for .1.3.6.1.4.1977.ifnumber.[12]

#!/bin/sh
# $Id: snmpifmon,v 1.1 2003/07/09 09:25:46 eugen Exp $
#
# Format: $MYMIB.ifnum.[12], 1 for input, 2 for output

MYMIB=.1.3.6.1.4.1977
OFS="$IFS"

while read command
do
  case $command in
  PING)
        echo PONG
        ;;
  get)
        read MIB
        case "$MIB" in
        $MYMIB*)
            IFS=.
            set $MIB
            IFS=$OFS
            shift 7
            if [ $# -eq 2 ]; then
              set `echo -n '0 '; ipfw show 4${1}${2} 2>/dev/null` 
              if [ -n "$4" ]; then
                echo $MIB
                echo integer
                echo $4
              else echo NONE
              fi
            else
              echo NONE
            fi
            ;;
        *)  echo NONE
            ;;
        esac
        ;;
  *)
        echo NONE
        ;;
  esac
done


More information about the freebsd-net mailing list