Release vnStat network traffic monitor


hmc

Active Member
Joined
Dec 19, 2011
Messages
787
Location
Bavaria, Germany
Hi guys,


you may test my new vnStat PND:


http://www.hermocom.com/en/downloads/openpandora/vnStat-Installer/


vnStat is a network traffic monitor. This is useful, if you connect to the Internet using a (USB) 3G modem or something like that and if you have a data plan with some kind of volume limit. Using vnStat you can monitor the data volume transfered over the corresponding network interface.


A typical kind of data plan here in Germany is the so-called "flat rate", whic is no real flat rate, but after e.g. 500MB or 1GB of transfered data volume connection speed will be limited to virtually zero. Keeping an eye on transfered data volume is good to prevent surprises.


The PND installs the vnStat daemon and utility in the system. Afterwards you may delete the PND.


Using the PND you can later also uninstall the daemon and utility again.


Besides the status display, vnStat also has a live mode, which is currently only available on the command line, which lets you observe data volume live during the transfer.


If there are problems or if you have suggestions for improvements, please post them here.


Once issues are sorted out and - maybe - improvements are implemented and tested, I will put the PND into the Repo.


Thanks,


Daniel
 
Tested the new version. Works fine.


One thought: I've been paying attention to the output of vnstat and I noticed that by default the statistics are being updated every 5 minutes (300 seconds). So there is no need to call "watch -n 1", which seems to be a bit overkill to me anyway. If you do not change the vnstat.conf, then you can set "watch -n 300". You can also trigger an update by using the "-u"-parameter, but that must be done as root unless the rights of the database-dirs/files are changed. I don't really see a need for this.


When lookin at vnstat.conf I noticed different poll-times. I'm not sure so far what the difference is between "UpdateInterval" and "PollInterval". Also I don't get why there is an "OfflineSaveInterval". Why is there a desire to save from time to time if all connections are offline? Not sure if changes should be made to these values for default-settings with SD-card-wear-off in mind. Probably not important.


Well these all are in-depth-questions. The only thing that should be done is changing the watch-rate to 300 seconds.


Everything else seems to work fine.
 
One last thing. Nothing to be done for the pnd - unless you choose to mention in in the documentation at the end of the installation. However I'm not sure if I am doing the right thing. This is just ment as a sidenote for the curious.


The man-page of vnstat mentions the use of "vnstat -r":

-r, --reset
Reset the internal counters in the database for the selected interface. Use this if the interface goes down and back up, otherwise that interface will get some extra traffic to its database.

I don't exactly know how much difference this makes and how to add it to the system in the best way, but it might bring an improvement if you add two lines to "/etc/network/interfaces" for the related interface. For example i added



Code:
up vnstat -r -i wlan0

down vnstat -r -i wlan0

to the wlan0-section (at the end of the "iface wlan0 inet dhcp" section).


Unfortunately i have no clue if this is working or making a difference. ;)
 
Hi Lomaxx,


thanks for testing!

Tested the new version. Works fine.


One thought: I've been paying attention to the output of vnstat and I noticed that by default the statistics are being updated every 5 minutes (300 seconds). So there is no need to call "watch -n 1", which seems to be a bit overkill to me anyway. If you do not change the vnstat.conf, then you can set "watch -n 300". You can also trigger an update by using the "-u"-parameter, but that must be done as root unless the rights of the database-dirs/files are changed. I don't really see a need for this.


When lookin at vnstat.conf I noticed different poll-times. I'm not sure so far what the difference is between "UpdateInterval" and "PollInterval". Also I don't get why there is an "OfflineSaveInterval". Why is there a desire to save from time to time if all connections are offline? Not sure if changes should be made to these values for default-settings with SD-card-wear-off in mind. Probably not important.


Well these all are in-depth-questions. The only thing that should be done is changing the watch-rate to 300 seconds.


Everything else seems to work fine.

I don't have any deeper insight regarding the configurable intervals either.


But that 30-sec interval is something I didn't notice to be relevant for the current output method. But you are right, watch -n 1 doesn't make any sense here.


However, when I see that statistics, I'd rather have a live view. Maybe during a download I'd like to have a feeling about the download speed, too, and I'd like to observe the traffic volume in real-time. 20 seconds is too large an interval for that matter.


Maybe I should not use watch, but call vnstat's live mode instead? What do you think?


Regarding SD card wear-off, I really don't think that's a big matter. Not with these small amounts of data written and these write intervals. There are so many things which write so much more to the card. And even with those other frequent writes, the theoretical live span of a modern SD card is still so many years, that this dhouldn't matter.


If you want to make sure that your data is safe, you need to make backups either. Additionally, it makes sense to copy over all data to a new medium in regular intervals, in order to make sure that wear has minimum effect on your data safety.


I do it that way for many years now.


The only data loss I encountered was due to my own stupidity: I erased the contents of my main Pandora SD card by mkfs-ing the wrong partition. All my development stuff for my earlier PNDs was gone. :-(

One last thing. Nothing to be done for the pnd - unless you choose to mention in in the documentation at the end of the installation. However I'm not sure if I am doing the right thing. This is just ment as a sidenote for the curious.


The man-page of vnstat mentions the use of "vnstat -r":

-r, --reset
Reset the internal counters in the database for the selected interface. Use this if the interface goes down and back up, otherwise that interface will get some extra traffic to its database.

I don't exactly know how much difference this makes and how to add it to the system in the best way, but it might bring an improvement if you add two lines to "/etc/network/interfaces" for the related interface. For example i added



Code:
up vnstat -r -i wlan0

down vnstat -r -i wlan0

to the wlan0-section (at the end of the "iface wlan0 inet dhcp" section).


Unfortunately i have no clue if this is working or making a difference.


I don't get the point here.


To me, the first sentence in the man page entry for the -r parameter means, that the traffic volume counter is reset to zero. The second one, however, seems to mean something different. I am confused.


Resetting to zero should be done whenever the data plan also begins to count at zero again. Usually monthly.


There is a corresponding parameter in the .conf file to configure, at which day of the month the counter should be reset. My provider begins to count on each 22th of the month, so I set this parameter to 22.


But -r does something different?


Daniel
 
Maybe I should not use watch, but call vnstat's live mode instead?

Yeah, I thought of that as well. If you really want to observe traffic in realtime, then i recommend to do so. I for myself would set "UnitMode 1" and "RateUnit 0" in "/etc/vnstat.conf" in order to get KB/s or MB/s. In order to show the summary after exiting the live-mode I would use the line



Code:
vnstat -l  && read -s -n 1

With that the terminal will stay open until you press any key. Unfortunately that stupid "terminal"-command does not understand the "&&" when passing it to the "-e"-parameter



This works just nice:



Code:
xterm -e "vnstat -l  && read -s -n 1"


But the same for "terminal" does not work. So either you have to stick to that ugly "-H" to keep the window open or write a one-line-bash-script which is installed somewhere and called through the desktop-file.

But -r does something different?
To be honest: I have no clue so far. Forget about it. Hopefully it's not important.
 
Last edited by a moderator:
Improved version is online:


http://www.hermocom....Stat-Installer/


I did not use live mode now, because live mode does not show the traffic volume, but it shows transmission rates. When I tried this first, I didn't look close enough I guess.


I changed some timings in /etc/vnstat.conf, the .desktop file now calls a script /usr/bin/vnstat_output.sh and that script handles statistics display. Currently, it does


watch -n 10 vnstat


That's all.


The script contains another block of code for live mode, but it is not enabled by default.


Also there was a problem with live mode, if the standard interface was not online. In that case, vnstat -l simply quits, and the terminal was closed instantly. For that, I have added a check to the live mode code block, if the standard interface is currently active, and if not, do not use live mode, but use normal vnstat mode instead.


If you want to use live mode, edit the script /usr/bin/vnstat_output.sh and comment out the current watch line and the exit command below.


I think now every situation is covered.


Daniel
 
Last edited by a moderator:
Thanks hmc, this will prove useful with my mi-fi set up, as its always grossly overestimating actual data useage. It works very nicely.


You may want to note that people should have their wi-fi active when first running it to install, as it asks to choose which connection you want monitored at that point and you have to quit out if its not running. Otherwise, nicely presented and the option to un-install, like the java and timidity installers is great!


n.b I did hit one weird issue though (which wasn't repeatable, so its not a bug) in that after install, some quick useage and then rebooting, my SD install partition had corrupted and been wiped out! Had to re-install. This didn't occur the next time and must've been something messed up with my SD card just waiting to happen and not your app to blame, as it happened before with early builds of PNDStore which also wiped out my nand install at the same time. Oh well, only takes a short time to back up and running anyway thanks to Pandoras robust PND system :)


A useful addition to the Pandora library, many thanks :)
 
Thanks hmc, this will prove useful with my mi-fi set up, as its always grossly overestimating actual data useage. It works very nicely.


You may want to note that people should have their wi-fi active when first running it to install, as it asks to choose which connection you want monitored at that point and you have to quit out if its not running.

That's why there is a dialog asking the user to establish the connection he wants to monitor, before continuing the installation. ;-)


Is there a problem with this dialog, os it not well enough understandable? Then I should change it maybe...

Otherwise, nicely presented and the option to un-install, like the java and timidity installers is great!


n.b I did hit one weird issue though (which wasn't repeatable, so its not a bug) in that after install, some quick useage and then rebooting, my SD install partition had corrupted and been wiped out! Had to re-install. This didn't occur the next time and must've been something messed up with my SD card just waiting to happen and not your app to blame, as it happened before with early builds of PNDStore which also wiped out my nand install at the same time. Oh well, only takes a short time to back up and running anyway thanks to Pandoras robust PND system :)


I have encountered SD write issues some times before, not related to any specific piece of software, but whenever I had problems, the partition was automatically remounted read-only, resulting in write errors. After remounting read-write, everything was okay, except the last installation, which caused the remount.


However, it turned out to be a defective SD card.


What I have learned is this:


Whenever I encounter any suspicious and not otherwise explainable SD card problem, I assume the card to be defective and will exchange it.


And I will always use only recommended brands and make sure I don't get a fake brand SD card.


But of course, your problem may be related to something different.


Daniel
 
No there is no issue with the dialog box. I merely meant a note of having wi-fi active within your OP about the release of this but it's not at all important. It just caught me out.


Yes the SD is likely defective and i'd love to replace it but it has happened rarely and with a numbr of different cards, 99% of the time working just fine, so i have just accepted it for now whilst strapped for cash. As I said I in no way blame your application or any others that it has occured too after using. Sometimes they are chk disk fixable and sometimes the entire partition is lost, hey ho.


Many thanks again for the app :)
 
I tried downloading the repo version (1.0.0.4) and the one at the dev site (1.11_b3).


Neither show icons in the menu or desktop on my pandora. Neither do anything when executed.


downloaded filesizes are correct and have been redownloaded numerous times.


I am running OS Zaxxon 1.5 beta 2 on an SD card. Have I done something incorrectly?


Thanks.
 
Last edited by a moderator:
It will help, if you post the contents of the pnd_run.programname.out file, if the program is not starting.
 
Sorry, I dont know what or where that is. Let me know please.


BTW it works now. I had tried 1.0.0.4 from the App site and it seems that the appdata folder was not compatible or that pnd was corrupt or something.


I delete all vnstat pnd files and the appdata folder and tried one last time.


this time the App showed up on the desktop and installed. Be aware that the file size WAS correct on the first bad file. Something got byted off I guess ;-)


thanks and I still want to know what and where this "pnd_run.programname.out" file is so I can have a more informative post in the future.
 
Last edited by a moderator:
Oh, sorry those files are kinda like a log file for pnds. They are in /tmp
 
Ha... I took a look and learned somethings today.


Thanks. This is turning into an adventure.
 
Back
Top