-
Notifications
You must be signed in to change notification settings - Fork 127
Usage # Real time monitoring modes
In addition to output features using the data store by the daemon to the database, vnStat has two real time monitoring modes which don't have a dependency to the daemon or the database. Both can be even used directly with only the vnstat
binary available without anything else installed.
Calculates the traffic for the default or given interfaces for 5 seconds (default, unless otherwise specified) and then shows the result in human readable format.
Supported additional parameters:
-
--json
- output in json format -
-ru
/--rateunit
- switch between bytes/s and bits/s, overridesRateUnit
from configuration file
Command examples:
-
vnstat -tr
- default interface selected, 5 seconds monitoring (unless configuration file says otherwise) -
vnstat -tr 5
- default interface selected, 5 seconds monitoring -
vnstat -tr 10 -i eth1
orvnstat -tr 10 eth1
(starting from version 2.8) - 10 seconds monitoring for interfaceeth1
-
vnstat -tr 2 --json
- default interface selected, 2 seconds monitoring, json format output
Output examples:
$ vnstat -tr
51 packets sampled in 5 seconds
Traffic average for eth0
rx 1.74 KB/s 5 packets/s
tx 793 B/s 4 packets/s
$ vnstat -tr 2 --json
{"jsonversion":"1","vnstatversion":"2.9","interface":"eth0","sampletime":2,"rx":{"ratestring":"4.57 KB/s","bytespersecond":4679,"packetspersecond":20,"bytes":9359,"packets":41},"tx":{"ratestring":"3.67 KB/s","bytespersecond":3757,"packetspersecond":18,"bytes":7515,"packets":36}}
Displays 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 mode parameter can be used to select between the displaying of packets per second (mode 0
) and transfer counters (mode 1
) during execution.
Supported additional parameters:
-
--json
- output in json format -
--style 4
- output a new line every 2 seconds instead of reusing one line -
-ru
/--rateunit
- switch between bytes/s and bits/s, overridesRateUnit
from configuration file
Command examples:
-
vnstat -l
- default interface selected, default human readable output -
vnstat -l -i eth1
orvnstat -l eth1
(starting from version 2.8) - default human readable output for interfaceeth1
-
vnstat -l --help
- help output for optional mode parameter -
vnstat -l 0
- default interface selected, default human readable output with packets per seconds shown -
vnstat -l 1
- default interface selected, default human readable output with transfer sum shown -
vnstat -l --json
- default interface selected, json format output with new line every two seconds
Output examples:
$ vnstat -l
Monitoring eth0... (press CTRL-C to stop)
rx: 2.57 KB/s 8 p/s tx: 693 B/s 6 p/s
eth0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 15.25 MB | 483.56 KB
--------------------------------------+------------------
max 1.81 MB/s | 66.12 KB/s
average 300.40 KB/s | 9.30 KB/s
min 884 B/s | 35 B/s
--------------------------------------+------------------
packets 12223 | 4131
--------------------------------------+------------------
max 1382 p/s | 408 p/s
average 235 p/s | 79 p/s
min 3 p/s | 0 p/s
--------------------------------------+------------------
time 52 seconds
$ vnstat -l --json
{"jsonversion":"1","vnstatversion":"2.8","interface":"eth0","sampletime":2}
{"index":1,"seconds":2,"rx":{"ratestring":"56.71 KB/s","bytespersecond":58067,"packetspersecond":48,"bytes":116134,"packets":96,"totalbytes":116134,"totalpackets":96},"tx":{"ratestring":"3.20 KB/s","bytespersecond":3278,"packetspersecond":14,"bytes":6556,"packets":28,"totalbytes":6556,"totalpackets":28}}
{"index":2,"seconds":4,"rx":{"ratestring":"867.84 KB/s","bytespersecond":888671,"packetspersecond":640,"bytes":1777343,"packets":1281,"totalbytes":1893477,"totalpackets":1377},"tx":{"ratestring":"20.69 KB/s","bytespersecond":21188,"packetspersecond":252,"bytes":42376,"packets":505,"totalbytes":48932,"totalpackets":533}}
{"index":3,"seconds":6,"rx":{"ratestring":"2.03 KB/s","bytespersecond":2081,"packetspersecond":10,"bytes":4163,"packets":20,"totalbytes":1897640,"totalpackets":1397},"tx":{"ratestring":"653 B/s","bytespersecond":653,"packetspersecond":6,"bytes":1306,"packets":12,"totalbytes":50238,"totalpackets":545}}
{"index":4,"seconds":8,"rx":{"ratestring":"177.69 KB/s","bytespersecond":181953,"packetspersecond":136,"bytes":363906,"packets":272,"totalbytes":2261546,"totalpackets":1669},"tx":{"ratestring":"2.74 KB/s","bytespersecond":2810,"packetspersecond":26,"bytes":5620,"packets":52,"totalbytes":55858,"totalpackets":597}}
{"index":5,"seconds":10,"rx":{"ratestring":"815.37 KB/s","bytespersecond":834941,"packetspersecond":607,"bytes":1669883,"packets":1214,"totalbytes":3931429,"totalpackets":2883},"tx":{"ratestring":"18.80 KB/s","bytespersecond":19254,"packetspersecond":216,"bytes":38508,"packets":432,"totalbytes":94366,"totalpackets":1029}}
{"seconds":10,"rx":{"maxratestring":"867.84 KB/s","averageratestring":"383.93 KB/s","minratestring":"2.03 KB/s","totalbytes":3931429,"maxbytes":1777343,"minbytes":4163,"totalpackets":2883,"maxpackets":1281,"minpackets":20},"tx":{"maxratestring":"20.69 KB/s","averageratestring":"9.21 KB/s","minratestring":"653 B/s","totalbytes":94366,"maxbytes":42376,"minbytes":1306,"totalpackets":1029,"maxpackets":505,"minpackets":12}}