VNSTAT(1)
โจ vnstat(1) โจ
okay bestie, welcome to the User Manuals page for vnstat(1) โ grab a lil snack, we're going in ๐
๐ธ NAME ๐ธ
vnstat โ a console-based network traffic monitor ๐
๐ฆ SYNOPSIS ๐ฆ
vnstat [-5bDedhlmqstvy?] [--95th] [--add] [--alert output exit type
condition limit unit] [--begin date] [--config file] [--days [limit]]
[--db file] [--dbdir directory] [--dbiflist [mode]] [--debug] [--end
date] [--fiveminutes [limit]] [--help] [-hg] [--hours [limit]]
[--hoursgraph] [-i interface] [--iface interface] [--iflist [mode]]
[--json [mode] [limit]] [--limit limit] [--live [mode]] [--locale
locale] [--longhelp] [--merge source destination] [--months [limit]]
[--oneline [mode]] [--query [mode]] [--rateunit [mode]] [--remove]
[--rename name] [-ru [mode]] [--setalias alias] [--short] [--showconfig]
[--style number] [--top [limit]] [-tr [time]] [--traffic [time]]
[--version] [--xml [mode] [limit]] [--years [limit]] [interface]
๐ DESCRIPTION ๐
So like, vnstat is a console-based network traffic monitor. It keeps a log of 5 minute interval, hourly, daily, monthly and yearly network traffic for the selected interface(s). โจ
But โ and this is important, bestie โ it is not a packet sniffer. The traffic information is read from the proc(5) or sys filesystems, depending on availability, and that's literally why it uses such light system resources regardless of how hard your network traffic rate is going. It's giving low-effort-maintenance, high-effort-results ๐
. That way vnstat can be used even without root permissions on most systems. no cap.
Functionality is divided into two commands, okay? The purpose of the vnstat command is to provide an interface for querying the traffic information stored in the database ๐๏ธ, whereas the daemon vnstatd(8) is the one responsible for data retrieval, caching and storage. And even though the daemon process is constantly running as a service, it's actually spending most of its time sleeping between data updates ๐ด โ literally the dream work schedule, honestly.
๐ OPTIONS ๐
--95thโ shows 95th percentile output for the ongoing month. This output uses the 5 minute resolution data of the ongoing month to calculate the 95th percentile traffic rate for received, transmitted and total. On top of that, the minimum, average and maximum traffic rates for received, transmitted and total are also shown. โ ๏ธ This output requires the5MinuteHoursconfiguration option to have a value of at least744for storing all the necessary data โ otherwise 100% coverage isn't possible. so like, set it right or accept the consequences ๐--addโ creates a database entry for the interface specified with-ior--iface. The daemon can totally be running during this operation, and it will automatically start monitoring the interface without a restart withinSaveIntervalminutes if configuration optionRescanDatabaseOnSaveis enabled. Otherwise? The daemon needs to be restarted in order for the added interface to be monitored. sad but true ๐ญ--alertoutput exit type condition limit unit โ depending on the values of the given parameters, show alert, use a different exit status, or a combination of both when the configured situation is met. ๐จ
The output parameter takes a number from 0 to 3 and controls when, if at all, the command will result in output: '0' never produces output, '1' always produces output, '2' shows output only when usage estimate exceeds limit, and '3' shows output only when limit is exceeded.
The exit parameter takes a number from 0 to 5 and controls the exit status of the command: '0' always uses exit status 0, '1' always uses exit status 1, '2' uses exit status 1 if usage estimate exceeds limit but otherwise exit status 0, and '3' uses exit status 1 if limit is exceeded but otherwise exit status 0. '4' and '5' are equivalents of '2' and '3' with the difference that exit status 2 is used instead of exit status 1 when the condition is met. This can help differentiate alerts from errors, since errors will always use exit status 1. ๐ก
The type parameter defines which time range type usage the limit is compared against. Available options: 'h', 'hour', 'hourly', 'd', 'day', 'daily', 'm', 'month', 'monthly', 'y', 'year', 'yearly', 'p', '95', '95%'.
The condition parameter defines if limit is compared to received (rx), transmitted (tx), total, or estimated usage of these three. Available options: 'rx', 'tx', 'total', 'rx_estimate', 'tx_estimate', 'total_estimate'. Estimate options aren't available for 95th percentile type. ๐ซถ
limit is a greater than zero integer without decimals which defines the traffic usage limit using the unit defined with the unit parameter. unit accepts the following options: 'B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'. For 95th percentile type the following options are available: 'B/s', 'KiB/s', 'MiB/s', 'GiB/s', 'TiB/s', 'PiB/s', 'EiB/s', 'kB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s', 'EB/s', 'bit/s', 'Kibit/s', 'Mibit/s', 'Gibit/s', 'Tibit/s', 'Pibit/s', 'Eibit/s', 'kbit/s', 'Mbit/s', 'Gbit/s', 'Tbit/s', 'Pbit/s', 'Ebit/s'.
Usage must exceed limit in order for the alarm to activate. Exactly the same usage as limit does not raise the alarm. ๐
Estimate calculation isn't limited to the estimate options in the condition parameter โ you can also achieve it by using the estimate option in the output or exit parameters. Missing or invalid parameters, or a parameter combination that doesn't work, will result in --alert-specific help output being shown. ๐
-b,--begindate โ begins the list output with a specific date / time defined by date, instead of the begin being selected based on the number of entries to be shown. If date isn't available in the database, then the closest later date will be used. date supports the following formats:YYYY-MM-DD HH:MM,YYYY-MM-DDand"today". This option can only be used with--json,--xmland list outputs. ๐--configfile โ use file as the configuration file instead of using the automatic configuration file search functionality. If--configis used multiple times, the configuration settings from files later on the command line will override configuration settings loaded from earlier files โ but only if the settings defined in the files overlap. ๐-d,--days[limit] โ show traffic statistics on a daily basis for the last days. The length of the list will be limited to30entries unless configured otherwise, or unless the optional limit parameter is used. All entries stored in the database will be shown if limit is set to0. ๐--dbfile โ use file as the database file instead of searching for a database from the directory specified in the configuration file, or the hardcoded default if no configuration file is available. This option overrides--dbdir. ๐พ--dbdirdirectory โ use directory as the database directory instead of using the directory specified in the configuration file, or the hardcoded default if no configuration file is available. This option is ignored if--dbis also defined. ๐๏ธ--dbiflist[mode] โ list interfaces currently in the database. If mode is not defined or is set to0, then the output will use a one line verbose format. If mode is set to1, then the output will contain one interface per line, and if mode is set to2then only the interface count will be shown as a single number. See also--iflist. ๐ง-D,--debugโ show additional debug output. Can be used multiple times for increased verbosity, up to a maximum of2. ๐-e,--enddate โ ends the list output with a specific date / time defined by date, instead of the latest date / time in the database. If date isn't available in the database, then the closest earlier date will be used. date supports the following formats:YYYY-MM-DD HH:MMandYYYY-MM-DD. This option can only be used with--json,--xmland list outputs. In list outputs the estimate line is replaced with a sum line, with values representing the sums of each column. The sum line is shown only if the output consists of more than one data line โ and this is applicable even if the defined date is the same as the current date. The top list also requires--beginto be used at the same time with this option. ๐-5,--fiveminutes[limit] โ show traffic statistics with a 5 minute resolution for the last hours. The length of the list will be limited to24entries unless configured otherwise, or unless the optional limit parameter is used. All entries stored in the database will be shown if limit is set to0. โฑ๏ธ-h,--hours[limit] โ show traffic statistics on a hourly basis. The length of the list will be limited to24entries unless configured otherwise, or unless the optional limit parameter is used. All entries stored in the database will be shown if the limit is set to0. ๐-hg,--hoursgraphโ show traffic statistics on a hourly basis for the last 24 hours using a bar graph followed by a table representing the numerical data. literally the icon of graphs, obsessed ๐-i,--ifaceinterface โ select one specific interface and apply actions to only it. For database queries, it's possible to merge the information of two or more interfaces using theinterface1+interface2+...syntax. All provided interfaces must be unique and must exist in the database when the merge syntax is used. Optionally, depending on theInterfaceMatchMethodconfiguration setting, interface can be replaced with an alias previously set using--setalias. Merge syntax isn't supported when an alias is used. The-i,--ifaceoption is optional, and interface can be used as a parameter on the command line for selecting the used interface even without the option being explicitly used. ๐--iflist[mode] โ list currently available interfaces. If mode is not defined or is set to0, then the output will use a one line verbose format. If mode is set to1, then the output will contain one interface per line, and if mode is set to2then only the interface count will be shown as a single number. See also--dbiflist. ๐--json [mode] [limit]โ okay bestie, this is the json dump era โจ it shows database content for the selected interface or for all interfaces. Every traffic value in the output is in bytes unless the key name says otherwise. You can pass an optionalmodeparameter to limit the output to only selected info โ by default, everything except the 95th percentile output is shown. Setmodeto's'for a summary containing the last 2 entries of 5 minute, hourly, daily, monthly and yearly resolution data;'f'gives only 5 minute resolution entries;'h'hours;'d'days;'m'months;'y'years;'t'the top days; and'p'the 95th percentile. Alternatively, or in combination withmode, an optionallimitparameter can limit the number of entries in the output. The--jsonoption can be used in combination with-l,--liveand-troptions withoutmodeorlimithaving any effect to the output. Thejsonversionfield in the output contains the API version information โ it will be changed only when the names or structures of previously existing content gets changed. In comparison, thevnstatversionfield exists only as extra information ๐--limit limitโ sets the maximum number of shown entries in list outputs tolimit. Using--limitoverrides the default list entry limit values and the optionallimitparameter given directly for a list query. All entries stored in the database will be shown iflimitis set to0.--limitcan also be used to control the length of--jsonand--xmloutputs ๐-l,--live [mode]โ displays the current transfer rate for the selected interface in real time until interrupted, like a little traffic heartbeat monitor ๐ statistics will be shown after interruption if the runtime was more than 10 seconds. An optionalmodeparameter can select between displaying packets per second (mode 0) and transfer counters (mode 1) during execution.--stylecan also be used to affect the layout of the output. The output will be in json format if used in combination with--jsonoption.--locale localeโ uselocaleinstead of using the locale setting specified in the configuration file or the system default if no configuration file is available ๐--longhelpโ show complete options list. iconic, honestly โจ--merge source destinationโ merge interface data fromsourcedatabase todestinationdatabase. Unless interfaces are specified, all interfaces fromsourcewill be merged todestination. A new database will be created ifdestinationdoesn't exist. If an interface of the same name doesn't exist indestinationthen a direct copy action for the data fromsourcewill be executed. If an interface of the same name already exists indestinationthen an additive merge action will be executed. Thesourcedatabase is always accessed as read-only and will never be modified by the merge actions. Changes to thedestinationdatabase cannot be reversed as subtraction actions aren't supported ๐ซถ execution of the merge needs to be acknowledged with an additional parameter. If this additional parameter isn't provided then a preview of the actions with additional guidance will be shown.
Both source and destination can either refer directly to database files or use an alternative file:interface syntax where the database file is suffixed with : followed with an interface name. When used as source, the alternative syntax allows specifying one interface to be merged from source to destination instead of all interfaces being merged. Additionally, it's possible to use the alternative syntax in destination for specifying to which interface the data will be merged to.
-m,--months [limit]โ show traffic statistics on a monthly basis for the last months ๐ the length of the list will be limited to 12 entries unless configured otherwise or unless the optionallimitparameter is used. All entries stored in the database will be shown iflimitis set to0.--oneline [mode]โ show traffic summary for the selected interface using one line with a parsable format. The output contains 15 fields with;used as field delimiter. The 1st field contains the API version information of the output that will only be changed in future versions if the field content or structure changes. The following fields in order: 2) interface name, 3) timestamp for today, 4) rx for today, 5) tx for today, 6) total for today, 7) average traffic rate for today, 8) timestamp for current month, 9) rx for current month, 10) tx for current month, 11) total for current month, 12) average traffic rate for current month, 13) all time total rx, 14) all time total tx, 15) all time total traffic. An optionalmodeparameter can be used to force all fields to output in bytes without the unit itself shown ๐-q,--query [mode]โ force database query mode. An optionalmodeparameter can override the default query mode.'a'results in short summary output being used when there are more than one interface in the database, otherwise regular summary output is used.'s'results in regular summary output being shown for one interface regardless of the number of interfaces in the database. When the optionalmodeparameter isn't defined, the configuredQueryModewill be used instead ๐--removeโ delete the database entry for the interface specified with-ior--ifaceand stop monitoring it. The daemon can be running during this operation and will automatically detect the change ๐--rename nameโ rename the interface specified with-ior--ifacein the database with new name name. The new name cannot already exist in the database. This operation doesn't cause any data loss. The daemon should not be running during this operation ๐ซ-ru,--rateunit [mode]โ swap the configured rate unit. If rate has been configured to be shown in bytes then rate will be shown in bits if this option is present. In the same way, if rate has been configured to be shown in bits then rate will be shown in bytes when this option is present. Alternatively,modewith either0or1can be used as parameter for this option in order to select between bytes (0) and bits (1) regardless of the configuration file setting โ๏ธ--setalias aliasโ setaliasas an alias for the selected interface to be shown in queries. The set alias can be removed by specifying an empty string foralias. The daemon can be running during this operation ๐ท๏ธ-s,--shortโ use short output mode. This mode is also used when more than one interface is available in the database and no specific interface is selected.--showconfigโ show current configuration using the same format as the configuration file itself uses ๐งพ--style numberโ modify the content and style of outputs. Setnumberto0for a narrower output,1for enabling bar column,2for same as previous but with average traffic rate visible in summary output, and3for enabling average traffic rate in all outputs where it is supported.4disables the use of terminal control characters in-l,--liveand-tr,--trafficmodes ๐จ-t,--top [limit]โ show all time top traffic days ๐ the length of the list will be limited to 10 entries unless configured otherwise or unless the optionallimitparameter is used. All entries stored in the database will be shown iflimitis set to0. When used with--beginand optionally with--end, the list will be generated using the daily data instead of separate top entries. The availability of daily data defines the boundaries the date specific query can access.-tr,--traffic [time]โ calculate how much traffic goes through the selected interface during the giventimeseconds. Thetimewill be 5 seconds if a number parameter isn't specified. The output will be in json format if used in combination with--jsonoption. However, in that case, the countdown before results isn't shown.--stylecan also be used to affect the layout of the output โฑ๏ธ-v,--versionโ show current version.--xml [mode] [limit]โ the xml sibling of the json dump, same energy with angle brackets ๐ฆ it shows database content for the selected interface or all interfaces in xml format. All traffic values in the output are in bytes unless otherwise indicated by the name of the key. An optionalmodeparameter can be used for limiting the output to only selected information โ everything except the 95th percentile output is shown by default. Setmodeto's'for a summary containing the last 2 entries of 5 minute, hourly, daily, monthly and yearly resolution data;'f'gives only 5 minute resolution entries;'h'hours;'d'days;'m'months;'y'years;'t'the top days; and'p'the 95th percentile. Alternatively, or in combination withmode, an optionallimitparameter can limit the number of entries in the output. Thexmlversionfield in the output contains the API version information โ it will be changed only when the names or structures of previously existing content gets changed. In comparison, thevnstatversionfield exists only as extra information.-y,--years [limit]โ show traffic statistics on a yearly basis for the last years ๐๏ธ the list will show all entries by default unless configured otherwise or unless the optionallimitparameter is used. All entries stored in the database will also be shown iflimitis set to0.-?,--helpโ show a command option summary. the little save-me icon of the options world ๐
๐ FILES ๐
/var/lib/vnstat/โ default database directory on Linux ๐ง on BSD systems the compile-time default is/var/db/vnstatunless overridden at build time.- Configuration file locations and search order are described in
vnstat.conf(5)๐
๐ซ EXAMPLES ๐ซ
Okay bestie, this is the fun part โ real commands you can literally copy-paste. Slay.
vnstatโ just type it with no args and you get the traffic summary for the default interface. Or, if you're monitoring more than one, you get a summary for multiple interfaces. Lowkey the easiest flex.
vnstat
vnstat -i eth0+eth1+eth3โ this one is giving combo energy โจ it shows the traffic summary for a merge of interfaceseth0,eth1andeth3.
vnstat -i eth0+eth1+eth3
vnstat -i eth2 --xmlโ wants everything about interfaceeth2but in xml format? Obsessed. Outputs all information abouteth2in xml.
vnstat -i eth2 --xml
vnstat --jsonโ no interface specified, so it dumps all information about all monitored interfaces in json format. Main character behavior fr fr.
vnstat --json
vnstat -i eth0 --setalias localโ giving interfaceeth0the alias"local". The way that this info will later show up as a label wheneth0is queried? Iconic. ๐
vnstat -i eth0 --setalias local
vnstat -i eth2 --removeโ bye bestie ๐ deletes the database entries for interfaceeth2and stops monitoring it.
vnstat -i eth2 --remove
๐ง RESTRICTIONS ๐ง
Okay so this part is the vibe check you actually need to pay attention to, ngl.
- Updates need to be executed at least as often as it is possible for the interface to generate enough traffic to overflow the kernel interface traffic counter. If you don't? It's possible that some traffic won't be seen. ๐ Like, literally lost to the void.
- With 32-bit interface traffic counters, the maximum time between two updates depends on how fast the interface can transfer 4 GiB.
โ ๏ธ And heads up โ there is no guarantee that a 64-bit kernel has 64-bit interface traffic counters for all interfaces. Don't assume, bestie.
The calculated theoretical times are:
10 Mbit: 54 minutes
100 Mbit: 5 minutes
1000 Mbit: 30 seconds
- Virtual and aliased interfaces cannot be monitored, because the kernel doesn't provide traffic information for that type of interface. ๐ญ Such interfaces are usually named
eth0:0,eth0:1,eth0:2etc., whereeth0is the actual interface being aliased. - Using long date output formats may cause misalignment in the shown columns if the length of the date exceeds the fixed size allocation. So likeโฆ aesthetic risk, basically. ๐
๐ AUTHOR ๐
Teemu Toivola <tst at iki dot fi> โ the mastermind, the moment, the legend. ๐ซถ
๐ SEE ALSO ๐
Go read these next, iykyk:
That's the whole page, bestie โ you made it to the end ๐๐ This masterpiece is version 2.14, dated OCTOBER 2026. Go forth and monitor your traffic, you absolute icon. ๐ฆโจ
๐ฆ where this page comes from
- arch rolling: vnstat 2.14-1 ยท GPL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms