Difference between revisions of "Vnstat"

From SME Server
Jump to navigationJump to search
(Add link to vnstat php frontend page)
(making more generic through use of YUM and ensuring reader obtains the latest)
Line 1: Line 1:
{{Needs review}}
+
{{Level|Medium}}
 +
===Description===
 
"vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s)." ([http://humdi.net/vnstat/ Read more...])
 
"vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s)." ([http://humdi.net/vnstat/ Read more...])
  
How to install vnstat and the the PHP frontent.<br>
+
Based on How to install vnstat and the the PHP frontent.<br>
 
[Original post http://forums.contribs.org/index.php?topic=42444]<br>
 
[Original post http://forums.contribs.org/index.php?topic=42444]<br>
==Install vnstat==
+
 
 +
===Configure necessary repositories===
 +
You can either obtain the package directly or set up the Dag repository. If not already configured, the Dag repsository can be set up as follows:
 +
====Dag====
 +
{{Repository|Dag}}
 +
 
 +
===Install vnstat===
 +
====Using Yum====
 +
If you have configured the dag repository, installation is as simple as:
 +
yum install vnstat --enablerepo=dag
 +
====Manually====
 +
If you have not configured the Dag repository then the following applies.
 +
 
 +
Search for the package at http://dag.wieers.com and find the latest and adjust the wget line as appropriate.
 +
 
 
Get vnstat and install:
 
Get vnstat and install:
 
  wget http://dag.wieers.com/rpm/packages/vnstat/vnstat-1.4-3.2.el4.rf.i386.rpm
 
  wget http://dag.wieers.com/rpm/packages/vnstat/vnstat-1.4-3.2.el4.rf.i386.rpm
 
  yum localinstall vnstat-1.4-3.2.el4.rf.i386.rpm
 
  yum localinstall vnstat-1.4-3.2.el4.rf.i386.rpm
  
 +
====Add the monitored Interfaces====
 
Add the interfaces you would like to monitor:
 
Add the interfaces you would like to monitor:
 
  vnstat -u -i eth0
 
  vnstat -u -i eth0
 
  vnstat -u -i eth1
 
  vnstat -u -i eth1
  
(Ignore the error message you get)
+
You should get an error about the database not existing but it will also say it created it. It is safe to ignore the error message.
  
==Install vnStat PHP FrontEnd==
+
===Install vnStat PHP FrontEnd===
 
"...Since vnStat is console mode only I created this script to make a 'nice' report of the data collected by vnStat...." ([http://www.sqweek.com/sqweek/index.php?p=1 Read More)]
 
"...Since vnStat is console mode only I created this script to make a 'nice' report of the data collected by vnStat...." ([http://www.sqweek.com/sqweek/index.php?p=1 Read More)]
  
 +
There is no yum repo for this so you will need to go to: http://www.sqweek.com/sqweek/index.php?p=1 to find the latest. Determine the link to the latest release and replace the '''wget''' command (below) accordingly.
 +
 +
The below instructions put the file into the Primary ibay, you can also put it in a dedicated ibay or in /opt as suits your needs and security requirements.
  
 
Get the frontend and configure:
 
Get the frontend and configure:
 
  cd /home/e-smith/files/ibays/Primary/html/
 
  cd /home/e-smith/files/ibays/Primary/html/
  wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.tar.gz
+
  wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz
  tar -xvzf vnstat_php_frontend-1.4.tar.gz
+
  tar -xvzf vnstat_php_frontend-1.4.1.tar.gz
  cd vnstat_php_frontend-1.4
+
  cd vnstat_php_frontend-1.4.1
 
nano config:<br>
 
nano config:<br>
 
Edit the information about the interfaces you would like to graph:
 
Edit the information about the interfaces you would like to graph:
  $iface_list = array('eth0', 'ppp0');
+
  $iface_list = array('eth0', 'eth1');
 
The optional names:  
 
The optional names:  
 
  $iface_title['eth0'] = 'Internal';
 
  $iface_title['eth0'] = 'Internal';
  $iface_title['ppp0'] = 'Internet';
+
  $iface_title['eth1'] = 'Internet';
 
Finnaly set application path:
 
Finnaly set application path:
 
  $vnstat_bin = '/usr/bin/vnstat';
 
  $vnstat_bin = '/usr/bin/vnstat';
Line 35: Line 54:
 
  chmod 666 /var/lib/vnstat/*;
 
  chmod 666 /var/lib/vnstat/*;
  
Wait and you should see the application working at http://yourserverIP/vnstat_php_frontend-1.4
+
Wait and you should see the application working at http://yourserverIP/vnstat_php_frontend-1.4.1
  
 
----
 
----
 
[[Category: Howto]]
 
[[Category: Howto]]
 
[[Category: Administration]]
 
[[Category: Administration]]

Revision as of 17:53, 7 December 2008

PythonIcon.png Skill level: Medium
The instructions on this page require a basic knowledge of linux.


Description

"vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s)." (Read more...)

Based on How to install vnstat and the the PHP frontent.
[Original post http://forums.contribs.org/index.php?topic=42444]

Configure necessary repositories

You can either obtain the package directly or set up the Dag repository. If not already configured, the Dag repsository can be set up as follows:

Dag

The following command will configure the Dag repository on SME Server. EDIT NOT COMPLETE!


To create an entry in the database for the epel repository we open put the following commands in a terminal window or in a shell window:

/sbin/e-smith/db yum_repositories set epel repository \

Name 'SME Server - epel' \
BaseURL 'http://<http://download.fedoraproject.org/pub/epel/7/$basearch' \
EnableGroups yes \
GPGCheck yes \
Visible no \
status disabled

To enable the changes:

    signal-event yum-modify

Just to be sure, give yum a fresh start:

    yum clean all

After adding it to the database we have to update the changes to the configuration file:

signal-event yum-modify

Install vnstat

Using Yum

If you have configured the dag repository, installation is as simple as:

yum install vnstat --enablerepo=dag

Manually

If you have not configured the Dag repository then the following applies.

Search for the package at http://dag.wieers.com and find the latest and adjust the wget line as appropriate.

Get vnstat and install:

wget http://dag.wieers.com/rpm/packages/vnstat/vnstat-1.4-3.2.el4.rf.i386.rpm
yum localinstall vnstat-1.4-3.2.el4.rf.i386.rpm

Add the monitored Interfaces

Add the interfaces you would like to monitor:

vnstat -u -i eth0
vnstat -u -i eth1

You should get an error about the database not existing but it will also say it created it. It is safe to ignore the error message.

Install vnStat PHP FrontEnd

"...Since vnStat is console mode only I created this script to make a 'nice' report of the data collected by vnStat...." (Read More)

There is no yum repo for this so you will need to go to: http://www.sqweek.com/sqweek/index.php?p=1 to find the latest. Determine the link to the latest release and replace the wget command (below) accordingly.

The below instructions put the file into the Primary ibay, you can also put it in a dedicated ibay or in /opt as suits your needs and security requirements.

Get the frontend and configure:

cd /home/e-smith/files/ibays/Primary/html/
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz
tar -xvzf vnstat_php_frontend-1.4.1.tar.gz
cd vnstat_php_frontend-1.4.1

nano config:
Edit the information about the interfaces you would like to graph:

$iface_list = array('eth0', 'eth1');

The optional names:

$iface_title['eth0'] = 'Internal';
$iface_title['eth1'] = 'Internet';

Finnaly set application path:

$vnstat_bin = '/usr/bin/vnstat';

Then change permission on /var/lib/vnstat/* files

chmod 666 /var/lib/vnstat/*;

Wait and you should see the application working at http://yourserverIP/vnstat_php_frontend-1.4.1