OpenWrt Forum Archive

Topic: how to check bandwidth usage?

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

What software do you use to check bandwidth usage on your WRT routers?

Something like below would be sufficient for me (with output every second etc):

# bandwidth -i ppp0
in 6 KB/s out 14 KB/s
in 4 KB/s out 9 KB/s
in 10 KB/s out 10 KB/s


Other nice thing would be to measure bandwidth of a certain client:

# bandwidth -i vlan0 --ip 192.168.1.6
in 6 KB/s out 14 KB/s
in 4 KB/s out 9 KB/s
in 10 KB/s out 10 KB/s

Do you have some tool in mind?

might want to checkout iftop.

-Duffin

I run gkrellmd on my wrt54g's. It has bandwidth, cpu, disk, etc, etc, etc stats for your router
Get the binary at my website:
http://chrisspot.com/software/gkrellm/wrt54g/

(Last edited by sublime on 19 Dec 2005, 23:50)

I suggest using iftop-banggless package

install:
rm /etc/ipkg.conf
cp /rom/etc/ipkg.conf /etc/ipkg.conf
echo "src timfreeman http://www.fungible.com/openwrt/packages" > /etc/ipkg.conf
ipkg update
ipkg install iftop-bangless
rm /etc/init.d/S50telnet
cp /rom/etc/init.d/S50telnet /etc/init.d/S50telnet
vi /etc/init.d/S50telnet (change "telnetd -l /bin/login" in to "telnetd -l /usr/bin/iftop-bangless")

DON'T FORGET ACTIVATE SSH ACCESS !!

reboot

telnet to your router smile

you should see something like this

                12.5Kb          25.0Kb          37.5Kb          50.0Kb    62.5Kb
????????????????????????????????????????????????????????????????????????????????
192.168.10.1               => 192.168.10.201             1.99Kb  2.08Kb  2.08Kb
                           <=                             320b    320b    320b
217.17.41.93               => 192.168.10.201              248b    124b    124b
                           <=                             160b     80b     80b
193.17.41.53               => 192.168.10.201                0b     80b     80b
                           <=                               0b     82b     82b












????????????????????????????????????????????????????????????????????????????????
TX:             cumm:  1.14KB   peak:   2.34Kb  rates:   2.23Kb  2.28Kb  2.28Kb
RX:                     241B             480b             480b    482b    482b
TOTAL:                 1.38KB           2.80Kb           2.70Kb  2.75Kb  2.75Kb

I use snmp to monitor my bandwidth usage and use rrdtool to make pretty graphs of said usage.

jwolf wrote:

I use snmp to monitor my bandwidth usage and use rrdtool to make pretty graphs of said usage.

Could you give a quick howto on how you setup snmp and how you generate your graphs? Screenshots?

I'm looking for a way to generate graphs over my bandwidth usage. I'm looking for something that can display by protcol so I can se where the most traffic usage comes from.

Yes, actually I already hav those. But I'm looking for a way to generate non realtime graphs so I can see the bandwidth usage the last 24H, 7 days, month... etc.

I have a server on the inside that can store the data and do the calculations.... but I need to get the data somehow from the router. I guess I'll have to write some l7-filter matcher to match packages to services and the count the data over each service and send this to the server... or something...

Anyone that has a solution like this?

get cacti on your server and snmpd on the router

kaksi wrote:
jwolf wrote:

I use snmp to monitor my bandwidth usage and use rrdtool to make pretty graphs of said usage.

Could you give a quick howto on how you setup snmp and how you generate your graphs? Screenshots?

I'm looking for a way to generate graphs over my bandwidth usage. I'm looking for something that can display by protcol so I can se where the most traffic usage comes from.

yea second that..any HOWTOs?

netddos wrote:
kaksi wrote:
jwolf wrote:

I use snmp to monitor my bandwidth usage and use rrdtool to make pretty graphs of said usage.

Could you give a quick howto on how you setup snmp and how you generate your graphs? Screenshots?

I'm looking for a way to generate graphs over my bandwidth usage. I'm looking for something that can display by protcol so I can se where the most traffic usage comes from.

yea second that..any HOWTOs?

I'm busy this weekend but I will see what I can cook up next weekend. I'll be sure to add it to the Wiki.

As far as graphing by protocol, I'm not sure that's possible (due to the somewhat limited data being reported by SNMP). It is possible, however, to graph traffic by interface. Perhaps someone with more experience with SNMP and rrdtool can bring some light to this.

I solved it like this:

I created itables rules to identify the different protocols with l7-filter. The I created a script that listed the throughput of each protocol and put it on the webserver of the openwrt router. On my second server I the wget the output of the script, grepped for the right data and then put it in an rrd database and genereted graphs from this. The result: http://graphs.densnygge.se/network-day.png http://graphs.densnygge.se/

kaksi, can you share your scripts and rules smile?

Regards,
Dino

jwolf wrote:
netddos wrote:
kaksi wrote:

Could you give a quick howto on how you setup snmp and how you generate your graphs? Screenshots?

I'm looking for a way to generate graphs over my bandwidth usage. I'm looking for something that can display by protcol so I can se where the most traffic usage comes from.

yea second that..any HOWTOs?

I'm busy this weekend but I will see what I can cook up next weekend. I'll be sure to add it to the Wiki.

As far as graphing by protocol, I'm not sure that's possible (due to the somewhat limited data being reported by SNMP). It is possible, however, to graph traffic by interface. Perhaps someone with more experience with SNMP and rrdtool can bring some light to this.

thanks!!

I will upload the scripts soon... I'm not at home right now

My iptabbles rules:

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto bittorrent -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto bittorrent -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto ftp -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto ftp -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto ssh -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto ssh -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto pop3 -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto pop3 -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto smtp -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto smtp -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto imap -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto imap -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto directconnect -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto directconnect -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto http -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto http -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto rdp -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto rdp -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto smb -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto smb -j MARK --set-mark 3

iptables -t mangle -A POSTROUTING -o vlan1 -m layer7 --l7proto ventrilo -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i vlan1 -m layer7 --l7proto ventrilo -j MARK --set-mark 3

#All unmarked
iptables -t mangle -A POSTROUTING -o $WAN -m mark --mark 0 -j MARK --set-mark 100
iptables -t mangle -A PREROUTING -i $WAN -m mark --mark 0 -j MARK --set-mark 101

The sscripts on the webserver:

#!/bin/sh
iptables -L -v -t mangle --exact

Create the rrd database  (really ugly code, shame on me):

#!/usr/bin/perl -w
#

use RRDs;

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';

system("rm siptables.sh");
system("rm snet_in.sh");
system("rm snet_out.sh");
system("wget -q http://192.168.1.1:3000/cgi-bin/iptables.sh -O siptables.sh");
system("wget -q http://192.168.1.1:3000/cgi-bin/net_in.sh -O snet_in.sh");
system("wget -q http://192.168.1.1:3000/cgi-bin/net_out.sh -O snet_out.sh");


if (! -e "$rrd/service_graphs.rrd")
{
        print "creating rrd database for network...\n";
        RRDs::create "$rrd/service_graphs.rrd",
                "-s 300",
                "DS:in_total:COUNTER:600:0:12500000",
                "DS:out_total:COUNTER:600:0:12500000",
                "DS:ftp_in:COUNTER:600:0:12500000",
                "DS:ftp_out:COUNTER:600:0:12500000",
                "DS:ssh_in:COUNTER:600:0:12500000",
                "DS:ssh_out:COUNTER:600:0:12500000",
                "DS:http_in:COUNTER:600:0:12500000",
                "DS:http_out:COUNTER:600:0:12500000",
                "DS:mail_in:COUNTER:600:0:12500000",
                "DS:mail_out:COUNTER:600:0:12500000",
                "DS:ventrilo_in:COUNTER:600:0:12500000",
                "DS:ventrilo_out:COUNTER:600:0:12500000",
                #"DS:hlstats_in:COUNTER:600:0:12500000",
                #"DS:hlstats_out:COUNTER:600:0:12500000",
                "DS:warez_in:COUNTER:600:0:12500000",
                "DS:warez_out:COUNTER:600:0:12500000",
                "DS:games_in:COUNTER:600:0:12500000",
                "DS:games_out:COUNTER:600:0:12500000",
                "DS:other_in:COUNTER:600:0:12500000",
                "DS:other_out:COUNTER:600:0:12500000",
                "RRA:AVERAGE:0.5:1:576",
                "RRA:AVERAGE:0.5:6:672",
                "RRA:AVERAGE:0.5:24:732",
                "RRA:AVERAGE:0.5:144:1460";
        if ($ERROR = RRDs::error) { print "unable to generate database: $ERROR\n"; }
}

sleep 2;

my $in_total =  `cat snet_in.sh`  *1;
my $out_total =  `cat snet_out.sh`  *1;

#my $ftp_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:20:21'|gawk '{print \$2}'` * 1;
#my $ftp_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:20:21'|gawk '{print \$2}'` * 1;
#my $ftp_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:20:21'|gawk '{print \$2}'` * 1;
#my $ftp_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:20:21'|gawk '{print \$2}'` * 1;
#my $ftp_in = $ftp_in1 + $ftp_in2;
#my $ftp_out = $ftp_out1 + $ftp_out2;
my $ftp_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto ftp'|gawk '{print \$2}'` * 1;
my $ftp_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto ftp'|gawk '{print \$2}'` * 1;

#my $ssh_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpt:22 M'|gawk '{print \$2}'` * 1;
#my $ssh_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spt:22 M'|gawk '{print \$2}'` * 1;
#my $ssh_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpt:22 M'|gawk '{print \$2}'` * 1;
#my $ssh_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spt:22 M'|gawk '{print \$2}'` * 1;
#my $ssh_in = $ssh_in1 + $ssh_in2;
#my $ssh_out = $ssh_out1 + $ssh_out2;

my $ssh_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto ssh'|gawk '{print \$2}'` * 1;
my $ssh_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto ssh'|gawk '{print \$2}'` * 1;

#my $http_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:80:8080'|gawk '{print \$2}'` * 1;
#my $http_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:80:8080'|gawk '{print \$2}'` * 1;
#my $http_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:80:8080'|gawk '{print \$2}'` * 1;
#my $http_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:80:8080'|gawk '{print \$2}'` * 1;

#my $https_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpt:443'|gawk '{print \$2}'` * 1;
#my $https_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spt:443'|gawk '{print \$2}'` * 1;
#my $https_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpt:443'|gawk '{print \$2}'` * 1;
#my $https_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spt:443'|gawk '{print \$2}'` * 1;

#my $http_in = $http_in1 + $http_in2 + $https_in1 + $https_in2;
#my $http_out = $http_out1 + $http_out2 + $https_out1 + $https_out2;

my $http_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto http'|gawk '{print \$2}'` * 1;
my $http_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto http'|gawk '{print \$2}'` * 1;

#my $smtp_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:25:465'|gawk '{print \$2}'` * 1;
#my $smtp_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:25:465'|gawk '{print \$2}'` * 1;
#my $smtp_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:25:465'|gawk '{print \$2}'` * 1;
#my $smtp_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:25:465'|gawk '{print \$2}'` * 1;

#my $pop3_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:110:995'|gawk '{print \$2}'` * 1;
#my $pop3_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:110:995'|gawk '{print \$2}'` * 1;
#my $pop3_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:110:995'|gawk '{print \$2}'` * 1;
#my $pop3_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:110:995'|gawk '{print \$2}'` * 1;

#my $imap_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:143:993'|gawk '{print \$2}'` * 1;
#my $imap_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:143:993'|gawk '{print \$2}'` * 1;
#my $imap_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:143:993'|gawk '{print \$2}'` * 1;
#my $imap_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:143:993'|gawk '{print \$2}'` * 1;

#my $mail_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpts:389:689'|gawk '{print \$2}'` * 1;
#my $mail_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spts:389:689'|gawk '{print \$2}'` * 1;
#my $mail_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpts:389:689'|gawk '{print \$2}'` * 1;
#my $mail_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spts:389:689'|gawk '{print \$2}'` * 1;

#my $mail_in = $smtp_in1 + $smtp_in1 + $pop3_in1 + $pop3_in2 + $imap_in1 + $imap_in2 + $mail_in1 + $mail_in2;
#my $mail_out = $smtp_out1 + $smtp_out2 + $pop3_out1 + $pop3_out2 + $imap_out1 + $imap_out2 + $mail_out1 + $mail_out2;

my $smtp_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto smtp'|gawk '{print \$2}'` * 1;
my $smtp_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto smtp'|gawk '{print \$2}'` * 1;

my $pop3_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto pop3'|gawk '{print \$2}'` * 1;
my $pop3_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto pop3'|gawk '{print \$2}'` * 1;

my $imap_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto imap'|gawk '{print \$2}'` * 1;
my $imap_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto imap'|gawk '{print \$2}'` * 1;

my $mail_in = $smtp_in + $pop3_in + $imap_in;
my $mail_out = $smtp_out + $pop3_out + $imap_out;

#my $ventrilo_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpt:3784'|gawk '{print \$2}'` * 1;
#my $ventrilo_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spt:3784'|gawk '{print \$2}'` * 1;
#my $ventrilo_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpt:3784'|gawk '{print \$2}'` * 1;
#my $ventrilo_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spt:3784'|gawk '{print \$2}'` * 1;

#my $ventrilo_in = $ventrilo_in1 + $ventrilo_in2;
#my $ventrilo_out = $ventrilo_out1 + $ventrilo_out2;

my $ventrilo_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto ventrilo'|gawk '{print \$2}'` * 1;
my $ventrilo_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto ventrilo'|gawk '{print \$2}'` * 1;

#my $hlstats_in1 = `cat siptables.sh|grep 'vlan1  any'|grep 'dpt:27500'|gawk '{print \$2}'` * 1;
#my $hlstats_in2 = `cat siptables.sh|grep 'vlan1  any'|grep 'spt:27500'|gawk '{print \$2}'` * 1;
#my $hlstats_out1 = `cat siptables.sh|grep 'ny    vlan1'|grep 'dpt:27500'|gawk '{print \$2}'` * 1;
#my $hlstats_out2 = `cat siptables.sh|grep 'ny    vlan1'|grep 'spt:27500'|gawk '{print \$2}'` * 1;

#my $hlstats_in = $hlstats_in1 + $hlstats_in2;
#my $hlstats_out = $hlstats_out1 + $hlstats_out2;

my $directconnect_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto directconnect'|gawk '{print \$2}'` * 1;
my $directconnect_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto directconnect'|gawk '{print \$2}'` * 1;

my $bittorrent_in = `cat siptables.sh|grep 'vlan1  any'|grep 'l7proto bittorrent'|gawk '{print \$2}'` * 1;
my $bittorrent_out = `cat siptables.sh|grep 'ny    vlan1'|grep 'l7proto bittorrent'|gawk '{print \$2}'` * 1;

my $warez_in = $directconnect_in + $bittorrent_in;
my $warez_out = $directconnect_out + $bittorrent_out;

my $games_in = 0 * 1;
my $games_out = 0 * 1;

my $other_in = `cat siptables.sh|grep 'MARK match 0x0 MARK set 0x65'|gawk '{print \$2}'` * 1;
my $other_out = `cat siptables.sh|grep 'MARK match 0x0 MARK set 0x64'|gawk '{print \$2}'` * 1;

my $uptime = `cut -d" " -f1 /proc/uptime` *1;
if ($uptime > 600) {
# insert values into rrd
RRDs::update "$rrd/service_graphs.rrd",
        "-t",
"in_total:out_total:ftp_in:ftp_out:http_in:http_out:mail_in:mail_out:ventrilo_in:ventrilo_out:warez_in:warez_out:games_in:games_out:other_in:other_out",
"N:$in_total:$out_total:$ftp_in:$ftp_out:$http_in:$http_out:$mail_in:$mail_out:$ventrilo_in:$ventrilo_out:$warez_in:$warez_out:$games_in:$games_out:$other_in:$other_out";



if ($ERROR = RRDs::error) { print "unable to update: $ERROR\n"; }
}

Generate graphs:

#!/bin/bash


# Full path to your rrdtool binary
RRDTOOL=/usr/bin/rrdtool

# Full path to your rrd datase
RRD=/var/lib/rrd/service_graphs.rrd

# The title of your graph
TITLE='traffic on vlan0 :: Mokey (Internet Gateway) Port Specific'

# Output path where your graphs will end up
OPATH=/home/magnus/www/graphs/

# Date command, add date formating if you would like so (man date)
DATECMD='/bin/date'

#
# End of configuration
#

for i in 1 2 3 4 5;
  do
    if [ "$i" == "1" ]; then
      START="12h"
      FILENAME="network-12h.png"
    fi
    if [ "$i" == "2" ]; then
      START="24h"
      FILENAME="network-day.png"
    fi
    if [ "$i" == "3" ]; then
      START=604800
      FILENAME="network-week.png"
    fi
    if [ "$i" == "4" ]; then
      START=2419200
      FILENAME="network-month.png"
    fi
    if [ "$i" == "5" ]; then
      START=31536000
      FILENAME="network-year.png"
    fi
DATE=`$DATECMD`

$RRDTOOL graph $OPATH/$FILENAME \
--start -$START \
--title "$TITLE" \
--vertical-label 'Bytes per second' \
-w 800 \
-h 200 \
-l 0 \
-Y \
-M \
-E \
-i \
DEF:in_total=$RRD:in_total:AVERAGE \
DEF:out_total=$RRD:out_total:AVERAGE \
DEF:ftp_in=$RRD:ftp_in:AVERAGE \
DEF:ftp_out=$RRD:ftp_out:AVERAGE \
DEF:http_in=$RRD:http_in:AVERAGE \
DEF:http_out=$RRD:http_out:AVERAGE \
DEF:ssh_in=$RRD:ssh_in:AVERAGE \
DEF:ssh_out=$RRD:ssh_out:AVERAGE \
DEF:mail_in=$RRD:mail_in:AVERAGE \
DEF:mail_out=$RRD:mail_out:AVERAGE \
DEF:ventrilo_in=$RRD:ventrilo_in:AVERAGE \
DEF:ventrilo_out=$RRD:ventrilo_out:AVERAGE \
DEF:warez_in=$RRD:warez_in:AVERAGE \
DEF:warez_out=$RRD:warez_out:AVERAGE \
DEF:games_in=$RRD:games_in:AVERAGE \
DEF:games_out=$RRD:games_out:AVERAGE \
DEF:other_in=$RRD:other_in:AVERAGE \
DEF:other_out=$RRD:other_out:AVERAGE \
 "CDEF:neg_out_total=out_total,-1,*"    \
 "CDEF:neg_ftp_out=ftp_out,-1,*"    \
 "CDEF:neg_ssh_out=ssh_out,-1,*"    \
 "CDEF:neg_http_out=http_out,-1,*"    \
 "CDEF:neg_mail_out=mail_out,-1,*"    \
 "CDEF:neg_ventrilo_out=ventrilo_out,-1,*"    \
 "CDEF:neg_warez_out=warez_out,-1,*"    \
 "CDEF:neg_games_out=games_out,-1,*"    \
 "CDEF:neg_other_out=other_out,-1,*"    \
"COMMENT:                                     IN                                                                            OUT\N" \
"COMMENT:                       MAX         AVERAGE             CURRENT                                 MAX         AVERAGE     CURRENT\n" \
 LINE1:in_total#FF0000:'TOTAL   ' \
"GPRINT:in_total:MAX:%5.1lf %sB/s", \
"GPRINT:in_total:AVERAGE:%5.1lf %sB/s", \
"GPRINT:in_total:LAST:%5.1lf %sB/s                              " \
"GPRINT:out_total:MAX:%5.1lf %sB/s", \
"GPRINT:out_total:AVERAGE:%5.1lf %sB/s", \
"GPRINT:out_total:LAST:%5.1lf %sB/s\n" \
LINE1:ftp_in#ff00ea:'FTP     ' \
"GPRINT:ftp_in:MAX:%5.1lf %sB/s", \
"GPRINT:ftp_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ftp_in:LAST:%5.1lf %sB/s                                " \
"GPRINT:ftp_out:MAX:%5.1lf %sB/s", \
"GPRINT:ftp_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ftp_out:LAST:%5.1lf %sB/s\n" \
LINE1:ssh_in#ff00ea:'SSH     ' \
"GPRINT:ssh_in:MAX:%5.1lf %sB/s", \
"GPRINT:ssh_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ssh_in:LAST:%5.1lf %sB/s                                " \
"GPRINT:ssh_out:MAX:%5.1lf %sB/s", \
"GPRINT:ssh_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ssh_out:LAST:%5.1lf %sB/s\n" \
LINE1:http_in#a200ff:'HTTP    ' \
"GPRINT:http_in:MAX:%5.1lf %sB/s", \
"GPRINT:http_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:http_in:LAST:%5.1lf %sB/s                               " \
"GPRINT:http_out:MAX:%5.1lf %sB/s", \
"GPRINT:http_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:http_out:LAST:%5.1lf %sB/s\n" \
LINE1:mail_in#3c00ff:'MAIL    ' \
"GPRINT:mail_in:MAX:%5.1lf %sB/s", \
"GPRINT:mail_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:mail_in:LAST:%5.1lf %sB/s                               " \
"GPRINT:mail_out:MAX:%5.1lf %sB/s", \
"GPRINT:mail_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:mail_out:LAST:%5.1lf %sB/s\n" \
LINE1:ventrilo_in#0072ff:'VENTRILO' \
"GPRINT:ventrilo_in:MAX:%5.1lf %sB/s", \
"GPRINT:ventrilo_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ventrilo_in:LAST:%5.1lf %sB/s                           " \
"GPRINT:ventrilo_out:MAX:%5.1lf %sB/s", \
"GPRINT:ventrilo_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:ventrilo_out:LAST:%5.1lf %sB/s\n" \
LINE1:warez_in#00ff84:'WAREZ   ' \
"GPRINT:warez_in:MAX:%5.1lf %sB/s", \
"GPRINT:warez_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:warez_in:LAST:%5.1lf %sB/s                              " \
"GPRINT:warez_out:MAX:%5.1lf %sB/s", \
"GPRINT:warez_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:warez_out:LAST:%5.1lf %sB/s\n" \
LINE1:games_in#00ff18:'GAMES   ' \
"GPRINT:games_in:MAX:%5.1lf %sB/s", \
"GPRINT:games_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:games_in:LAST:%5.1lf %sB/s                              " \
"GPRINT:games_out:MAX:%5.1lf %sB/s", \
"GPRINT:games_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:games_out:LAST:%5.1lf %sB/s\n" \
LINE1:other_in#a8ff00:'OTHER   ' \
"GPRINT:other_in:MAX:%5.1lf %sB/s", \
"GPRINT:other_in:AVERAGE:%5.1lf %sB/s", \
"GPRINT:other_in:LAST:%5.1lf %sB/s                              " \
"GPRINT:other_out:MAX:%5.1lf %sB/s", \
"GPRINT:other_out:AVERAGE:%5.1lf %sB/s", \
"GPRINT:other_out:LAST:%5.1lf %sB/s\n" \
LINE1:neg_ftp_out#ff00ea \
LINE1:neg_ssh_out#a200ff \
LINE1:neg_http_out#3c00ff \
LINE1:neg_mail_out#0072ff \
LINE1:neg_ventrilo_out#00fffc \
LINE1:neg_warez_out#00ff18 \
LINE1:neg_games_out#a8ff00 \
LINE1:neg_other_out#fcff00 \
COMMENT:"!\r" #date

done

And there it is....

Would any of this allow me to monitor the bandwidth coming from specific device on the network? I want to see how much bandwidth my VoIP adapter is getting in different conditions (no activity, P2P going on, active FTP session, etc.). I don't need historical recording at this moment, but I am sure if I get real time data - I would want to have the log as well.

Thx

Actually i am writing a script for graph and data logging, i will post it in some days.
For graph for qos, i use the iptables directly, so its work with all qos script

sioux wrote:

I suggest using iftop-banggless package

sioux,

is it possible to rebuild the package to depend on libpcap 0.9; not 0.8? When I am telneting to iftop-bangless, I am getting /usr/bin/iftop-bangless: can't load library 'libpcap.so.0.8'; probably because I have /usr/lib/libpcap.so.0.9.4 and /usr/lib/libpcap.so.0.9

Thanks in advance - I think that this the exact information that I am looking for!
Felix

ymhee_bcex wrote:

is it possible to rebuild the package to depend on libpcap 0.9; not 0.8? When I am telneting to iftop-bangless, I am getting /usr/bin/iftop-bangless: can't load library 'libpcap.so.0.8'; probably because I have /usr/lib/libpcap.so.0.9.4 and /usr/lib/libpcap.so.0.9
Felix

just make a symbolic link to the file (ln -s libpcap.so.0.9.4 libpcap.so.0.8)

eatnumber1 wrote:

just make a symbolic link to the file (ln -s libpcap.so.0.9.4 libpcap.so.0.8)

indeed! haven't thought about it hmm Thanks a lot. This seems exactly what I was looking for

kaksi wrote:

I solved it like this:

I created itables rules to identify the different protocols with l7-filter. The I created a script that listed the throughput of each protocol and put it on the webserver of the openwrt router. On my second server I the wget the output of the script, grepped for the right data and then put it in an rrd database and genereted graphs from this. The result: http://graphs.densnygge.se/network-day.png http://graphs.densnygge.se/

That's pretty cool. Another thing you might consider is to install the fprobe ipkg which generates netflows. You could run ntop on another server and point your fprobe collector to it. ntop creates all kinds of neat protocol breakdowns and graphs based on that NetFlow data. It's very simple to set up.

so, I've been running iftop-bangless package for a week - and I love it! It does exactly what I want.

Two questions, though, on customization:
First, is it possible to not truncate the external host name. Some of the host names are quite long; so I would prefer to either wrap onto the second line (esp. in two-line mode), or just to push lan addresses to the right... Of course, I can switch to IP addresses, and then run hostname from command line. But it's such a kluge sad

Second, I see the options for "set filter" and "screen filter". What is the syntax for these options. For example, if I want to exclude one of the servers on the lan from monitoring, or something like that - how would I do it?

The program says that it's "top for network monitoring" - but I didn't see the filtering in top.

Started coding a new way of generating graphs since rrdtool is so complicated. I use a the jpgraph php package. I generated this graph: http://graphs.densnygge.se/bar2scalesex1.php

Each bar represents the ammount of data passed though my router during three hours... As soon as I have enough ammount of data each bar will represent 24hours. I will also create a script that generates a line graph with the throughput.

As soons as I have completed the scripts I will post them here...

Until then, what do you think?

The discussion might have continued from here.