Nlbwmon not resetting data each month

Does anybody know why nlbwmon package doesn't reset the data each month? The packages is up to date.

config nlbwmon
        option netlink_buffer_size '1572864'
        option commit_interval '12h'
        option refresh_interval '30s'
        option database_directory '/root'
        option database_generations '24'
        option database_interval '1'
        option database_limit '10000'
        option protocol_database '/usr/share/nlbwmon/protocols'
        list local_network '192.168.0.0/16'
        list local_network '172.16.0.0/12'
        list local_network '10.0.0.0/8'
        list local_network 'wwan'

By default your interval should be first of the month.

Check your config cat /etc/config/nlbwmon

The config is 1st of the month

Sorry about that. I just noticed you don’t have a persistent location to save previous databases in your config. By default, at the end of each period it will just restart a new period based on your configured database_interval.

If you want to keep each interval for history, you need to add
option database_directory 'path to persistent_storage location'

1 Like

I have that too as /flash, the folder is excluded in the flash configuration.
Data is being saved just fine, but it doesn't reset to 0 every month.

In the GUI what do you show in the drop down for select accounting period? Or ls -la /root


root@OpenWrt:~# ls -la /root
drwxr-xr-x    1 root     root          3488 Apr  1 00:00 .
drwxr-xr-x    1 root     root          3488 Jan  1  1970 ..
-rw-r-----    1 root     root          2124 Mar  8 18:30 20240201.db.gz
-rw-r-----    1 root     root          1985 Mar 31 23:00 20240301.db.gz
-rw-r-----    1 root     root          3387 Apr  3 20:00 20240401.db.gz
-rwxr-xr-x    1 root     root          5805 Jan 31 01:15 opkgscript.sh

Looks like it’s working to me. 3 periods, all created on the last of the month for the previous period - Feb/Mar/current Apr

Have your tried using the nlbw runtime to query each? See the README.md here: https://github.com/jow-/nlbwmon

It looks like it's adding it, it doesn't reset to 0

root@OpenWrt:~# nlbw -c show -t 2024-04-01
  Fam            Host (    MAC )      Layer7      Conn.   > Downld. ( > Pkts. )      Upload (   Pkts. )
IPv4    192.168.1.228 (64:16:62)        QUIC   107.70 K    88.32 GB (  74.57 M)   974.36 MB (   9.83 M)
IPv4    192.168.1.148 (b9:69:a7)       HTTPS   210.08 K    47.82 GB (  35.71 M)   421.70 MB (   3.93 M)
IPv4    192.168.1.184 (df:56:2e)       HTTPS    47.16 K    15.07 GB (  11.26 M)   376.54 MB (   6.60 M)

Each period will accumulate starting from day of a period start through day of period end. ie. April will accumulate all stats for the full period. Nlbwmon won’t report each individual days statistics separately.

That's what I want, to reset to 0 every month, but it keeps adding it every month.

You’re going to have to handle some sort of Version Control then.

On another note, you should not be writing to flash. Is your device capable of using a USB drive to save the db to?

I'm using a TP-link OnHub. I tried using a USB drive but the problem is that when the router boots with the USB inserted it doesn't want to boot, no problem otherwise. I didn't bother wasting the time, I just decided to exclude a folder from flashing and just use it. If I loose the data it's not a big deal.