Analyze load of the channel to Internet

Vincent Hoffman vince at unsane.co.uk
Mon Aug 3 12:48:44 UTC 2009


Anton wrote:
>    Hello Gary,
> 
>    Due to what I've read about ntop - it is not really what I need.
> 
>    I dont have any Cisco routers, nor switches with port-mirroring - so I
>    c=uld not collect any traffic. I have only 2 freebsd routers - and
>    need to k=ow - when the outgoing channel of first gets overflowed
>    and I need to redi=ect outgoing traffic to second

Freebsd comes with bsnmp or if you prefer ports try net-snmp from ports,
these will let you query the snmp OID's mentioned.
I use a little perl script to query them and graph them myself for my
home router.
If you dont like snmp for some reason, putting something together using
netstat shouldnt be too hard. For example

(12:45:12 <~>) 0 # netstat -b -f inet -I fxp1
Name    Mtu Network       Address              Ipkts Ierrs     Ibytes
 Opkts Oerrs     Obytes  Coll
fxp1   1500 10.0.0.0/25   intgate             806889     -  118190683
1247743     - 1621177480     -

(excuse word wrap but it shouldnt be too hard to work out)

running this every minute from cron would make it easy to grab the in
(Ibytes) or out (Obytes) traffc and perform actions accordingly.

very quick and dirty example:
-------------cut--------------------
#!/bin/sh

IFNAME="fxp0"

OLDIN=$(netstat -b -I $IFNAME | awk '/Link/{print $7}')
OLDOUT=$(netstat -b -I $IFNAME | awk '/Link/{print $10}')

sleep 10

NEWIN=$(netstat -b -I $IFNAME | awk '/Link/{print $7}')
NEWOUT=$(netstat -b -I $IFNAME | awk '/Link/{print $10}')

INBPS=$(echo "( $NEWIN - $OLDIN ) / 10 " | bc )
OUTBPS=$(echo "( $NEWOUT - $OLDOUT ) / 10 " | bc )


echo "$IFNAME is doing $INBPS bytes a second inbound"
echo "$IFNAME is doing $OUTBPS bytes a second outbound"

--------------cut----------------------------


sample output:
(13:50:09 <~>) 0 # sh foo.sh
fxp0 is doing 1247 bytes a second inbound
fxp0 is doing 51175 bytes a second outbound




Vince

> 
>    Monday, August 3, 2009, 4:55:00 AM, you wrote:
> 
>    >
> 
>    almost any NIC / OS will support SNMP MIB-II counter=, which
>    includes octets Tx and Rx. MANY tools available for "getting" snmp   mib values.
> 
>    If you want util AND details on IP, ports, etc. - ch=ck out nTop.org
> 
>    ----- Original Message -----
> 
>    From: owner-freebsd-questions at freebsd.org <owner-   freebsd-questions at freebsd.org>
> 
>    To: freebsd-questions at freebsd.org <freebsd-questi=ns at freebsd.org>
> 
>    Sent: Sun Aug 02 15:08:38 2009
> 
>    Subject: Analyze load of the channel to Internet
> 
>    Hello everybody...
> 
>    Need to view and get real-time reporting of outgoing=hannel to
>    Internet?
> 
>    I think, that this is may be realized by means of ip=w (e.g. - get
>    counters
> 
>    of count rules for Internet and divide them to time,=hich passed
>    between
> 
>    analyzing)
> 
>    But, maybe, there is an utility, to which I can comm=nicate (or
>    which could
> 
>    analyze) my outgoing channel to Internet - and repor= me (mean some
> 
>    redirection script) when an outgoing channel gets ov=rflowed, and I
>    need to
> 
>    redirect all other outgoing traffic to another chann=l.
> 
>    I would like to clear: I have to channels for Intern=t, meaned for
>    gaming
> 
>    club - but I don't have enough finance to afford buy=ng some Cisco
>    device
> 
>    and this 2 channel are 512 kilobits and 768 kilobits=f outgoing
>    traffic
> 
>    Please, help
> 
>    _______________________________________________
> 
>    freebsd-questions at freebsd.org mailing list
> 
>    [1]http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> 
>    To unsubscribe, send any mail to "freebsd-questions-   unsubscribe at freebsd.org"
> 
>    "This email is intended to be reviewed by only the i=tended
>    recipient and may contain information that is privileged and/or con   fidential. If you are not the intended recipient, you are hereby
>    notified t=at any review, use, dissemination, disclosure or copying
>    of this email and=ts attachments, if any, is strictly prohibited. If
>    you have received this=mail in error, please immediately notify the
>    sender by return email and d=lete this email from your system."
> 
>    --
> 
>    Best regards,
> 
>     Anton           &nbs=;                [2]mailto:anton at sng.by
> 
>     Administrator
> 
>    Feel free to contact me
> 
>    via ICQ 363780596
> 
>    via Skype dobryak47
> 
>    via phone +375 29 3320987
> 
> References
> 
>    1. 3D"http://lists.freebsd.org/mailman/listinfo/freeb   2. 3D"mailto:anton at sng.by"
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list