vnStat daemon – the alternative for cron based updating
The purpose of
is to provide a more flexible way for updating
databases than what using cron for updating can provide. The daemon makes
possible updating databases more often but at the same time requires
less disk access since data can be cached and written only later to disk
at a user configurable interval. It is also able to track how interfaces
come and go without the need of additional scripts that are required with
cron based updates.
is the command for starting the daemon. The daemon can either fork
itself to run as a background process or stay attached to the terminal.
It supports logging to a user selectable file or using syslog.
Once started, the daemon will check if there are any databases available
in the database directory that has been specified in the configuration
file. New databases will be created for all available interfaces excluding
pseudo interfaces lo, lo0 and sit0 if no databases are found during startup.
as config file instead of using normal config file search function.
and use it for locking so that another instance of the daemon cannot
be started if the same
The behaviour of the daemon is configured mainly using the configuration
in the configuration file.
defines in seconds how often the interface data is updated.
This is similar to the run interval for alternative cron based updating.
However, the difference is that the data doesn’t get written to disk
defines in seconds how often the list of available interfaces is checked
for possible changes. The minimum value is 2 seconds and the maximum 60
also defines the resolution for other intervals.
defines in minutes how often cached interface data is written to disk.
A write can only occur during the updating of interface data. Therefore,
the value should be a multiple of
with a maximum value of 60 minutes.
The default values of
2 are usually suitable for most systems and provide a similar behaviour
as cron based updating does but with a better resolution for interface
changes and fast interfaces.
For embedded and/or low power systems more tuned configurations are possible.
In such cases if the interfaces are mostly static the
can be rised to around 10-30 seconds and
set to 60 seconds. Higher values up to 300 seconds are possible if the
interface speed is 10 Mbit or less.
can be rised for example to 15, 30 or even 60 minutes depending on how
often the data needs to be viewed.
The daemon is listening to signals
signal to the daemon will cause cached data to be written to disk,
a rescan of the database directory and a reload of settings from the
configuration file. However, the pid file will not be updated even if
it’s configuration setting has been changed.
signals will cause the daemon to write all cached data to disk and
exists. See the configuration chapter and
for more information.
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 GiB. 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
Virtual and aliased interfaces cannot 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>