After installing vnstat to keep an eye on server IN and OUT traffic on a Debian Squeeze server. I used the usual:
debian:~# vnstat -u -i eth0
In order to generate the initial database for the ethernet interface used by vnstat to generate its statistics.
However even though /var/lib/vnstat/eth0 got generated with above command statistics were not further generated and trying to check them with command:
debian:~# vnstat --days
Returned the error message:
eth0: Not enough data available yet.
To solve the eth0: Not enough data available yet. message I tried completely removing vnstat package by purging the package e.g.:
debian:~# apt-get --yes remove vnstat
...
debian:~# dpkg --purge vnstat
...
Even though dpkg –purge was invoked /var/lib/vnstat/ refused to be removed since it contained vnstat’s db file eth0
Therefore I deleted by hand before installing again vnstat:
debian:~# rm -rf /var/lib/vnstat/
Tried installing once again vnstat “from scratch”:
debian:~# apt-get install vnstat
...
After that I tried regenerating the vnstat db file eth0 once again with vnstat -u -i eth0 , hoping this should fix the error but it was no go and after that the error:
debian:~# vnstat --hours
eth0: Not enough data available yet.
persisted.
I checked in Debian bugs mailing lists and I found, some people complaining about the same issue with some suggsetions on how the error can be work arouned, anyways none of the suggestions worked for me.
Being irritated I further removed / purged once again vnstat and decided to give it a try by installing vnstat from source
As of time of writting this article, the latest stable vnstat version is 1.11 .
Therefore to install vnstat from source I issued:
debian:~# cd /usr/local/src
debian:/usr/local/src# wget http://humdi.net/vnstat/vnstat-1.11.tar.gz
...
debian:/usr/local/src# tar -zxvvf vnstat-1.11.tar.gz
debian:/usr/local/src# cd vnstat-1.11
debian:/usr/local/src/vnstat-1.11# make & make all & make install
debian:/usr/local/src/vnstat-1.11# cp examples/vnstat.cron /etc/cron.d/vnstat
debian:/usr/local/src/vnstat-1.11# vnstat -u -i eth0
Error: Unable to read database "/var/lib/vnstat/eth0".
Info: -> A new database has been created.
As a last step I put on root crontab to execute:
debian:~# crontab -u root -e
*/5 * * * * /usr/bin/vnstat -u >/dev/null 2>&1
This line updated vnstat db eth0 database, every 5 minutes. After the manual source install vnstat works, just fine 😉