nyanginator / wrtbwmon-remixed

Adapted from https://code.google.com/p/wrtbwmon/. Bandwidth monitor that generates usage reports in tables and charts and provides automated quota management.
MIT License
2 stars 1 forks source link

Daily Data Calculation and Roll #1

Closed AZDavid2 closed 4 years ago

AZDavid2 commented 4 years ago

Total Used and Average Daily Total columns appear to be calculating data correctly. Today Total columns as well as Grand Total bar along the top are not adding up. Reinstalled the tool today after after seeing the discrepancy for several days. After reinstalling, received the same issue. I am running the tool from DD-WRT v3.0-r44251 std (08/27/20).

Screenshot showing usage. Being first day reinstalled expect Today Total to equal Total Used. Also, total bar along the top is not adding properly. wrtbwmon-remixed usage screenshot

nyanginator commented 4 years ago

Hi, your .db files seem to be out-of-sync. Try starting over by doing a reset:

$ /tmp/mnt/sda1/reset

If you are able to reproduce the error again, let me know what steps you took to do it.

AZDavid2 commented 4 years ago

Ran the reset. Columns are still not cooperating.

wrtbwmon-remixed usage screenshot - after reset

AZDavid2 commented 4 years ago

Is this a normal response when running the reset?

invalid number

nyanginator commented 4 years ago

I'm having trouble reproducing the error, so it's somewhat difficult for me to debug. Initially, it looks like your /tmp/usage.db and /tmp/reports/*daily.db aren't getting the correct values. It may be as simple as the USB failing on read/write (a problem I had before) ... or something else.

The Grand Total/Down/Up on the top is calculated here, which is pulling straight from /tmp/usage.db. Numbers for Today are always pulled from the /tmp/reports/*daily.db files, here and here.

Any other hints you can provide might help to pinpoint the problem:

If you want to do refresh everything manually, you can:

$ rm -rf /tmp/usage.db /tmp/reports /tmp/www/reports /tmp/www/usage.htm

And remove any previous backups made:

$ rm -rf /tmp/mnt/sda1/reports /tmp/mnt/sda1/usage.db /tmp/mnt/sda1/monthlybkup /tmp/mnt/sda1/bkup

nyanginator commented 4 years ago

Is this a normal response when running the reset?

invalid number

Ah, well that definitely seems to be [a/the] problem. The .db files are likely not getting updated correctly if the script is exiting early.

nyanginator commented 4 years ago

Do you get any output from this?

$ dmesg | head -n -1

AZDavid2 commented 4 years ago

Same invalid number message

invalid number 2

Have a brand new 16 GB USB drive showing up later today. Going to give that a try. Does it matter how the drive is formatted?

nyanginator commented 4 years ago

Huh, that's interesting indeed. I don't know if the build for your router is somehow compiled in a way that makes the head command work differently. head -n -1 appears twice in the script, so it needs to work. Maybe play around with:

$ dmesg | head -n-1 (no space) $ dmesg | head -n "-1" (quotes) $ dmesg | head -n"-1" (quotes with no space)

Try a number other than -1 and see how it behaves. All these commands work fine for me (also the r44251 build).

My drive is formatted as FAT32, but I can't imagine that or the drive itself affecting the shell. The head command should work regardless of the USB. You may want to try re-flashing or flashing a different DD-WRT build to see if was a regression in this version.

AZDavid2 commented 4 years ago

I am running DD-WRT on a Linksys WRT32x, accessing the router through a PuTTY SSH session

Tried several options to see if I could isolate a cause

No change after all three - received either "invalid number" or "unrecognized option" when running reset or unp

Following was returned after a clean install. Could this help point in a direction? clean install

Tried playing around with the commands including using a number other than -1 trying other options

AZDavid2 commented 4 years ago

Is there a way I can open the database files?

Attempted to open using SQLite but they are not being recognized as a database.

nyanginator commented 4 years ago

Looks like there's more than one shell command with issues. Guessing that this won't work for you either:

$ date -d @1599429351

I haven't found anything yet in the DD-WRT forums about this. Might be worth posting there to see if anybody else has had a similar issue. Maybe erasing NVRAM could help?

The .db files generated by the script are just text files, so you can open them with vi.

nyanginator commented 4 years ago

Found this thread. Did you upgrade to the "full featured" version?

AZDavid2 commented 4 years ago

Yes, I installed the full version ddwrt-linksys-wrt32x-webflash.bin.

Going to perform a hard reset soon to see if that works.

Entering $ date -d @1599429351 worked time

AZDavid2 commented 4 years ago

No luck after the hard reset to clear NVRAM. At a complete loss for what to try next.

nyanginator commented 4 years ago

Just spitballing some ideas here:

AZDavid2 commented 4 years ago

Ruled out PuTTY by setting up Telnet through command prompt in Windows. Receive the same command responses.

Do not see any ^M characters when running $ vi /tmp/mnt/sda1/wrtbwmon m search

Suspected a date issue so I ran the "date" command from DD-WRT. Router responded with the correct date and time. command

Going to start a thread on the DD-WRT forum to see if anyone there has ideas.

Thank you for all your continued help! Much appreciated!

nyanginator commented 4 years ago

Seems a router/DD-WRT issue and not the script.