# [HOWTO] Network traffic monitoring with vnStat

## vpetreski

Hi,

I have two Gentoo boxes on my LAN: AMD64 as desktop and P3 as server.

P3 is connected to the internet over ADSL modem-router and has folowing services enabled: apache, proftpd, jabberd, sshd, squid, http-replicator, djbdns, rsyncd, iptables (firewall & NAT), etc.

Although I have flat-rate and don't care how much data is tranfered, somethimes I just want to know what have passed through my netwotk to the internet and vice-versa.

Typical susgestions are: mrtg, ntop, cacti and so one, but they had far too many features compared to my needs.

So, lets try vnStat!

Installing and configuring:

```

emerge vnstat

vnstat -u -i eth0

```

Optional:

```

vnstat -u -i ethX

```

where X belongs from 1..n.

Viewing your stats:

```

vnstat -u && vnstat

```

Reseting:

-r option doesn't work for me, so do the trick:

```

rm -rf /var/lib/vmstat/ethY && vnstat -u -i ethY

```

where Y belongs from 0..n.

Enable web preview with this small PHP script:

```

<html>

<head>

<title>Current Bandwidth</title>

<style type="text/css">

body {background-color:black;color:orange}

</style>

</head>

<body>

<br><br><br>

<pre>

<?php

system("vnstat -u && vnstat");

?>

</pre>

</body>

</html>

```

name it bandwidth.php and put it in /var/www/localhost/htdocs/

Now type: http://your_server/bandwidth.php in your browser.

 :Cool: 

----------

## truc

oh yeah thanks a lot, i was just looking for something like that, I'll try it as soon as I can  :Cool: 

----------

