Section: User Manuals (1)
Updated: JANUARY 2008
Return to Main Contents
vnStat - a console-based network traffic monitor
is a console-based network traffic monitor. It keeps a log of hourly,
daily and monthly network traffic for the selected interface(s). However,
it isn't a packet sniffer. The traffic information is analyzed from the
filesystem. That way vnStat can be used even without root permissions.
- -d, --days
Show traffic for days.
- -h, --hours
Show traffic for the last 24 hours.
- -m, --months
Show traffic for months.
- -s, --short
Use short output mode. This mode is also used if more than one
database is available.
- -t, --top10
Show all time top10 traffic days.
- -w, --weeks
Show traffic for 7 days, current and previous week.
- -tr time
Calculate how much traffic goes through the selected interface during
will be 5 seconds if a number parameter isn't included.
- -l, --live
Display current transfer rate for the selected interface in real time
until interrupted. Statistics will be shown after interruption if runtime
was more than 10 seconds.
- -i, --iface interface
Select one specific
and apply actions to only it.
- -q, --query
Force database query mode.
- -u, --update
Update all enabled databases or only the one specified with
- -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.
Synchronize internal counters in the database with interface
counters for the selected interface. Use this if the system is
rebooted but interface counters aren't reseted. Such can occur
when suspend to ram/disk is used.
- --enable, --disable
Enable or disable updates for selected interface. Useful for
interfaces that aren't always available, like ppp0. If the interface
goes down it should be disabled in order to avoid errors. Add something
vnstat -r --disable -i ppp0
to the script that's executed when
the interface goes down and
vnstat --enable -i ppp0
to the up script.
- -v, --version
Show current version.
Remove all top10 entries.
- -?, --help
Show a command summary.
Show complete options list.
- --nick nickname
Set the selected interfaces
as an alias the will be displayed in queries. Usage of
is required to save the change.
- --config file
as config file instead of using normal config file search function.
Reset the total traffic counters and recount those using recorded months.
Test if the kernel boot time information always stays the same like it should or
if it's shifting.
- -D, --debug
Show additional debug output.
Instead of showing the database with a formated output, this output will
dump the whole database in a format that should be easy to parse with most
script languages. Use this for example with PHP, Perl or Python to make a
custom webpage. The dump uses ; as field delimeter.
active;1 activity status
interface;eth0 name for the interface
nick;inet nick (if given)
created;1023895272 creation date in Unix time
updated;1065467100 when the database was updated
totalrx;569605 all time total received MB
totaltx;2023708 all time total transmitted MB
currx;621673719 latest rx value in /proc
curtx;981730184 latest tx value in /proc
totalrxk;644 total rx kB counter
totaltxk;494 total tx kB counter
btime;1059414541 system boot time in Unix time
Then follows 30 lines like the following
where d = days, 0 = day number in database (0 is today), 1077314401 date in
Unix time, 559 = rx MB, 7433 = tx MB, 68 = rx kB, 557 = tx kB and 1 tells that
vnStat has filled this value and it is in use.
m = months, t = top10 and h = hours, all other fields are in the same order as in days
except hours that doesn't have a separate kB value. For hours the forth and fifth fields
have values in kB.
This directory contains all databases the program uses. Files are
named according to the monitored interfaces.
Config file that will be used unless
vnstat -u -i
forces a database update for
or creates the database if it doesn't exist. This is usually the
first command used after a fresh install.
vnstat -u -i
and that information will be later included with queries.
vnstat -u -r --disable -i
resets the internal counters of
and disables it from being updated before enabled again with the
parameter. This feature is especially useful for interfaces like ppp0
that aren't always active.
Updates needs to be executed at least as often as it is possible for the interface
to generate enough traffic to wrap the kernel interface traffic counter. Otherwise
it is possible that some traffic won't be seen. This isn't an issue for 64 bit kernels
but at least one update every hour is always required in order to provide proper input.
With 32 bit kernels the maximum time between two updates depends on how fast the
interface can transfer 4 GB. Calculated theoretical times are:
10 Mbit: 54 minutes
100 Mbit: 5 minutes
1000 Mbit: 30 seconds
However, for 1000 Mbit interfaces updating once every minute is usually a
Estimated traffic values are likely to be somewhat inaccurate if daily
traffic is low because only the MB counter is used to calculate the
Virtual and aliased interfaces can't be monitored because the kernel doesn't
provide traffic information for that type of interfaces. Such interfaces are
usually named eth0:0, eth0:1, eth0:2 etc. where eth0 is the actual interface
Teemu Toivola <tst at iki dot fi>
- SEE ALSO
linux.jgfs.net manual pages