openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

vnstat2: configuration of network interfaces is not respected on router reboot #16986

Open kayfab3 opened 3 years ago

kayfab3 commented 3 years ago

Maintainer: @janh @jow @xdarklight @diizzyy Environment: mvebu, OpenWrt 21.02.x, vnstat2 2.7-1, vnstat 1.18-2

Description: As of OpenWrt 21.02 vnstat and vnstat2 packages do not respect user defined configuration of interfaces. Database configuration does not survive a router reboot. After each router reboot, configuration of interfaces set either manually or configured by /etc/config/vnstat and /etc/vnstat.conf is not honored, the previous database config is purged, and reloaded from some unspecified default.

To clarify, this bug effects packages vnstat and vnstat2 since Openwrt 21.02.

Installing and removing either package multiple times, and retesting, returns the same result.

This bug was not present in 18.06 or 19.07. In previous OpenWrt releases /etc/config/vnstat and /etc/vnstat.conf were respected. Interface configuration used to survive a reboot.

Normal behavior should be that the user defined interface configuration (what interfaces you want to monitor) survives a reboot or power cycle, but the recorded traffic data per interface reset to zero.

Steps-to-reproduce

The user guide on openwrt.org was followed for install and initial configuration of vnstat.

https://openwrt.org/docs/guide-user/services/network_monitoring/vnstat?s[]=vnstat

Once vnstat (or vnstat2) is installed via luci or okpg and configured we can verify the configuration and current database.

## vnstat2
opkg update
opkg install vnstat2 vnstati2 luci-app-vnstat2

or

## vnstat
opkg update
opkg install vnstat vnstati luci-app-vnstat

Let's verify files and the configuration


****@****:~$ ssh root@192.168.1.1
root@192.168.1.1's password: 

BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 21.02.1, r16325-88151b8303
 -----------------------------------------------------
root@OpenWrt:~# ls /etc
TZ                    fw_env.config         opkg                  shinit
adblock               group                 opkg.conf             ssl
banner                hosts                 os-release            sysctl.conf
banner.failsafe       hotplug-preinit.json  passwd                sysctl.d
board.d               hotplug.d             ppp                   sysupgrade.conf
board.json            hotplug.json          preinit               uci-defaults
capabilities          init.d                profile               udhcpc.user
config                inittab               protocols             udhcpc.user.d
crontabs              iproute2              rc.button             uhttpd.crt
device_info           localtime             rc.common             uhttpd.key
diag.sh               luci-uploads          rc.d                  urandom.seed
dnsmasq.conf          modules-boot.d        rc.local              vnstat.conf
dropbear              modules.d             resolv.conf           vnstat.conf-opkg
ethers                mtab                  services
firewall.user         openwrt_release       shadow
fstab                 openwrt_version       shells
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/vnstat.conf | grep -B 2 -A 1 'pppoe-wan'

# default interface (leave empty for automatic selection)
Interface "pppoe-wan"

root@OpenWrt:~# cat /etc/vnstat.conf-opkg | grep -B 2 -A 1 'Interface "'

# default interface (leave empty for automatic selection)
Interface ""

root@OpenWrt:~# ls /etc/config
adblock       dropbear      network       ubootenv      vnstat
adblock-opkg  firewall      rpcd          ucitrack      vnstat-opkg
dhcp          luci          system        uhttpd        wireless
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/vnstat

config vnstat
    list interface 'pppoe-wan'

root@OpenWrt:~# cat /etc/config/vnstat-opkg
config vnstat
#   list interface      br-lan
root@OpenWrt:~#
root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: pppoe-wan
root@OpenWrt:~#
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit)

Here we can see (vnstat --dbiflist) that after re-installation the only inteface listed in the database is 'pppoe-wan'. The existing configuration /etc/vnstat.conf and /etc/config/vnstat appears to initially be respected. Vnstat shows various interfaces available (vnstat --iflist)

Let's verify via the installed luci-app-vnstat2 that no interfaces but 'pppoe-wan' are displayed and configured in the database. You may need to manually copy and paste these links if vnstat does not immediately appear under Luci > status > vnStat Traffic Monitor

https://192.168.1.1/cgi-bin/luci/admin/status/vnstat2

vnstat_before_reboot

http://192.168.1.1/cgi-bin/luci/admin/status/vnstat2/config

vnstat_before_reboot2

Reboot the router via luci or commandline and check configuration


root@OpenWrt:~# reboot
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.
****@****:~$ 
****@****:~$ ssh root@192.168.1.1
root@192.168.1.1's password: 

BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 21.02.1, r16325-88151b8303
 -----------------------------------------------------
root@OpenWrt:~# cat /etc/vnstat.conf | grep -B 2 -A 1 'pppoe-wan'

# default interface (leave empty for automatic selection)
Interface "pppoe-wan"

root@OpenWrt:~# cat /etc/config/vnstat

config vnstat
    list interface 'pppoe-wan'

root@OpenWrt:~# cat /etc/config/vnstat-opkg
config vnstat
#   list interface      br-lan

We can see that 'pppoe-wan' is still defined in /etc/vnstat.conf and /etc/config/vnstat. The dupe config auto-renamed as vnstat-opkg on re-installation has its config line commented out.

What does the actual database show ?


root@OpenWrt:~#
root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: br-lan eth0 lan1 lan2 lan3 lan4 wan wlan0 wlan1
root@OpenWrt:~#
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit) 

Here we can see (vnstat --dbiflist) that after a router reboot the 'pppoe-wan' interface was purged from the database. vnstat is not respecting 'pppoe-wan' configured in /etc/vnstat.conf and /etc/config/vnstat

Again let's verify the output via Luci

http://192.168.1.1/cgi-bin/luci/admin/status/vnstat2

vnstat2_after_reboot1

vnstat2_after_reboot1a

http://192.168.1.1/cgi-bin/luci/admin/status/vnstat2/config

vnstat2_after_reboot2

vnstat2_after_reboot2a

Aftermath

A manual cleanup and reset to correct settings will fix the issue but user configuration still will not survive a reboot as /etc/vnstat.conf and /etc/config/vnstat are not respected.


root@OpenWrt:~# vnstat --force --remove -i br-lan
Interface "br-lan" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i eth0
Interface "eth0" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan1
Interface "lan1" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan2
Interface "lan2" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan3
Interface "lan3" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan4
Interface "lan4" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wan
Interface "wan" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wlan0
Interface "wlan0" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wlan1
Interface "wlan1" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --dbiflist
Database is empty.root
root@OpenWrt:~# vnstat --add -i pppoe-wan
Adding interface "pppoe-wan" for monitoring to database...
janh commented 3 years ago

Can you show the system log entries related to vnStat?

Maybe the issue here is that the pppoe-wan interface doesn't exist yet when vnStat is started. In that case, https://github.com/openwrt/packages/pull/16950? should at least fix the part where other interfaces get monitored instead, but pppoe-wan probably still won't work.

By the way, there is no need co configure any interface in /etc/vnstat.conf. That option doesn't control which interfaces get monitored, it just specifies the default interface that is shown in the vnstat and vnstati tools.

kayfab3 commented 3 years ago

Hi @janh

I can't see you on Libera.

This is what the systemlog shows via Luci after installation/re-install of vnstat2

Tue Oct 26 13:47:09 2021 daemon.info vnstatd[3870]: Config: UpdateInterval has been reset to 20 seconds in order to ensure correct counter rollover detection at 1000 Mbit.
Tue Oct 26 13:47:09 2021 daemon.info vnstatd[3870]: Info: vnStat daemon 2.7 started. (pid:3870 uid:0 gid:0 64-bit)
Tue Oct 26 13:47:09 2021 daemon.info vnstatd[3870]: Info: Monitoring (1): pppoe-wan (1000 Mbit)

If the router is rebooted, this disappears since the log is in RAM.

After reboot the log does not show new vnstat messages in the system log

janh commented 3 years ago

After reboot the log does not show new vnstat messages in the system log

There should be at least a Info: vnStat daemon X.Y started. message. The log info would be useful to determine if the actual issue matches what I suspect.

But I'll also try to reproduce this myself, so I can work on a fix.

kayfab3 commented 3 years ago

Hi @janh

I've included more below along with comments. Hopefully this helps.

There appears to be an INIT script making changes which are not recorded by the syslog on reboot.

Additionally there appear to be a few additional bugs

...

BASELINE: vnstat2 is installed and configured to only monitor pppoe-wan

root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: pppoe-wan
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit) 
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/vnstat.conf | grep -B 2 -A 1 'pppoe-wan'

# default interface (leave empty for automatic selection)
Interface "pppoe-wan"

root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/vnstat

config vnstat
    list interface 'pppoe-wan'

root@OpenWrt:~# cat /etc/config/vnstat-opkg
config vnstat
#   list interface      br-lan

Looks good, ok let's reboot and verify no changes

The current syslog in RAM will be cleared on reboot.

root@OpenWrt:~# 
root@OpenWrt:~# reboot
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.
anon@SATURNUS:~$ ssh root@192.168.1.1
root@192.168.1.1's password: 

BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 21.02.1, r16325-88151b8303
 -----------------------------------------------------
root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: br-lan eth0 lan1 lan2 lan3 lan4 wan wlan0 wlan1
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit) 

We observe that silent changes happen to the vnstat database after reboot during initialization

The new syslog after reboot did not record:

root@OpenWrt:~# 
root@OpenWrt:~# logread | grep "Wed Oct 27.*vnstatd"
root@OpenWrt:~# 

Let's remove the unwanted interfaces and cleanup a mess created by an unknown INIT script

root@OpenWrt:~# 
root@OpenWrt:~# vnstat --force --remove -i br-lan
Interface "br-lan" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i eth0
Interface "eth0" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan1
Interface "lan1" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan2
Interface "lan2" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan3
Interface "lan3" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i lan4
Interface "lan4" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wan
Interface "wan" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wlan0
Interface "wlan0" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# vnstat --force --remove -i wlan1
Interface "wlan1" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --dbiflist
Database is empty.
root@OpenWrt:~# vnstat --add -i pppoe-wan
Adding interface "pppoe-wan" for monitoring to database...

Restart the vnStat daemon if it is currently running in order to start monitoring "pppoe-wan".

Ok let's see if syslog recorded these vnstatd database changes

root@OpenWrt:~# 
root@OpenWrt:~# logread | grep 'Wed Oct 27.*vnstatd'
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wlan1" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wlan0" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wan" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan4" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan3" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan2" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan1" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "eth0" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "br-lan" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Nothing to monitor
Wed Oct 27 09:22:50 2021 daemon.info vnstatd[2206]: Info: Monitoring (1): pppoe-wan (1000 Mbit)
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: pppoe-wan
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit) 

vnstatd started monitoring pppoe-wan without a restart command

To be thorough let's go through the proper steps

root@OpenWrt:~# /etc/init.d/vnstat help
Syntax: /etc/init.d/vnstat [command]

Available commands:
    start           Start the service
    stop            Stop the service
    restart         Restart the service
    reload          Reload configuration files (or restart if service does not implement reload)
    enable          Enable service autostart
    disable         Disable service autostart
    enabled         Check if service is started on boot
    running         Check if service is running
    status          Service status
    trace           Start with syscall trace

root@OpenWrt:~# /etc/init.d/vnstat status
running
root@OpenWrt:~# /etc/init.d/vnstat enable
root@OpenWrt:~# /etc/init.d/vnstat restart
root@OpenWrt:~# 
root@OpenWrt:~# logread | grep 'Wed Oct 27.*vnstatd'
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wlan1" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wlan0" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "wan" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan4" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan3" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan2" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "lan1" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "eth0" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Removing interface "br-lan" from update list.
Wed Oct 27 09:20:00 2021 daemon.info vnstatd[2206]: Info: Nothing to monitor
Wed Oct 27 09:22:50 2021 daemon.info vnstatd[2206]: Info: Monitoring (1): pppoe-wan (1000 Mbit)
Wed Oct 27 09:26:57 2021 daemon.info vnstatd[2206]: Info: SIGTERM received, exiting.
Wed Oct 27 09:32:02 2021 daemon.info vnstatd[5565]: Config: UpdateInterval has been reset to 20 seconds in order to ensure correct counter rollover detection at 1000 Mbit.
Wed Oct 27 09:32:02 2021 daemon.info vnstatd[5565]: Info: vnStat daemon 2.7 started. (pid:5565 uid:0 gid:0 64-bit)
Wed Oct 27 09:32:02 2021 daemon.info vnstatd[5565]: Info: Monitoring (1): pppoe-wan (1000 Mbit)

Looks good, ok let's reboot and verify no changes

The current syslog in RAM will be cleared on reboot.

root@OpenWrt:~# 
root@OpenWrt:~# reboot
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.
anon@SATURNUS:~$ ssh root@192.168.1.1
root@192.168.1.1's password: 

BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 21.02.1, r16325-88151b8303
 -----------------------------------------------------
root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: br-lan eth0 lan1 lan2 lan3 lan4 wan wlan0 wlan1

Again we confirm that silent changes are recorded to the vnstat database after reboot during initialization

Again we confirm the new syslog after reboot does not contain:

root@OpenWrt:~#
root@OpenWrt:~# logread | grep "Wed Oct 27.*vnstatd"
root@OpenWrt:~# 

Let's uninstall vnstat2 packages

root@OpenWrt:~# opkg remove luci-app-vnstat2 vnstati2 vnstat2
Removing package luci-app-vnstat2 from root...
Removing package vnstati2 from root...
Removing package vnstat2 from root...
Not deleting modified conffile /etc/config/vnstat.
Not deleting modified conffile /etc/vnstat.conf.
root@OpenWrt:~# 

The syslog does not record the uninstall of vnstat2

root@OpenWrt:~# logread | grep "Wed Oct 27.*vnstatd"
Wed Oct 27 09:51:58 2021 daemon.info vnstatd[2231]: Info: SIGTERM received, exiting.
root@OpenWrt:~# 

Re-install vnstat2 vnstati2 luci-app-vnstat2

root@OpenWrt:~# opkg update
Downloading https://downloads.openwrt.org/releases/21.02.1/targets/mvebu/cortexa9/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/releases/21.02.1/targets/mvebu/cortexa9/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/base/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/base/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/luci/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/routing/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/telephony/Packages.sig
Signature check passed.
root@OpenWrt:~# 
root@OpenWrt:~# opkg install vnstat2 vnstati2 luci-app-vnstat2
Installing vnstat2 (2.7-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/packages/vnstat2_2.7-1_arm_cortex-a9_vfpv3-d16.ipk
Installing vnstati2 (2.7-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/packages/vnstati2_2.7-1_arm_cortex-a9_vfpv3-d16.ipk
Installing luci-app-vnstat2 (git-20.332.74200-03c77da) to root...
Downloading https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/luci/luci-app-vnstat2_git-20.332.74200-03c77da_all.ipk
Configuring vnstat2.
Configuring vnstati2.
Configuring luci-app-vnstat2.
Collected errors:
 * resolve_conffiles: Existing conffile /etc/vnstat.conf is different from the conffile in the new package. The new conffile will be placed at /etc/vnstat.conf-opkg.
 * resolve_conffiles: Existing conffile /etc/config/vnstat is different from the conffile in the new package. The new conffile will be placed at /etc/config/vnstat-opkg.

Re-check of syslog shows an entry for vnstat2 installation

root@OpenWrt:~# logread | grep "Wed Oct 27.*vnstatd"
Wed Oct 27 09:51:58 2021 daemon.info vnstatd[2231]: Info: SIGTERM received, exiting.
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Config: UpdateInterval has been reset to 20 seconds in order to ensure correct counter rollover detection at 1000 Mbit.
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Info: vnStat daemon 2.7 started. (pid:3998 uid:0 gid:0 64-bit)
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Info: Monitoring (10): wlan1 (1000 Mbit) wlan0 (1000 Mbit) wan (100 Mbit) pppoe-wan (1000 Mbit) lan4 (1000 Mbit) lan3 (1000 Mbit) lan2 (1000 Mbit) lan1 (1000 Mbit) eth0 (1000 Mbit) br-lan (1000 Mbit)

The syslog implies that vnstatd read /etc/config/vnstat and added pppoe-wan on re-install, but did not purge the other unauthorized interfaces silently added by an unknown INIT script on startup after reboot

A database check shows pppoe-wan was not added

root@OpenWrt:~# vnstat --dbiflist
Interfaces in database: br-lan eth0 lan1 lan2 lan3 lan4 pppoe-wan wan wlan0 wlan1
root@OpenWrt:~# 
root@OpenWrt:~# vnstat --iflist
Available interfaces: pppoe-wan wlan1 wan (100 Mbit) lan1 (1000 Mbit) br-lan lan4 (1000 Mbit) wlan0 eth0 (1000 Mbit) lan2 (1000 Mbit) lan3 (1000 Mbit) 
root@OpenWrt:~#

This is strange, let's check syslog again

root@OpenWrt:~# logread | grep "Wed Oct 27.*vnstatd"
Wed Oct 27 09:51:58 2021 daemon.info vnstatd[2231]: Info: SIGTERM received, exiting.
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Config: UpdateInterval has been reset to 20 seconds in order to ensure correct counter rollover detection at 1000 Mbit.
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Info: vnStat daemon 2.7 started. (pid:3998 uid:0 gid:0 64-bit)
Wed Oct 27 09:55:01 2021 daemon.info vnstatd[3998]: Info: Monitoring (10): wlan1 (1000 Mbit) wlan0 (1000 Mbit) wan (100 Mbit) pppoe-wan (1000 Mbit) lan4 (1000 Mbit) lan3 (1000 Mbit) lan2 (1000 Mbit) lan1 (1000 Mbit) eth0 (1000 Mbit) br-lan (1000 Mbit)

Ok very strange, let's check output from luci (pppoe-wan is actually there)

https://192.168.1.1/cgi-bin/luci/admin/status/vnstat2

T2_vnstat2_after_reboot1

T2_vnstat2_after_reboot1a

https://192.168.1.1/cgi-bin/luci/admin/status/vnstat2/config

T2_vnstat2_after_reboot2

T2_vnstat2_after_reboot2a

janh commented 3 years ago

OK, here are some details which may explain what happens here:

kayfab3 commented 3 years ago

Thanks

My understanding is that interfaces declared in /etc/config/vnstat are read by vnstat to create a database in RAM on launch of vnstatd ?

I apologize, maybe my understanding of vnStat is incorrect, it seems like the easiest solution to the NAND flash wear writes issue is a config file effectively WORM in nature (rarely changes).

I'm not sure what code or init scripts for vnstat and vnstat2 changed between Openwrt 19.07 and 21.02, all I know is the program behavior changed by not loading pppoe-wan after a router reboot.

Hopefully a fix can be backported to the 21.02.1 package repo.

The issues with logging I was observing earlier today were really strange. No idea if it was a vnstatd issue or syslog reporting, but some messages would show up one time and not another.

janh commented 3 years ago

@kayfab3: Can you try the fix from the linked pull request?

kayfab3 commented 3 years ago

@janh are you on Libera?

I don't have a buildsystem setup and tbh have limited experience. I see that the fix was pushed into master. It does not look like a new package was built and backported into the 21.02.1 package repo based on timestamps and pkg version.

janh commented 3 years ago

I don't have a buildsystem setup and tbh have limited experience. I see that the fix was pushed into master. It does not look like a new package was built and backported into the 21.02.1 package repo based on timestamps and pkg version.

You are right that the fix isn't backported to 21.02 at this time. I'll still have to look into this.

In the meantime you could try the vnStat packages from master. As long as you only download and install the two vnStat packages (and nothing else), this should be fine. (In general, installing packages from another release is a bad idea though!)

These two packages should be the right ones for your device: https://downloads.openwrt.org/snapshots/packages/arm_cortex-a9_vfpv3-d16/packages/vnstat2_2.8-3_arm_cortex-a9_vfpv3-d16.ipk https://downloads.openwrt.org/snapshots/packages/arm_cortex-a9_vfpv3-d16/packages/vnstati2_2.8-3_arm_cortex-a9_vfpv3-d16.ipk

kayfab3 commented 3 years ago

@janh ran into a small problem when installing the vnstat2 binary

root@OpenWrt:~# opkg install /tmp/vnstat2_2.8-3_arm_cortex-a9_vfpv3-d16.ipk
Installing vnstat2 (2.8-3) to root...
Configuring vnstat2.
Error relocating /usr/bin/vnstat: __mktime64: symbol not found
Error relocating /usr/bin/vnstat: __fstat_time64: symbol not found
Error relocating /usr/bin/vnstat: __localtime64_r: symbol not found
Error relocating /usr/bin/vnstat: __stat_time64: symbol not found
Error relocating /usr/bin/vnstat: __time64: symbol not found
Error relocating /usr/bin/vnstat: __gettimeofday_time64: symbol not found
Error relocating /usr/bin/vnstat: __localtime64: symbol not found
Collected errors:
 * resolve_conffiles: Existing conffile /etc/vnstat.conf is different from the conffile in the new package. The new conffile will be placed at /etc/vnstat.conf-opkg.
 * resolve_conffiles: Existing conffile /etc/config/vnstat is different from the conffile in the new package. The new conffile will be placed at /etc/config/vnstat-opkg.
root@OpenWrt:~# opkg install /tmp/vnstati2_2.8-3_arm_cortex-a9_vfpv3-d16.ipk
Installing vnstati2 (2.8-3) to root...
Configuring vnstati2.
root@OpenWrt:~# opkg install /tmp/luci-app-vnstat2_git-21.223.26753-57f325a_all.ipk
Installing luci-app-vnstat2 (git-21.223.26753-57f325a) to root...
Configuring luci-app-vnstat2.
root@OpenWrt:~# vnstat --dbiflist
Error relocating /usr/bin/vnstat: __mktime64: symbol not found
Error relocating /usr/bin/vnstat: __fstat_time64: symbol not found
Error relocating /usr/bin/vnstat: __localtime64_r: symbol not found
Error relocating /usr/bin/vnstat: __stat_time64: symbol not found
Error relocating /usr/bin/vnstat: __time64: symbol not found
Error relocating /usr/bin/vnstat: __gettimeofday_time64: symbol not found
Error relocating /usr/bin/vnstat: __localtime64: symbol not found
root@OpenWrt:~# 
janh commented 3 years ago

ran into a small problem when installing the vnstat2 binary

It looks like there was a switch to 64-bit time values with the musl update to 1.2.2, and the vnstat binary from master is incompatible with 21.02 because of this (I did a quick test before the recommendation in my last message, but I only tested on a 64-bit platform where this issue doesn't exist).

In that case, the best solution is probably to wait for a backport. You could manually install the hotplug script from the fix (you just need to put it into /etc/hotplug.d/iface), but the issue that all other interfaces are also monitored would remain without a patched vnstat binary.

kayfab3 commented 3 years ago

ok, thanks

I'm not familiar with the timeline on backports. How long does that usually take or should I just assume it will land in 21.02.2 in a few months

janh commented 3 years ago

I'm not familiar with the timeline on backports. How long does that usually take or should I just assume it will land in 21.02.2 in a few months

As far as I know, individual packages are updated regularly, so you could just update vnstat via opkg after the backport, even before the next point release. I'll try to open a pull request for 21.01 in the next few days.

kayfab3 commented 3 years ago

@janh

Sorry to ask, are you still going to submit a vnstat2 pull request for 21.02.1?

It doesn't look like the vnstat2 packages updated

https://downloads.openwrt.org/releases/21.02.1/packages/arm_cortex-a9_vfpv3-d16/packages/

kayfab3 commented 2 years ago

@janh

Haven't heard or seen an update. Thought I would follow up one more time before giving up. :(