-
Notifications
You must be signed in to change notification settings - Fork 120
/
vnstat.1
525 lines (470 loc) · 14.4 KB
/
vnstat.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
.TH VNSTAT 1 "MAY 2021" "version 2.7" "User Manuals"
.SH NAME
vnstat \- a console-based network traffic monitor
.SH SYNOPSIS
.B vnstat
.RB [ \-5bDedhlmqstvy? ]
.RB [ \-\-add ]
.RB [ \-\-begin
.IR date ]
.RB [ \-\-config
.IR file ]
.RB [ \-\-days
.RI [ limit ]]
.RB [ \-\-dbdir
.RI [ directory ]]
.RB [ \-\-dbiflist
.RI [ mode ]]
.RB [ \-\-debug ]
.RB [ \-\-end
.IR date ]
.RB [ \-\-fiveminutes
.RI [ limit ]]
.RB [ \-\-help ]
.RB [ \-hg ]
.RB [ \-\-hours
.RI [ limit ]]
.RB [ \-\-hoursgraph ]
.RB [ \-i
.IR interface ]
.RB [ \-\-iface
.IR interface ]
.RB [ \-\-iflist
.RI [ mode ]]
.RB [ \-\-json
.RI [ mode ]
.RI [ limit ]]
.RB [ \-\-limit
.IR limit ]
.RB [ \-\-live
.RI [ mode ]]
.RB [ \-\-locale
.IR locale ]
.RB [ \-\-longhelp ]
.RB [ \-\-months
.RI [ limit ]]
.RB [ \-\-oneline
.RI [ mode ]]
.RB [ \-\-query ]
.RB [ \-\-rateunit
.RI [ mode ]]
.RB [ \-\-remove ]
.RB [ \-\-rename
.IR name ]
.RB [ \-ru
.RI [ mode ]]
.RB [ \-\-setalias
.IR alias ]
.RB [ \-\-short ]
.RB [ \-\-showconfig ]
.RB [ \-\-style
.IR number ]
.RB [ \-\-top
.RI [ limit ]]
.RB [ \-tr
.RI [ time ]]
.RB [ \-\-traffic
.RI [ time ]]
.RB [ \-\-version ]
.RB [ \-\-xml
.RI [ mode ]
.RI [ limit ]]
.RB [ \-\-years
.RI [ limit ]]
.SH DESCRIPTION
.B 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).
However, it isn't a packet sniffer. The traffic information is read from the
.BR proc (5)
or
.B sys
filesystems depending on availability resulting in light use of system resources
regardless of network traffic rate. That way vnStat can be used even
without root permissions on most systems.
.PP
Functionality is divided into two commands. The purpose of the
.B vnstat
command is to provide an interface for querying the traffic information stored
in the database whereas the daemon
.BR vnstatd (8)
is responsible for data retrieval, caching and storage. Although the daemon
process is constantly running as a service, it is actually spending most of its
time sleeping between data updates.
.SH OPTIONS
.TP
.B "--add"
Create database entry for interface specified with
.B \-i
or
.B \-\-iface
option. The daemon can be running during this operation but will not
automatically detect the addition without a restart.
.TP
.BI "-b, --begin " date
Begin the list output with a specific date / time defined by
.I date
instead of the begin being selected based on the number of entries to be shown.
If
.I date
isn't available in the database then the closest later date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM and YYYY-MM-DD.
This option can only be used with
.B "--json"
,
.B "--xml"
and list outputs.
.TP
.BI "--config " file
Use
.I file
as configuration file instead of using automatic configuration file search
functionality.
.TP
.BI "-d, --days " [limit]
Show traffic statistics on a daily basis for the last days. The length of the list
will be limited to 30 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--dbdir " directory
Use
.I directory
as database directory instead of using the directory specified in the configuration
file or the hardcoded default if no configuration file is available.
.TP
.BI "--dbiflist " [mode]
List interfaces currently in the database. If
.I mode
is not defined or is set to 0 then the output will use a one line verbose format. If
.I mode
is set to 1 then the output will contain one interface per line. See also
.BR "--iflist" .
.TP
.B "-D, --debug"
Show additional debug output.
.TP
.BI "-e, --end " date
End the list output with a specific date / time defined by
.I date
instead of the latest date / time in the database. If
.I date
isn't available in the database then the closest earlier date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM and YYYY-MM-DD.
This option can only be used with
.B "--json"
,
.B "--xml"
and list outputs. The top list also requires
.B "--begin"
to be used at the same time with this option.
.TP
.BI "-5, --fiveminutes " [limit]
Show traffic statistics with a 5 minute resolution for the last hours. The length of the list
will be limited to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "-h, --hours " [limit]
Show traffic statistics on a hourly basis. The length of the list will be limited
to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries store in the database will be shown if the
.I limit
is set to 0.
.TP
.B "-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.
.TP
.BI "-i, --iface " interface
Select one specific
.I interface
and apply actions to only it. For queries, it is possible to merge the
information of two or more interfaces using the
.I interface1+interface2+...
syntax. All provided interfaces must be unique and must exist in the database
when the merge syntax is used.
.TP
.BI "--iflist " [mode]
List currently available interfaces. If
.I mode
is not defined or is set to 0 then the output will use a one line verbose format. If
.I mode
is set to 1 then the output will contain one interface per line. See also
.BR "--dbiflist" .
.TP
.BI "--json " "[mode] [limit]"
Show database content for selected interface or all interfaces in json format. All
traffic values in the output are in bytes. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything is shown by default. Setting
.I mode
to 'f' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months, 'y'
years and 't' the top days. Alternatively or in combination with
.I mode
an optional
.I limit
parameter can be used to limit the number of entries in the output. The
.BI "--json"
option can be used in combination with
.B "-l, --live"
and
.B "-tr"
options without
.I mode
or
.I limit
having any effect to the output. The
.B "jsonversion"
field 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, the
.B "vnstatversion"
field exists only as extra information.
.TP
.BI "--limit " limit
Set the maximum number of shown entries in list outputs to
.IR limit .
Usage of
.B "--limit"
overrides the default list entry limit values and the optional
.I limit
parameter given directly for a list query. All entries stored in the database will be shown if
.I limit
is set to 0.
.B "--limit"
can also be used to control the length of
.B "--json"
and
.B "--xml"
outputs.
.TP
.BI "-l, --live " [mode]
Display current transfer rate for the selected interface in real time
until interrupted. Statistics will be shown after interruption if the runtime
was more than 10 seconds. An optional
.I mode
parameter can be used to select between the displaying of packets per
second (mode 0) and transfer counters (mode 1) during execution.
.B "--style"
can also be used to affect the layout of the output. The output will be in json
format if used in combination with
.B "--json"
option.
.TP
.BI "--locale " locale
Use
.I locale
instead of using the locale setting specified in the configuration file or the system
default if no configuration file is available.
.TP
.B "--longhelp"
Show complete options list.
.TP
.BI "-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 optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--oneline " [mode]
Show traffic summary for 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 optional
.I mode
parameter can be used to force all fields to output in bytes without the
unit itself shown.
.TP
.B "-q, --query"
Force database query mode.
.TP
.B "--remove"
Delete the database entry for the interface specified with
.B \-i
or
.B \-\-iface
and stop monitoring it. The daemon can be running during this operation
and will automatically detect the change.
.TP
.BI "--rename " name
Rename the interface specified with
.B \-i
or
.B \-\-iface
in the database with new name
.BR 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.
.TP
.BI "-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,
.I mode
with either 0 or 1 can be used as parameter for this option in order to
select between bytes (0) and bits (1) regardless of the configuration file setting.
.TP
.BI "--setalias " alias
Set
.I alias
as an alias for the selected interface to be shown in queries. The set
alias can be removed by specifying an empty string for
.IR alias .
The daemon can be running during this operation.
.TP
.B "-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.
.TP
.B "--showconfig"
Show current configuration using the same format as the configuration file
itself uses.
.TP
.BI "--style " number
Modify the content and style of outputs. Set
.I number
to 0 for a narrower output, 1 for enabling bar column, 2
for same as previous but with average traffic rate visible in summary
output and 3 for enabling average traffic rate in all outputs where it is
supported. 4 disables the use of terminal control characters in
.B "-l / --live"
mode.
.TP
.BI "-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 optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0. When used with
.B "--begin"
and optionally with
.BR "--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.
.TP
.BI "-tr, --traffic " [time]
Calculate how much traffic goes through the selected interface during
the given
.I time
seconds. The
.I time
will be 5 seconds if a number parameter isn't specified. The output will
be in json format if used in combination with
.B "--json"
option. However, in that case, the countdown before results isn't shown.
.TP
.B "-v, --version"
Show current version.
.TP
.BI "--xml " "[mode] [limit]"
Show database content for selected interface or all interfaces in xml format. All
traffic values in the output are in bytes. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything is shown by default. Setting
.I mode
to 'f' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months, 'y'
years and 't' the top days. Alternatively or in combination with
.I mode
an optional
.I limit
parameter can be used to limit the number of entries in the output. The
.B "xmlversion"
field 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, the
.B "vnstatversion"
field exists only as extra information.
.TP
.BI "-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 optional
.I limit
parameter is used. All entries stored in the database will also be shown if
.I limit
is set to 0.
.TP
.B "-?, --help"
Show a command option summary.
.SH FILES
.TP
.I /var/lib/vnstat/
Default database directory.
.TP
.I /etc/vnstat.conf
Config file that will be used unless
.I $HOME/.vnstatrc
exists. See
.BR vnstat.conf (5)
for more information.
.SH EXAMPLES
.TP
.B "vnstat"
Display traffic summary for the default interface or multiple interfaces
when more than one is monitored.
.TP
.B "vnstat -i eth0+eth1+eth3"
Display traffic summary for a merge of interfaces eth0, eth1 and eth3.
.TP
.B "vnstat -i eth2 --xml"
Output all information about interface eth2 in xml format.
.TP
.B "vnstat --json"
Output all information of all monitored interfaces in json format.
.TP
.B "vnstat -i eth0 --setalias local"
Give interface eth0 the alias "local". That information will be
later visible as a label when eth0 is queried.
.TP
.B "vnstat -i eth2 --remove"
Delete database entries for interface eth2 and stop monitoring it.
.SH RESTRICTIONS
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. Otherwise,
it is possible that some traffic won't be seen. With 32-bit interface traffic counters,
the maximum time between two updates depends on how fast the interface can transfer 4 GiB.
Note that there is no guarantee that a 64-bit kernel has 64-bit interface traffic counters
for all interfaces. Calculated theoretical times are:
.RS
.TS
l l.
10 Mbit: 54 minutes
100 Mbit: 5 minutes
1000 Mbit: 30 seconds
.TE
.RE
.PP
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
being aliased.
.PP
Using long date output formats may cause misalignment in shown columns if the
length of the date exceeds the fixed size allocation.
.SH AUTHOR
Teemu Toivola <tst at iki dot fi>
.SH "SEE ALSO"
.BR vnstatd (8),
.BR vnstati (1),
.BR vnstat.conf (5),
.BR proc (5),
.BR ifconfig (8),
.BR units (7)