OpenWrt Forum Archive

Topic: vnstat on kamikaze 8.09 has a bug

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I recently installed vnstat on my wl-500gp router. After install the package I got this message:

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

Great... I issued an ls /var/lib/ and the vnstat folder has been  created.

I moved forward and reboot the router. I SSHed back to the router and issue this command "vnstat" and I got this:

root@OpenWrt:~# vnstat
Error: Unable to open database directory "/var/lib/vnstat".
Make sure it exists and is at least read enabled for current user.

The vnstat folder is deleted. Why is that? What am I doing wrong?

My configuration is as follow

## VLAN configuration
config switch eth0
       option vlan0    "0 1 2 5*"      # For VOIP traffic
       option vlan1    "3 5"           # For LAN traffic
       option vlan2    "4 5"           # For WAN traffic

#### Loopback configuration
config interface loopback
       option ifname   "lo"
       option proto    static
       option ipaddr   127.0.0.1
       option netmask  255.0.0.0

#### LAN configuration
config interface lan
       #option type    bridge
       option ifname   "eth0.0"
       option proto    static
       option ipaddr   192.168.1.1
       option netmask  255.255.255.0
       option gateway  192.168.1.1
       option dns      192.168.1.1

#### WIFI configuration
config interface wifi
       #option type    bridge
       option ifname   "eth0.1"
       option proto    static
       option ipaddr   192.168.2.1
       option netmask  255.255.255.0
       option gateway  192.168.2.1
       option dns      192.168.1.1

#### WAN configuration
config interface        wan
       option ifname   "eth0.2"
       option proto    static
       option ipaddr   10.1.1.101
       option netmask  255.255.255.0
       option gateway  10.1.1.1
       option dns      10.1.1.1

Thanks for your help,
--Jude

To configure vnstat I do the followings:
vnstat -u -i eth0.2 --nick "wan"
vnstat -u -i eth0.1 --nick "wifi"
vnstat -u -i eth0.0 --nick "lan"

The results are as follow:
root@OpenWrt:~# vnstat -u -i eth0
Error: Unable to read database "/var/lib/vnstat/eth0".
Info: -> A new database has been created.

root@OpenWrt:~# vnstat -u -i eth0.2 --nick "wan"
Error: Unable to read database "/var/lib/vnstat/eth0.2".
Info: -> A new database has been created.

root@OpenWrt:~# vnstat -u -i eth0.1 --nick "wifi"
Error: Unable to read database "/var/lib/vnstat/eth0.1".
Info: -> A new database has been created.

root@OpenWrt:~# vnstat -u -i eth0.0 --nick "lan"
Error: Unable to read database "/var/lib/vnstat/eth0.0".
Info: -> A new database has been created.

ls /var/lib/vnstat shows all the interfaces are and collecting data
eth0.0  eth0.1  eth0.2

Now when I reboot the router all these interfaces are gone.

Use /etc/config/vnstat for the configuration.

Yanira,

Thanks much for the response. I'm not sure I understand you ciorrectly. Here is how I setup /etc/config/vnstat:

config interface                eth0.2
        option enabled          0
        option remote_host      localhost
        option remote_path      /var/www/vnstat

config interface               eth0.1
       option enabled          0
       option remote_host      localhost         
       option remote_path      /var/www/vnstat                 

config interface               eth0.0
       option enabled          0
       option remote_host      localhost       
       option remote_path      /var/www/vnstat

How would that work in term of maintaining the interfaces on /var/lib/vnstat? It seems the problem is still persisting. I create the interface to mintor  vnstat -u -i eth0.0 and so on

root@OpenWrt:~# ls /var/lib/vnstat
eth0.0  eth0.1  eth0.2

reboot the router and the same thing happen (var/lib/vnstat empty):

root@OpenWrt:~# vnstat
No database found, nothing to do. Use --help for help.

A new database can be created with the following command:
    vnstat -u -i eth0

Replace 'eth0' with the interface that should be monitored.

The following interfaces are currently available:
    lo eth0 eth0.0 eth0.1 eth0.2

Thanks...

(Last edited by jude1747 on 3 Jun 2009, 12:53)

There is an init script for vnstat:

root@OpenWrt:~# /etc/init.d/vnstat enable
root@OpenWrt:~# /etc/init.d/vnstat start

Look at the vnstat init script (line 38). Then you know what's going on.

Btw. I'll write an LuCI WebUI application for vnstat in the next days.

EDIT: Don't forget to set option enabled 1 for each interface section.

(Last edited by Yanira on 3 Jun 2009, 13:08)

Yanira,

I value your help a lot and thank you very much. With all dues respect I'm still unable to resolve the problem. Here are the steps I followed:

0) Flashing my router wl-500gp with openwrt-brcm-2.4-squashfs.trx taken from downloads.openwrt.org/snapshots/trunk/brcm47xx
1) Install vnstat
2) Configure vnstat (/etc/config/vnstat)
config interface                eth0.2
        option enabled          1
        option remote_host      127.0.0.1
        option remote_path      /www/vnstat

config interface               eth0.1
       option enabled          1
       option remote_host      127.0.0.1
       option remote_path      /www/vnstat

config interface               eth0.0
       option enabled          1
       option remote_host      127.0.0.1
       option remote_path      /www/vnstat
3) Create the the interface to mintor  vnstat -u -i eth0.0 and so on

root@OpenWrt:~# ls /var/lib/vnstat
eth0.0  eth0.1  eth0.2

4) I do the followings
root@OpenWrt:~# /etc/init.d/vnstat enable
root@OpenWrt:~# /etc/init.d/vnstat start

5) Reboot the router
6) Issue vnstat and  check the var/lib/vnstat  is empty

I don't know what I need to do now to fix the problem.

Thank you so much for your invaluable help.

(Last edited by jude1747 on 3 Jun 2009, 13:59)

/var is a symlink to /tmp, so of course if you reboot the folder is going to be gone.

That said, the current init script and uci config can be and are only used to download a backup database from an http server.

You could grab the vnstat.conf from the original tarball, put it in /etc/vnstat.conf, and change DatabaseDir to point to a non-tmpfs filesystem.

Yanira wrote:

Btw. I'll write an LuCI WebUI application for vnstat in the next days.

You might want to wait until https://dev.openwrt.org/ticket/4989 gets checked in.

Guys,

Thank you very much I have resolved the problem. For the benefit of others Here is what I have done:

6) Using the steps above (following step 5)
7) Login to the router
8) mkdir -p /jffs/vnstat
9) Download the latest version of vnstat (http://humdi.net/vnstat/vnstat-1.7.tar.gz)
10) Untar it and grab vnstat.conf from vnstat1.7/cfg
11) Copy vnstat.conf to /etc on the router
12) Open it and change DatabaseDir "/jffs/vnstat"
13) Edit /etc/crontabs/root like so:
0-55/5 * * * *    if [ -x /usr/bin/vnstat ] && [ `ls /jffs/vnstat | wc -l` -ge 1 ]; then /usr/bin/vnstat -u; fi
14) Create the interface that you want vnstat to monitor like so:
vnstat -u -i eth0.2 --nick "wan"
15) You should see the database for eth0.2 under  /jffs/vnstat
16) Reboot and everything should be there

Note: I'm not sure if creating /jffs/vnstat is right place to use.

As always thank you both Yanira and Swalker

How would I know when https://dev.openwrt.org/ticket/4989 is checked?

Thanks,
--Jude1747

(Last edited by jude1747 on 4 Jun 2009, 03:53)

The discussion might have continued from here.