VnStat Network Monitor

Posted in Arch Linux by TuxLyn on January 25, 2013 edited on February 24, 2013
903 views

Config Icon This is simple vnstats html with cron I’m using here: http://gotux.net/stats If you would like to do similar setup, you can follow this instructions.

# pacman -S vnstat
# vnstat -u -i venet0
# nano /etc/rc.conf (and add "vnstat" to your DEAMONS="")

Prepare Nginx and Directory

Add this following function to your /etc/nginx/nginx.conf file:

server {
  server_name stats.domain.com;
  root /var/www/stats;
  index index.html;
} #stats

Create Directory and Initial Images

 mkdir /var/www/stats 

You can use this basic css stylesheet:

Then create this basic index.html file:

Run this command to create initial images:

vnstati -s -nh -i venet0 -o /var/www/stats/summary.png
vnstati -h -nh -i venet0 -o /var/www/stats/hourly.png
vnstati -d -nh -i venet0 -o /var/www/stats/daily.png
vnstati -m -nh -i venet0 -o /var/www/stats/monthly.png
vnstati -t -nh -i venet0 -o /var/www/stats/top10.png

Configure Cron

As regular user add this following line in your .bashrc file:

 export EDITOR=nano 

Then execute command “crontab -e” and add this lines:

@hourly vnstati -s -nh -i venet0 -o /var/www/stats/summary.png
@hourly vnstati -h -nh -i venet0 -o /var/www/stats/hourly.png
@hourly vnstati -d -nh -i venet0 -o /var/www/stats/daily.png
@hourly vnstati -m -nh -i venet0 -o /var/www/stats/monthly.png
@hourly vnstati -t -nh -i venet0 -o /var/www/stats/top10.png

This will automatically update your stats images hourly.

If you don’t have cron installed you can do this:

# pacman -S cronie
# systemctl start cronie

Interface Notes:
eth0, wired network interface. (Dedi)
venet0, wired network interface. (VPS)
wlan0, wireless network interface. (Wireless)

Note if you’re using new systemd on Arch Linux, you’re interfaces will be named differently please check your interface by running “ip addr” command.

You can see how this graphs will look at http://gotux.net/stats/

StatCounter WhosAmungUs FlagCounter