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: ,