Wanna see bandwidth broken down by wifi vs wired, per billing cycle

On my server I have something similar to this setup:

https://www.linkedin.com/pulse/monitoring-collectd-influxdb-grafana-alan-wen

I run ubuntu, so used the latest apt sources for influxdb and grafana, set up influxdb as a network collectd listener, and then use the network plugin on connectd on the openwrt box, to send all stats to influxdb database.

grafana can understand the syntax of influxdb for the most part - so the creation of charts generally only needs the drop down menus in the chart creation screen. The one exception is the interface statistics, as you want to turn a counter into a rate, so you manually need to enter the query value as SELECT non_negative_derivative(mean("value"),10s) from "interface_rx" ... etc, do the same for "interface_tx" too.

Thank you so much. Great setup you have there.

I have a good bit of experience with Docker so I have set up InfluxDB and Graphana on my Mac. I just need to set up CollectD now on LEDE to collect and send data to Influx.

Would you mind sharing your CollectD config? Thanks again.

To follow up to myself: Yes, it's possible in darkstat. You'd have to uncomment the network_filter option in /etc/config/darkstat and adjust the two netmasks in the statement to your configuration. Effectively it says to disregard anything that comes from and goes to the local network. I'd also recommend to use the network_netmask (again, adjusted for the local configuration) and local_only options (they have to be used in conjunction) so the hosts list in the statistics is not cluttered with the destination hosts.

darkstat also has an option to import/export database on start/stop (the import and export options), but they are not supported by the UCI config file. I'll have to look into that, but for now it doesn't backup or restore the database.

[edit] In line with the original question, I didn't find any option to adjust the "billing cycle", i.e. start-of-month, for darkstat though.

1 Like

@takimata,

I've had your solution running for about a month. And yesterday, the router (and most of the house) briefly lost power as I was trying to fix an electrical problem (not related to the router).

I checked sftp://192.168.1.1/etc/vnstat_backup.tar.gz and it looks like it's empty.

I've uploaded it to http://s000.tinyupload.com/index.php?file_id=92648105438374048422

This doesn't look good. I don't remember if I set up an automatic daily cronjob. Oh no!

Hi Hillz, I took a look at that link (https://wiki.openwrt.org/doc/howto/vnstat#method_2). The last portion (currently at the bottom of the page) is called

Add for cron and for init

It says

The below commands will add a cronjob entry that triggers a backup every 6 hours every day, if necessary adjust to an interval you feel comfortable with:

echo "* */6 * * * /etc/init.d/vnstat_backup backup" >> /etc/crontabs/root
/etc/init.d/cron restart

In terminal, I first did
ssh root@192.168.1.1
then
echo "* */6 * * * /etc/init.d/vnstat_backup backup" >> /etc/crontabs/root
and
/etc/init.d/cron restart

How can I verify that I correctly have set up automatic backups?

There is now a new lightweight daemon nlbwmon and luci-app-nlbwmon for measuring per-host traffic.
Available in master, but not yet in 17.01

EDIT:
now also in 17.01

@hnyman,

Thank you very much for your reply and adding to the advice on this thread.

Could you kindly tell me how nlbwmon and luci-app-nlmwmon compare with vnstat and the luci version of vnstat?

By the way, you said that nlbwmon is for measuring per-host traffic. Is that what I'm seeking to do -- measure per-host traffic? I'm not familiar with all these terms (e.g. host).

I had to do some terminal coding (copy-pasting) to set up cron for auto backups. With nlbwmon, is it simpler to set everything up.

Thanks again hnyman!!!

Just install it with opkg and test.
Screenshots are available in the original pull request https://github.com/openwrt/luci/pull/1259
And generic explanation in https://github.com/openwrt/packages/pull/4646

1 Like

Sorry, but what exactly is the command to install?

The installation is done like any other package:

opkg update
opkg install luci-app-nlbwmon

(that will install also nlbwmon itself)

Or use LuCI GUI to install it.

But it has a dependency to a kernel module, so if you are running a buildbot snapshot build , you may need to first flash it and then install the package right afertwards. (like all kernel related packages)

1 Like

hnyman,

thank you very much for your reply.

i updated opkg in terminal (refreshedi tried installing luci-app-nlbwmon (through terminal and luci), but it doesn't seem to be available

Unknown package 'luci-app-nlbwmon'.

I'm on LuCI lede-17.01 branch (git-17.152.82987-7f6fc16) / LEDE Reboot 17.01.2 r3435-65eec8bd5f.

I'm a real rookie when it comes to IT stuff. And it looks like getting nlbwmon to work may be harder than just running the opkg commands (or installing via Luci Gui).

Would you kindly tell me whether nlbwmon does what I need it do? (I need something to show my wifi use, and will back up that info so that a powered-off router won't be a loss). I just wanna make sure that all the effort (and for a slow-learning noob like myself, it is a lot of time and effort) will not be in vain. I just wanna make sure nlbwmon meets my needs, and does it better than vnstat.

Yeah, it is not yet available in 17.01, just like I said in my first message:

As far as I understand, the package pretty much answers your needs, as it even enables adjusting the start date of the monitoring period (billing period).

I will enquire from the author if he sees backporting this to 17.01 possible. If that is done, it could be available in 17.01 after a few days.

1 Like

@hnyman,
Thank you so much for your responses to my newbie questions. I really appreciate it a lot. Hopefully, I'll soon see light at the end of the tunnel. :slight_smile:

If I may ask an additional question about nlbwmon: Do you know if it has an easy way to set up automatic backups? I don't want to lose all the precious bandwidth info when there is something like a power outage. Thanks again.

Please look at the screenshots and read the already written messages...

From the screenshots you can see that you can define the directory where the database is stored (e.g. router flash or USB stick, instead of the default RAMdisk ) and the interval how often it is stored there.

2 Likes

Indeed nlbwmon seems like the perfect new solution to all statistic needs, all the existing ones (vnstat, darkstat, etc.) do have a shortcoming one way or another. Very, very nice.

1 Like

The author @jow has now backported it to 17.01 by himself.

Buildbot will build the packages for 17.01 in a few hours.
http://release-builds.lede-project.org/17.01/packages/grid

2 Likes

It seems like it's not of much use now anymore, but for posterity:

You can check if your cronjob exists with crontab -l. I seem to remember that cron needed enabling, but I'm not sure anymore. For good measure, I would do /etc/init.d/cron enable. And whenever a cronjob is started, it will leave a line in the system logfile.

However, if your /etc/vnstat_backup.tar.gz does actually exist, but is a zero-length file, it did fire, and something went wrong in the process. That would need some investigation.

1 Like

@hnyman
Thank you so much for requesting author @jow to backport it. I installed both luci-app-nlbwmon and bwmon through opkg, logged out of Luci and logged back in. I now see a tab called Bandwidth Monitor.

In some earlier replies, @takimata cautioned against too much (too frequent) saving/writing on flash memory, and said a backup script may be around wearing away flash memory. I still don't quite understand all that. (As a tech newbie, I know that the laptop I'm using to type to you on has an SSD and some RAM, and I'm trying to understand how a router is similar or different to a laptop or desktop computer, when it comes to memory.)

Anyway, on http://192.168.1.1/cgi-bin/luci/admin/nlbw/config (looks like https://user-images.githubusercontent.com/2528802/28720681-2d6cb6d6-73ae-11e7-908b-cbe6039ac468.png) , I do see configuration for "Commit Interval". Some preset options are

24 h -- least flash wear at the expense of data loss risk
12 h -- compromise between risk of data loss and flash wear
10 m -- frequent commits at the expense of flash wear
60 s -- commit every minute, useful for non-flash storage

I connected a USB 256MB thumbdrive to the back of the router and mounted it. In the blank that ask for Database Directory , I wrote

/mnt/sda1

Is there a way to verify that everything I've done is correct and complete?

Hi, guys ( @jow @takimata @hnyman and others) ,

Super excited to have luci-app-nlbwmon installed (succesfully, I think!).

In http://192.168.1.1/cgi-bin/luci/admin/nlbw/config#, I see

Should I make any changes in the "Local subnets" section? If so, how do I figure out what to type in there? Thanks for helping a newbie, fellow LEDErs.

Another question.

I have this:

So why is it still empty, like this:

Sat Aug 5 23:07:45 PDT 2017 UPDATE: It now looks like