Skip to content

Usage # Configuration file basics

Teemu Toivola edited this page Aug 9, 2023 · 2 revisions

This page aims to describe the relevant options of the configuration file for the current vnStat release. See the vnstat.conf man page for a description of every available configuration option.

In the configuration file, any line starting with # or ; are considered as inactive. In general, # is used for comments and ; is used for configuration options having the initially default setting visible.

Interface

Default interface for queries. The daemon ignores this option. Leave empty for automatic selection which will selects the interface with most overall traffic unless a specific interface with -i / --iface is used. Use to configure a different interface for default queries when there are multiple interfaces being monitored and the wanted interface doesn't match the automatic selection criteria.

Date output format

DayFormat, MonthFormat and TopFormat configure the date output formats for all outputs and can be modified without restarting the daemon. These options affect only how the dates are formatted in the outputs and don't change how dates are represented in the database. See man 1 date or date --help for format control options. Note that there's a fixed maximum length for the date field

RateUnit

Selection between bytes per second (0) and bits per second (1) for any output having traffic rate visible. Ignored by the daemon.

BandwidthDetection

Try to query the interface for current interface specific maximum bandwidth. For most ethernet cable connections, this will automatically provide the actual link speed. Default value 1 is enabled and the suggested configuration but can be disabled with 0 or overridden with MaxBW.

MaxBandwidth

Default maximum bandwidth for all interfaces if BandwidthDetection is disabled or is unable to detect the value for an interface. The maximum bandwidth configuration in vnStat doesn't affect the actual bandwidth of the interface but is a sanity check value instead for ignoring invalid readings.

MaxBW

Interface specific maximum bandwidth configuration that will override the above options if enabled. The interface name needs to be part of the configuration option. For example, for the interface eth0 the option would be MaxBWeth0 and for interface foofoo42 the option would be MaxBWfoofoo42. Can be needed for example for dialup and ppp interfaces which don't report the link speed for BandwidthDetection and system also has another much faster interface for local traffic.

Data retention

The following options are available for defining for how long for each time period data is kept in the database:

  • 5MinuteHours
  • HourlyDays
  • DailyDays
  • MonthlyMonths
  • YearlyYears
  • TopDayEntries

The daemon needs to be reloaded or restarted if these options are changed. Setting any option to 0 allows disabling the storage of the matching time period and -1 disabled the removal of any data for the time period. The impact of using -1 is mainly more disk space being needed on the longer run which will be more visible for 5 minute, hourly and daily time periods than for example for monthly or yearly. Also note that the number of monitored interfaces acts as a multiplier if there's a worry regarding disk space usage.

MonthRotate

Day of month that months are expected to change. Set by default to 1 resulting in the months to change on the first day of every month (as would be expected) but can be set to alternative values for example for tracking monthly billed traffic when the billing period doesn't start on the first day. For example, if set to 7, days of February up to and including the 6th will count for January. Changing this option will not cause existing data to be recalculated. The daemon needs to be reloaded or restarted if this option is changed.