# Network monitoring tool



## wonslung (May 16, 2009)

I'm looking for a basic tool to monitor bandwidth on my machine so i can effectively set up altq.  I remember using ntop of pfsense but it used to crash every 2-3 minutes...any thoughts?
all i really need is a graph showing my bandwidth throughout the day.


----------



## hydra (May 16, 2009)

Try MRTG or zabbix. I'm working on a tool that measures per-IP usage (bandwidth / packet rate).


----------



## wonslung (May 16, 2009)

i've used MRTG before.....it's been awhile.

I didn't need anything like that, i ended up using vnstat
thanks though, i WILL check out zabbix just because i've never seen it


----------



## edhunter (May 16, 2009)

net/nload 

"screenshot":

```
Device vlan13 [xx.xx.xx.xx] (8/8):
=========================================================================================================
Incoming:





                                                                        Curr: 0.29 kBit/s
                                                                        Avg: 0.60 kBit/s
                                                                        Min: 101.37 kBit/s
                                              .     ..                  Max: 3.64 MBit/s
  #|  .#| ..         ##...##    .  ...    ..||##   .##.  ..... ####     Ttl: 2.15 GByte
Outgoing:





                                                                        Curr: 25.83 kBit/s
                                                                        Avg: 66.96 kBit/s
                                                                        Min: 3.26 kBit/s
                                                                        Max: 0.56 kBit/s
                                                     .                  Ttl: 3.84 GByte
```


----------



## DutchDaemon (May 16, 2009)

You're already running pf, so sysutils/pfstat should be a breeze. You can monitor altq queues with it as well. It produces mrtg-like jpg/png graphs for any time interval you want.


----------



## Mel_Flynn (May 16, 2009)

And adding net/bmon for per interface statistics capable of being saved to a database, flat html and rrdtool.
Also, sysutils/pftop[/port] view '8' is very useful for live monitoring of already existing queues, since the last time you reloaded the rules. Especially with borrows, it's good to see they are needed / being overloaded etc.


----------



## wonslung (May 17, 2009)

thanks for the suggestions guys =)


----------



## wonslung (May 17, 2009)

well i tried pfstat but i can't seem to get any graphs..when i do pfstat -q i get nothing
not sure what i did wrong.

here is my config file



```
#
collect 1 = interface "em0" pass bytes in ipv4 diff
collect 2 = interface "em0" pass bytes out ipv4 diff
collect 3 = global states entries

image "/usr/local/www/basic/pfstat/pfstat_day.jpg" {
        from 1 days to now
        width 980 height 200
        left
                graph 1 "in" "bytes/s" color 0 192 0 filled,
                graph 2 "out" "bytes/s" color 0 0 255
        right
                graph 3 "states" "entries" color 192 192 0
}

image "/usr/local/www/basic/pfstat/pfstat_week.jpg" {
        from 1 weeks to now
        width 980 height 200
        left
                graph 1 "in" "bytes/s" color 0 192 0 filled,
                graph 2 "out" "bytes/s" color 0 0 255
        right
                graph 3 "states" "entries" color 192 192 0
}

image "/usr/local/www/basic/pfstat/pfstat_month.jpg" {
        from 1 months to now
        width 980 height 200
        left
                graph 1 "in" "bytes/s" color 0 192 0 filled,
                graph 2 "out" "bytes/s" color 0 0 255
        right
                graph 3 "states" "entries" color 192 192 0
}

#
collect 4 = interface "em0" pass packets in ipv4 diff
collect 5 = interface "em0" pass packets out ipv4 diff
collect 6 = interface "em0" block packets in ipv4 diff
collect 7 = interface "em0" block packets out ipv4 diff

image "/usr/local/www/basic/pfstat/pfstat-packets_day.jpg" {
        from 1 days to now
        width 980 height 200
        left
          graph 4 "pass in"   "packets/s" color 0 192 0 filled,
                graph 5 "pass out"  "packets/s" color 0 0 255
        right
                graph 6 "block in"  "packets/s" color 255 0 0,
                graph 7 "block out" "packets/s" color 192 192 0
}

image "/usr/local/www/basic/pfstat/pfstat-packets_week.jpg" {
        from 1 weeks to now
        width 980 height 200
        left
                graph 4 "pass in"   "packets/s" color 0 192 0 filled,
                graph 5 "pass out"  "packets/s" color 0 0 255
        right
                graph 6 "block in"  "packets/s" color 255 0 0,
                graph 7 "block out" "packets/s" color 192 192 0
}

image "/usr/local/www/basic/pfstat/pfstat-packets_month.jpg" {
        from 1 months to now
        width 980 height 200
        left
                graph 4 "pass in"   "packets/s" color 0 192 0 filled,
                graph 5 "pass out"  "packets/s" color 0 0 255
        right
                graph 6 "block in"  "packets/s" color 255 0 0,
                graph 7 "block out" "packets/s" color 192 192 0
}

#
collect  8 = global states inserts  diff
collect  9 = global states removals diff
collect 10 = global states searches diff

image "/usr/local/www/basic/pfstat/pfstat-states_day.jpg" {
        from 1 days to now
        width 980 height 200
        left
                graph 8 "inserts" "states/s" color 0 192 0 filled,
                graph 9 "removals" "states/s" color 0 0 255
        right
                graph 10 "searches" "states/s" color 255 0 0
}
 
image "/usr/local/www/basic/pfstat/pfstat-states_week.jpg" {
        from 1 weeks to now
        width 980 height 200
        left
                graph 8 "inserts" "states/s" color 0 192 0 filled,
                graph 9 "removals" "states/s" color 0 0 255
        right
                graph 10 "searches" "states/s" color 255 0 0
}
 
image "/usr/local/www/basic/pfstat/pfstat-states_week.jpg" {
        from 1 weeks to now
        width 980 height 200
        left
                graph 8 "inserts" "states/s" color 0 192 0 filled,
                graph 9 "removals" "states/s" color 0 0 255
        right
                graph 10 "searches" "states/s" color 255 0 0
}

image "/usr/local/www/basic/pfstat/pfstat-states_month.jpg" {
        from 1 months to now
        width 980 height 200
        left
                graph 8 "inserts" "states/s" color 0 192 0 filled,
                graph 9 "removals" "states/s" color 0 0 255
        right
                graph 10 "searches" "states/s" color 255 0 0
}

#
collect 15 = global counters match          diff
collect 16 = global counters bad-offset     diff
collect 17 = global counters fragment       diff
collect 18 = global counters short          diff
collect 19 = global counters normalize      diff
collect 20 = global counters memory         diff
collect 21 = global counters bad-timestamp  diff
collect 22 = global counters congestion     diff
collect 23 = global counters ip-option      diff
collect 24 = global counters proto-cksum    diff
collect 25 = global counters state-mismatch diff
collect 26 = global counters state-insert   diff
collect 27 = global counters state-limit    diff
collect 28 = global counters src-limit      diff
collect 29 = global counters synproxy       diff

image "/usr/local/www/basic/pfstat/pfstat-errors_day.jpg" {
       from 1 days to now
       width 980 height 200
        left
               graph 17 "frag" "/s" color 192 0 192,
               graph 22 "cong" "/s" color 0 192 192,
               graph 23 "iopt" "/s" color 0 0 255,
               graph 24 "csum" "/s" color 192 192 0,
               graph 25 "mism" "/s" color 255 0 0
#        
        right
               graph 15 "match" "/s" color 0 192 0
}

image "/usr/local/www/basic/pfstat/pfstat-errors_week.jpg" {
        from 1 weeks to now
        width 980 height 200
        left
                graph 17 "frag" "/s" color 192 0 192,
                graph 22 "cong" "/s" color 0 192 192,
                graph 23 "iopt" "/s" color 0 0 255,
                graph 24 "csum" "/s" color 192 192 0,
                graph 25 "mism" "/s" color 255 0 0
#               others are usually all zero here
        right
                graph 15 "match" "/s" color 0 192 0
}

image "/usr/local/www/basic/pfstat/pfstat-errors_month.jpg" {
        from 1 months to now
        width 980 height 200
        left
                graph 17 "frag" "/s" color 192 0 192,
                graph 22 "cong" "/s" color 0 192 192,
                graph 23 "iopt" "/s" color 0 0 255,
                graph 24 "csum" "/s" color 192 192 0,
                graph 25 "mism" "/s" color 255 0 0
        right
                graph 15 "match" "/s" color 0 192 0
}
#######################################################
#######################################################
```

and my crontab

```
*    *    *   *   *   /usr/local/bin/pfstat -q -d /var/db/pfstat.db
10   6-19 *   *   *   /usr/local/bin/pfstat -p -d /var/db/pfstat.db
25   3    *   *   *   /usr/local/bin/pfstat -t 30 -d /var/db/pfstat.db
```


----------



## DutchDaemon (May 17, 2009)

You will have to keep numbering on, not reuse 1, 2, 3 every time. Example:


```
collect [B]1[/B] = interface "em0" pass bytes in ipv4 diff
     collect [B]2[/B] = interface "em0" pass bytes out ipv4 diff
     image "/usr/local/www/data/bandwidth_em0_day.png" {
             from 24 hours to now
             type png
             width 800 height 320
             left
                     graph [B]1[/B] bps "in" "bits/s" color 0 192 0 filled
             right
                     graph [B]2[/B] bps "out" "bits/s" color 0 0 255
     }

     collect [B]3[/B] = interface "em1" pass bytes in ipv4 diff
     collect [B]4[/B] = interface "em1" pass bytes out ipv4 diff
     image "/usr/local/www/data/bandwidth_em1_day.png" {
             from 24 hours to now
             type png
             width 800 height 320
             left
                     graph [B]3[/B] bps "in" "bits/s" color 0 192 0 filled
             right
                     graph [B]4[/B] bps "out" "bits/s" color 0 0 255
     }

     collect [B]5[/B] = interface "em0" pass bytes in ipv4 diff
     collect [B]6[/B] = interface "em0" pass bytes out ipv4 diff
     image "/usr/local/www/data/bandwidth_em0_week.png" {
             from 7 days to now
             type png
             width 800 height 320
             left
                     graph [B]5[/B] bps "in" "bits/s" color 0 192 0 filled
             right
                     graph [B]6[/B] bps "out" "bits/s" color 0 0 255
     }


     collect [B]7[/B] = interface "em1" pass bytes in ipv4 diff
     collect [B]8[/B] = interface "em1" pass bytes out ipv4 diff
     image "/usr/local/www/data/bandwidth_em1_week.png" {
             from 7 days to now
             type png
             width 800 height 320
             left
                     graph [B]7[/B] bps "in" "bits/s" color 0 192 0 filled
             right
                     graph [B]8[/B] bps "out" "bits/s" color 0 0 255
     }

     collect [B]9[/B] = global states entries
     image "/usr/local/www/data/states.png" {
             from 24 hours to now
             type png
             width 800 height 320
             left
                    graph [B]9[/B] "states" "entries" color 200 0 0 filled
     }
```

etc. Every graph _n_ needs a collect _n_.

You can use [cmd=]pfstat -vp[/cmd] and [cmd=]pfstat -vq[/cmd] for more info. I advise the use of png, much more lightweight. You can easily run -q every minute and -p every five minutes. I'm doing that on servers doing 125+ Mbit/s, and it's not even registering in 'top'.


----------



## kiranopatil (Dec 16, 2010)

Try iftop.......


----------

