Vnstat: Difference between revisions

From Leo's Notes
This page was last edited on 29 March 2015, at 05:17.
No edit summary
No edit summary
Line 1: Line 1:
== Installation ==
== Installation ==
The following steps should work for CentOS/ScientificLinux/RHEL.
Vnstat should be available through the yum package manager via the EPEL repository.
 
=== Installing from Source ===
The following instructions will set up vnstat from source and should work for CentOS/ScientificLinux/RHEL linux distributions.  


<syntaxhighlight lang="bash" line start="1" enclose="div">
<syntaxhighlight lang="bash" line start="1" enclose="div">
Line 18: Line 21:
You do not need to interface with vnstat directly since vnstat will create a cronjob in <code>/etc/cron.d/vnstat</code> which will run <code>/usr/sbin/vnstat.cron</code> as nobody every 5 minutes.
You do not need to interface with vnstat directly since vnstat will create a cronjob in <code>/etc/cron.d/vnstat</code> which will run <code>/usr/sbin/vnstat.cron</code> as nobody every 5 minutes.


However, you may need to fix or initialize the database.
Depending on how your network interfaces are named and the number of interfaces you have, you may need to fix or initialize the vnstat database.


=== Initializing Database ===
=== Initializing Database ===
Line 26: Line 29:
=== Force Update ===
=== Force Update ===
  sudo -u /usr/sbin/vnstat.cron --force
  sudo -u /usr/sbin/vnstat.cron --force




Line 32: Line 34:
[[Category:Guides]]
[[Category:Guides]]
[[Category:Linux]]
[[Category:Linux]]
{{Navbox Services}}

Revision as of 05:17, 29 March 2015

Installation

Vnstat should be available through the yum package manager via the EPEL repository.

Installing from Source

The following instructions will set up vnstat from source and should work for CentOS/ScientificLinux/RHEL linux distributions.

wget http://humdi.net/vnstat/vnstat-1.11.tar.gz
tar -xzf vnstat-1.11.tar.gz
cd vnstat-1.11
make
make install
vnstat --testkernel
/bin/cp examples/init.d/centos/vnstat /etc/init.d/vnstat
chkconfig --levels 234 --add vnstat
vnstat -u -i eth0
/etc/init.d/vnstat start

Usage

You do not need to interface with vnstat directly since vnstat will create a cronjob in /etc/cron.d/vnstat which will run /usr/sbin/vnstat.cron as nobody every 5 minutes.

Depending on how your network interfaces are named and the number of interfaces you have, you may need to fix or initialize the vnstat database.

Initializing Database

To initialize a database for a specific device:

vnstat -u -i $NetInterface

Force Update

sudo -u /usr/sbin/vnstat.cron --force