Recently I installed vnstat on one of my new Ubuntu VPSs. After running for a while I checked the stats and I found nothing had been logged.

It turns out that vnstat no longer uses a cron to log the stats and instead uses daemon. The issue being this daemon is not started by default.

user@server:/$ sudo apt-get install vnstat
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
The following NEW packages will be installed
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.
Need to get 82.2kB of archives.
After this operation, 311kB of additional disk space will be used.
Get:1 maverick/universe vnstat i386 1.10-1 [82.2kB]
Fetched 82.2kB in 2s (39.0kB/s)
Selecting previously deselected package vnstat.
(Reading database ... 184841 files and directories currently installed.)
Unpacking vnstat (from .../vnstat_1.10-1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up vnstat (1.10-1) ...
 * Starting vnStat daemon vnstatd
Zero database found, exiting.

The installer attempts to start the daemon, but because there is no database the start fails.

sudo /etc/init.d/vnstat status
 * vnStat daemon is not running
sudo /etc/init.d/vnstat start
 * Starting vnStat daemon vnstatd
Zero database found, exiting.

Attempting to start the daemon has no effect. Instead you must first initialise the database.

sudo vnstat -u -i eth0
Error: Unable to read database "/var/lib/vnstat/eth0".
Info: -> A new database has been created.

After the database has been created, start the daemon and it should be successful and stats will now start being recorded.

sudo /etc/init.d/vnstat start
 * Starting vnStat daemon vnstatd
Share this post


  1. naj


  2. is there a way to have the deamon run at start up everytime?


    • Mark Davidson

      @cordoval once you’ve created the initial database using the `sudo vnstat -u -i eth0` command on system reboots the deamon should run at startup each time without any additional configuration required at least in my experience. Are you running a standard version of Ubuntu 10.04?
      If this is not happening for you then I’d try starting it manually check for errors or check your logs see if there is any details about why its not working there.

Leave a Reply

CAPTCHA (required) Time limit is exhausted. Please reload CAPTCHA.