Difference between revisions of "VnStat"

From ArchWiki
Jump to navigation Jump to search
m (→‎Usage: Changing command options to long options)
 
(25 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 +
{{lowercase title}}
 
[[Category:Networking]]
 
[[Category:Networking]]
{{lowercase title}}
+
[[ja:VnStat]]
[http://humdi.net/vnstat/ vnStat] is a lightweight network traffic monitor. It keeps a network traffic log on selectable interfaces. Through the command line the network traffic statistics can be shown.
+
[[ru:VnStat]]
==Installation==
+
[http://humdi.net/vnstat/ vnStat] is a lightweight (command line) network traffic monitor. It monitors selectable interfaces and stores network traffic logs in a database for later analysis.
The {{Pkg|vnStat}} package is available in [community]:
+
 
# pacman -S vnstat
+
== Installation ==
==Configuration==
+
 
===Setting the interfaces===
+
[[Install]] the {{Pkg|vnstat}} package.
First introduce every interface that needs to be logged to vnStat. For example a wired interface:
+
 
# vnstat -u -i eth0
+
== Configuration ==
Or a wireless interface:
+
 
# vnstat -u -i wlan0
+
[[systemd#Using units|Start/Enable]] the {{ic|vnstat.service}} daemon.
 +
 
 +
Pick a preferred network interface and edit the {{ic|Interface}} variable in the {{ic|/etc/vnstat.conf}} accordingly. To list all interfaces available to vnstat, use {{ic|vnstat --iflist}}.
  
When introducing an interface for the first time there will be an error message saying 'unable to read database'. If this message is followed by an info message saying 'a new database has been created' the interface is successfully introduced. If this is not the case check that the specified interface is valid.
+
To start monitoring a particular interface that was not referred to in the configuration file when the daemon was started, you must initialize a database first. Each interface needs its own database. The command to initialize one for the {{ic|eth0}} interface is:
 +
# vnstat --add -i eth0
  
===Updating method===
+
Remember to [[restart]] the {{ic|vnstat.service}} daemon after you have added a new interface.
After introducing the interface(s) set one of the update methods.
 
{{Warning| Only use one of the methods, do not use them at the same time!}}
 
====Cron====
 
The first method is using [[Cron]]. A sample of Cron usage is provided with vnStat at {{ic|/usr/share/doc/vnstat/examples/vnstat.cron}}.
 
====Service====
 
The second way is using [[systemd]] (and the provided service):
 
# systemctl start vnstat.service
 
====Daemon====
 
The third way of updating is using a daemon provided by vnStat. Add vnstat to your daemons in [[rc.conf#Daemons]].
 
DAEMONS=(... network vnstat ...)
 
  
===Global settings===
+
== Usage ==
Other settings, like settings to control the daemon, can be done in {{ic|/etc/vnstat.conf}}.
 
  
==Usage==
 
 
Query the network traffic:
 
Query the network traffic:
  # vnstat -q
+
  # vnstat --query
  
 
Viewing live network traffic usage:
 
Viewing live network traffic usage:
  # vnstat -l
+
  # vnstat --live
  
For all the other options, use:
+
To find more options, use:
 
  # vnstat --help
 
  # vnstat --help
Or for a complete list, use:
+
or to see all options use:
 
  # vnstat --longhelp
 
  # vnstat --longhelp
 
==See Also==
 
[http://gotux.net/arch-linux/vnstat-network-monitor/ VnStat Custom WebUI]
 

Latest revision as of 19:24, 8 March 2019

vnStat is a lightweight (command line) network traffic monitor. It monitors selectable interfaces and stores network traffic logs in a database for later analysis.

Installation

Install the vnstat package.

Configuration

Start/Enable the vnstat.service daemon.

Pick a preferred network interface and edit the Interface variable in the /etc/vnstat.conf accordingly. To list all interfaces available to vnstat, use vnstat --iflist.

To start monitoring a particular interface that was not referred to in the configuration file when the daemon was started, you must initialize a database first. Each interface needs its own database. The command to initialize one for the eth0 interface is:

# vnstat --add -i eth0

Remember to restart the vnstat.service daemon after you have added a new interface.

Usage

Query the network traffic:

# vnstat --query

Viewing live network traffic usage:

# vnstat --live

To find more options, use:

# vnstat --help

or to see all options use:

# vnstat --longhelp