Despite the fact that it’s a command-line based tool (but extremely easy to use!) ‘vnstat’ is one of my favorite tools for monitoring the bandwidth usage of network connections. Now I’ve written about it already (under Ubuntu) but because the installation is a bit hectic under openSUSE 12.2, I decided to write about how to install and configure it properly in openSUSE.
Firstly, it is located in a different repository called ‘server monitoring’ in openSUSE, so first we have to add it. Secondly unlike in Ubuntu, openSUSE does not let vnstat’s service to be run from the background and start monitoring your networks.
So you either have to create a database for your preferred network interface manually or can just enable its system service (daemon), which is the most easiest, as a fix. So here it goes.
Enabling the ‘server monitoring’ repository.
If you use the latest version of openSUSE 12.2, then enter the below command in your Terminal.
sudo zypper addrepo -r http://download.opensuse.org/repositories/server:/monitoring/openSUSE_12.2/server:monitoring.repo
For the openSUSE 12.1 users, use the below one instead.
sudo zypper addrepo -r http://download.opensuse.org/repositories/server:/monitoring/openSUSE_12.1/server:monitoring.repo
If you use openSUSE 11.4, then use the below one.
sudo zypper addrepo -r http://download.opensuse.org/repositories/server:/monitoring/openSUSE_11.4/server:monitoring.repo
Step 2: Then enter the below command to install ‘vnstat’.
sudo zypper install vnstat
Step 3: Now I’m using openSUSE 12.2 and don’t know if in other versions you have to configure ‘vnstat’ manually too (no need in Ubuntu). If for some reason few seconds after installing, ‘vnstat’ is not showing your network bandwidth usage, then you might have to configure it manually.
Step 4: So to enable the system service of ‘vnstat’ (which should solve the issue) then first search for ‘system services’ in the start menu and launch the ‘system service editor’ tool.
Step 5: Then scroll down a bit and find a service called ‘vnstatd’ as shown below.
Once you’ve found it, select it and click on the ‘Enable’ button. Click ‘OK’ to the next message that you get (make sure it says something like ‘returned success (0) …’). And then click on the other ‘OK’ button on the right bottom side and then choose ‘Yes’ to the next message to confirm.
That’s it. From now on you should be able to view your network usage by simply typing ‘vnstat’ on your Terminal window.
If however, even after doing all that and once entered ‘vnstat’ you got an error saying something like …
No database found, nothing to do. Use --help for help …
Step 6: Then perhaps you’ll have to manually create a database for your network interfaces. For example, if you want ‘vnstat’ to monitor your Wi-Fi connection then enter the below command to create a database for that (remember, you only have to create a database once).
sudo vnstat-create-db wlan0
If you have a wired (Network card) connection, then enter the below command to create a database.
sudo vnstat-create-db eth0
Then wait for few seconds (about 30-35 seconds) and issue ‘vnstat’ command and you should see an output as shown in the first screenshot.
Ho to change the update interval?
By default, ‘vnstat’ updates network traffic data within an interval of 30 seconds. But if that’s not fast enough for you, then you can easily change that. For that enter the below command in your Terminal.
sudo nano /etc/vnstat.conf
This should open the main configuration file of ‘vnstat’ in an editor. Now scroll down and find a line that says ‘UpdateInterval 30′. Simply replace ’30’ with the amount of seconds that you want ‘vnstat’ to update its database (don’t change anything else) as shown below.
Once that’s done, press ‘Ctrl’ + ‘x’ keys and when asked, type ‘y’ and then press ‘Enter’ to save changes permanently. That’s it.
If you want additional info on how to use it to monitor only certain network interface and few other options, then please refer to its manual by using the below command.
Or you can read my previous review of it as it contain few main commands that you can use. Good luck.