Friday, May 15, 2009

» vnstat on openSUSE

vnstat is a network traffic monitor that collects the amount of data you transmit over network interfaces (typically, your Internet uplink), and can display them
  • on a terminal:
    screenshot

  • or, since version 1.7, also as graphs:
    vnstat graph
The latter can even be watched from a browser, using a CGI script. vnstat runs through a cron job at a regular interval (every 5 minutes by default) and collects network transfer statistics for selected network interfaces, to be able to give you information about daily, weekly, monthly traffic. To install and run vnstat on openSUSE, either use the 1-click install for openSUSE 11.1, openSUSE 11.0 or SLE 11, or proceed as follows:
# add the "server:monitoring" repository if needed:
zypper ar -r http://download.opensuse.org/repositories/\ server:/monitoring/openSUSE_11.1/server:monitoring.repo # (optionally adapt the URL above to match your distribution, # e.g. openSUSE_11.0 or SLE_11 instead of openSUSE_11.1) # download and refresh the repository metadata: zypper refresh # install the vnstat and vnstat-cgi packages: zypper install vnstat vnstat-cgi
That being done, simply run the following command as root to create a vnstat database for at least one of your network interfaces, obviously using whatever connection you want to collect statistics for instead of "eth0":
vnstat-create-db eth0
And we're already finished :) To see the results, give vnstat a few minutes to collect data (at least 5 minutes), and either see the results in a terminal:
vnstat
vnstat -h
Or point your favourite webbrowser at the following URL: http://localhost/vnstat Note: if the URL above doesn't work, make sure to start apache2 first, using the following command as root:
rcapache2 start

Labels: ,

4 Comments:

Blogger DimiG said...

Does `vnstat' open own web server on `localhost'? Which services is in RAM for it?

09:35  
Blogger Oliver said...

Looks very nice. Thanks for the tip.

Unfortunately I get the following error, when running the vnstat-create-db script:

/usr/bin/vnstat-create-db: vnstat-create-db: line 53: syntax error: unexpected end of file

10:31  
Blogger Loki said...

@Oliver: fixed now, just update.

@DimiG: no, it's a CGI that runs in Apache ("rcapache2 start" to start it if needed, I forgot to mention that :)), but I also added the necessary Apache configuration in the vnstat-cgi package

19:50  
OpenID dev-hands said...

Cool. Bug with permissions on /var/lib/vnstat was solved during I was writing bugreport.

It is very quick )

13:07  

Post a Comment

Links to this post:

Create a Link

<< Home