vergoh / vnstat Goto Github PK
View Code? Open in Web Editor NEWvnStat - a network traffic monitor for Linux and BSD
License: GNU General Public License v2.0
vnStat - a network traffic monitor for Linux and BSD
License: GNU General Public License v2.0
nevermind, sorry!
If so, could you offer a tag in github for new releases from now on?
I also would like to see tarball available on your homepage.
Thanks.
When using a grsecurity enhanced kernel and running vnstatd with the user vnstat, no data is collected.
Due to proc restrictions by grsec, the vnstat user must be a member of the grsec-proc group.
When this is not the case, vnstatd collects no data and produces no error or warning log messages.
Please add one for this case.
Maybe at
Line 68 in 4e1b097
Line 22 in 4e1b097
Install docs are now incorrect since you changed to autotools because the binaries are no longer in src/ but in the root of the working directory.
Not all required includes are included.
We get an error when parsing vnstat -i br0 -h --json
using python -m json.tool
.
Indeed, the output contains some wrongly formatted json on traffic.hours
array which contains a leading ,
(..."hours":[,{"id":15,"...
)
{"vnstatversion":"1.13","jsonversion":"1","interfaces":[{"id":"br0","nick":"br0","created":{"date":{"year":2015,"month":2,"day":8}},"updated":{"date":{"year":2015,"month":2,"day":8},"time":{"hour":15,"minutes":21}},"traffic":{"total":{"rx":974,"tx":128},"days":[{"id":0,"date":{"year":2015,"month":2,"day":8},"rx":974,"tx":128}],"months":[{"id":0,"date":{"year":2015,"month":2},"rx":974,"tx":128}],"tops":[],"hours":[,{"id":15,"date":{"year":2015,"month":2,"day":8},"rx":974,"tx":128}]}}]}
In addition with the default monthly monitoring, I would like to monitor a custom date range matching the billing period. How can it be done?
If not, please let me know how to configure monitoring the billing period.
I was wondering if there is any chance that support for per-process stats would be added, because it would be quite useful to have.
When I run
vnstat -d -s
it returns
rx / tx / total / estimated
eth0:
Dec '15 19.47 MiB / 543.02 MiB / 562.49 MiB / 11.01 GiB
today 19.47 MiB / 543.02 MiB / 562.49 MiB / 1.01 GiB
as you can see, it adds an extra 10 to the days estimate.
I couldn't find a mention of this in the changelog; and the config-file didn't seem to have an option for this either. This change makes the output pretty useless as it's just a bunch of numbers now (which are also being truncated). Can I change this; or is this a bug?
Hey,
I'm attempting to statically cross compile vnstat-1.16
(same with 1.15
) to ARM or MIPS64, using musl-1.15
but the build fails. The cross-compiler works fine as I was able to compile many other softwares. It is using gcc-6.2.0
.
In case you want to look what was done, here the output → https://framagit.org/Ypnose/solyste/snippets/363/raw
Since Gigabit links are common, what about changing the default MaxBandwidth
setting from 100
to 1000
? As far as I can see, this limit exists to detect abnormally high deviations and there shouldn't be any other negative effects from doing so?
I have set my router to reset wlan0 every 6 hours using cron and wifi command.
Sometimes after running that command vnstat is adding 4GB of transfer to my wlan0 statistic. Anyone know why?
It's happening on OpenWRT Chaos Calmer and was present on OpenWRT Barrier Breaker.
I am using the --json parameter to output results for my website's dashboard. Using a script that converts the output into a readable format, it returns MB, rather than GB. The readable numbers are the exact same.
My question is, is the rx and tx numbers bytes?
Excuse me if this is possible but it's not obvious in any manual pages or docs that I've come across. Would it be possible to be able to log and report on periods longer than 12 months, like say over a 10 year period?
vnstat -s
rx / tx / total / estimated
wan0:
Jan '16 4.00 GiB / 3.40 GiB / 7.40 GiB
Mar '16 0.99 GiB / 1.05 GiB / 2.04 GiB / 2.26 GiB
yesterday 18.52 MiB / 23.78 MiB / 42.30 MiB
today 2.90 MiB / 2.39 MiB / 5.29 MiB / 32 MiB
however in standard printout:
vnstat
Database updated: Tue Mar 1 02:55:01 2016
wan0 since 08/03/15
rx: 16.17 GiB tx: 11.53 GiB total: 27.70 GiB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
Jan '16 4.00 GiB | 3.40 GiB | 7.40 GiB | 23.18 kbit/s
Feb '16 0.99 GiB | 1.05 GiB | 2.04 GiB | 7.57 kbit/s
------------------------+-------------+-------------+---------------
estimated 1.10 GiB | 1.16 GiB | 2.26 GiB |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
yesterday 18.52 MiB | 23.78 MiB | 42.30 MiB | 4.01 kbit/s
today 2.90 MiB | 2.39 MiB | 5.29 MiB | 4.13 kbit/s
------------------------+-------------+-------------+---------------
estimated 16 MiB | 16 MiB | 32 MiB |
looks like February in -s short printout is missing
When vnstat shows me stats it gives wrong information about the avg. rate.
Example:
day rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
01/17/16 1.77 GiB | 1.09 GiB | 2.86 GiB | 277.92 kbit/s
That is wrong information because 2.86 GiB (Gebibyte) per day equals 284.34 kbit/s.
Either your calculation is wrong or you're just using the wrong prefix. I suspect the latter, because 277.92 kibibyte/s would be right.
I attached a screenshot of my calculations, just to show what I did.
Hi @vergoh,
Thanks for this useful tool, I was wondering if -h
can show data as -d
, -m
to use a human readable unit? Currently, it shows the data in KiB, hope it can auto transfer to use MiB and GiB.
Thanks!
I updated from 1.12 to 1.16 and I got this error.
Error: wlan0: Invalid database timestamp.
Error: validation of imported database failed.
How do I fix this? I can't even import my backup databases.
hello,
the devices are not in sort order shown.
i have no idea if there is any option for it ?
I can no longer build with image output support on FreeBSD since you changed to autotools. libgd is installed, we're passing the correct LDFLAGS as always and it simply won't play ball.
Is there a reason you changed to autotools? Your old makefiles worked perfectly fine.
Just fresh installed and -> Failed to restart vnstat.service: Unit vnstat.service is masked.
ps aux|grep vnstat
--nothing there ...
My router with LEDE (version 17.01.2) has vnstat version 1.12. I could upgrade it to vnstat version 1.17 by following instructions on https://forum.lede-project.org/t/why-vnstat-is-at-version-1-12-1-only/1179/21
My Linux Mint 18.2 Xfce has vnstat version 1.14. I could follow the instructions on https://askubuntu.com/questions/938293/update-vnstat-to-1-17 to upgrade to vnstat 1.17.
Here's my question. If I upgrade the vnstat on my Linux Mint computer or my router, will I lose some vnstat data/logs/stats that are being saved?
Another question: Before I can upgrade to vnstat 1.17, wouldn't I first have to remove my current vnstat? If so, am I right to think that uninstalling would remove all the vnstat logs/stats/database?
Im using the command --exportdb --xml, my xml is then converted to json.
The first id in traffic.days.day and traffic.months.month always seem to be current month/day. However if i do the same to traffic.months.month the usage reported will be in the id of the current hours. (So say i download a huge file at 1700 o'clock the reported use will be in id 16)
Output https://gist.github.com/Hellowlol/7808a07c190a911cc208
Is this intended?
Is there any way to change the "first day of the month" for vnstat? Example:
$ vnstat -m
external (enp4s0) / monthly
month rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
May '16 45.71 GiB | 1.86 GiB | 47.57 GiB | 148.99 kbit/s
Jun '16 261.80 GiB | 4.57 GiB | 266.36 GiB | 1.26 Mbit/s
------------------------+-------------+-------------+---------------
estimated 381.14 GiB | 6.64 GiB | 387.79 GiB |
As you can see, vnstat is treating the first day I started the daemon as the first day of the month. I need it to be the actual first day, e.g. for June it should start at June 1.
My /etc/vnstat.conf
has MonthRotate 1
set, but that doesn't seem to have any effect.
$ vnstat -v
vnStat 1.15 by Teemu Toivola <tst at iki dot fi>
Please delete
I've been doing some weird stuff and it's messed with my vnstat output. I realized this when I had already uploaded three gigabytes abnormally. Can I edit the database to return the value for a specific hour to a sensible size? I don't know what format databases are in, or how to open them.
hello,
thanks for this great software !
i'm using vnStat 1.12 on debian jessie and didn't see anything about what i'm looking for:
i ve got several logical interface, and i need details per sub-interface
eth0
eth0:1
eth0:2
is that possible ?
[ifinfo.c:131]: (error) Dangerous usage of 'ifaceid' (strncpy doesn't always null-terminate it).
Source code is
strncpy(ifaceid, iface, 32);
strcat(ifaceid, ":");
Suggest new code
strncpy(ifaceid, iface, 32);
ifaceid[32] = '\0';
strcat(ifaceid, ":");
Can you consider adding vnstat to Coverity Scan.
Would be nice to have remote controll of vnstat so you can collect data from diffrent hosts!
Such as in FreeNAS jails or other simular setups.
Sorry bad english!
I find myself want 5, or 15 minute intervals as well (coincides with better loadavg for one).
Unfortunately 'm' is already used in the db for month.
Using JSON as output makes vnstat one of the best network monitoring tools.
However I've noticed that --json parameter is not working in some cases like:
Maybe there is some workaround to achieve JSON output in such situations, if not It might turnout to be very handy to add such support.
Greetings,
I have a feature request -
It would be very helpful to my platform and usage needs if it were possible to get the -tr argument output in JSON format.
Thank you for work on this great product.
In the function readproc there is a buffer overflow:
char temp[4][64], procline[512], *proclineptr, ifaceid[33];
[...]
while (fgets(procline, 512, fp)!=NULL) {
sscanf(procline, "%511s", temp[0]);
The variable temp is only 4*64 (=256) bytes, yet the code tries to fill it with 512 byte and thus overflows. (To see the overflow at runtime you can compile vnstat with address sanitizer: 'make CFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address"' and then run 'src/vnstat -tr')
I think a patch like this should fix it (but not 100% sure, cause I don't know what exactly the code is meant to do):
--- ./vnstat-1.14/src/ifinfo.c 2015-03-29 20:56:55.000000000 +0200
+++ ./vnstat-1.14-1/src/ifinfo.c 2015-12-07 18:35:50.981122234 +0100
@@ -182,8 +182,8 @@
strcat(ifaceid, ":");
check = 0;
- while (fgets(procline, 512, fp)!=NULL) {
- sscanf(procline, "%511s", temp[0]);
+ while (fgets(procline, 256, fp)!=NULL) {
+ sscanf(procline, "%255s", temp[0]);
if (strncmp(ifaceid, temp[0], strlen(ifaceid))==0) {
/* if (debug)
printf("\n%s\n", procline); */
I see errors like this
In file included from common.h:18:0,
from misc.c:2:
/usr/include/sys/file.h:209:2: error: unknown type name 'u_int'
u_int xf_flag; /* flags (see fcntl.h) */
in gmake all
, even with the CPATH and LIBRARY_PATH variables set. I'm not a C programmer, so what other information do you need?
And insert the JSON output in one unnecessary commas, therefore in jq command cannot parse error occurs.
This is in recognition that the bug right?
# vnstat --json
{"vnstatversion":"1.13","jsonversion":"1","interfaces":[{"id":"eth0","nick":"eth0","created":{"date":{"year":2015,"month":4,"day":6}},"updated":{"date":{"year":2015,"month":4,"day":6},"time":{"hour":16,"minutes":2}},"traffic":{"total":{"rx":33464,"tx":920},"days":[{"id":0,"date":{"year":2015,"month":4,"day":6},"rx":33464,"tx":920}],"months":[{"id":0,"date":{"year":2015,"month":4},"rx":33464,"tx":920}],"tops":[],"hours":[,{"id":15,"date":{"year":2015,"month":4,"day":6},"rx":33367,"tx":894},{"id":16,"date":{"year":2015,"month":4,"day":6},"rx":97,"tx":26}]}}]}
[root@localhost ~]# vnstat --json | jq .
parse error: Expected value before ',' at line 1, column 425
I noticed traffic from apt-mirror is not (reliably) counted by vnstat, but the traffic shows up in my Zabbix monitoring. apt-mirror downloaded a good 120GB at a speed of roughly 700Mbit/s today, yet only 18GB were registered by vnstat (which includes other traffic by other applications). I haven't noticed any other applications not being counted on my system. I have no idea how this is even possible, vnstat usually even counts routed traffic on the network interface. Any suggestions?
Hey
Is there any API of sorts which is possible to use to integrate in a different application. Or some way to access its output stats?
Thanks.
... either that, or the documentation is incorrect.
I am just getting into vnstat and think I am going to love it. In setting up the initial configuration, I noticed that PollInterval was capped at 60 instead of 300 as listed in the documentation.
Thank you!
i have a question.
i use a shell script to get the output from one month from different servers.
one server has more b/w usage then the other.
one server gives me 700 mb usage per month
another server gives me 4 gb usage per month.
in my output i get 700 from one server and 4 from the other.
is it possible to get the output in mb ? so i get 700 from one server and 4096 from the other server ?
here is a part of the line i use.
vnstat -m | grep "date +"%b '%y"
" | awk '{print $3}' > monitor/download.txt
maybe you have another solution that i can get the output in bytes so i can calculate in the script to get back to mb or gb.
I just installed vnstat and enable the service. I wan't to reset it to zero like I never used it.
vnstat -r >> doesn't reset.
vnstat --delete ; vnstat --create -i mydevice ; reboot >> doesn't reset either.
After --create. the profile that was created was the profile that was deleted before.
rm /var/lib/vnstat/mydevice ; vnstat --create -i mydevice ; reboot also doesn't reset.
same thing happened after --create.
just like this guy: http://www.linuxquestions.org/questions/linux-networking-3/vnstat-doesn%27t-reset-494165/
What could be the problem? Am I doing it wrong?
Thank you :'D
This happens for every installation and the fix would be
chown vnstat: /var/lib/vnstat/*
OS: CentOS 6 & 7
Installed using yum.
Vnstat has made my day. I configured it just right, started the daemon, and waited patiently for data to amass in each interface's database.
I then noticed graph columns did not align correctly:
I've encountered this problem in my own programs. As programmers, we cannot assume that characters of localized strings only occupy a single column. The fix is straightforward and begins with the man page for wcswidth().
Thank you for maintaining such an awesome utility.
Hi,
I got this problem 4 times on this month during connecting via 3G USB (only occur on 3G USB). The counter increase 8Gb suddenly with Download 4GB and Upload 4GB.
I don't know why and facing it few time in this month. How can I find the cause of this problem?
Hi,
according to the docs, vnstatd
will only create database files for interfaces when there aren't any files yet. How do get it to automatically create database files for interfaces that are added later on? Is there an option for that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.