Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Closed TopicStart new topic
> IP Accouting with CentOS 3.x or 4.x
post Apr 2 2006, 03:27 PM
Post #1

Its GNU/

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069

Hello everyone,

This one is going to be a guide about how to setup a box with CentOS 3.x or 4.x , that will allow you to monitor traffic per user for your entire lan.
I will only cover the configuration of this software and not the entire machine, please note that this software would be installed on your primary router.
NOTE: make sure that the proxy server is not before the primary router , because if it is traffic will not be correctly counted, so the best thing to do is, to put the proxy server after the primary router.

Okay let's start by downloading the software from this website

yum install httpd php php-mysql mysql mysql-devel mysql-server zlib-devel autoconf automake
chkconfig httpd on
chkconfig mysqld on
/etc/init.d/mysqld start
cd /home
tar -xvzf pmacct-0.10.0.tar.gz
tar -xvzf bwstat-0.25.tar.bz2

then we compile the source code for pmacct with mysql support like this :
cd /home/pmacct-0.10.0
make clean
./configure --enable-mysql
make install

then we create the following config file under /usr/local/etc

Instead of eth5 use the interface that is connected to the firewall or internet directly.
(for better understanding)

! pmacct: In + Out
debug: false
daemonize: true
interface: eth5
networks_file: /usr/local/etc/networks.def
aggregate : src_host,dst_host
plugins : mysql
sql_db : pmacct
sql_table : acct
sql_table_version : 1
sql_passwd : 123456
sql_user : pmacct
sql_refresh_time : 60
sql_history : 1h
sql_history_roundoff : mh

! local networks

Then we create the mysql database for pmaact and grant access for it only for user pmacct with password 123456 like this :

mysqladmin -u root create pmacct

then type the following :
grant all privileges on pmacct.* to pmacct@localhost identified by "123456";

Ok so now we are done with preparing mysql, let's configure bwstat.

cd /home/bwstat-0.25
cd config

Using localhost,database=pmacct,username=pmacct,password=123456,webusername=pmacct,web
userpassword=123456. Once done it should report that the installation finished successfully and you'll need to configure the rest of the things
in config.php .

Let's just rename config.php.default to config.php
mv config.php.default config.php

and edit config.php like this
// $Id: config.php.example,v 1.9 2004/10/04 14:45:36 eu Exp $

/* title of the page, of course */
$title = "- Internet Usage Statistics -";

/* theme - you can write here the name of the folders from themes */
$theme = "blue";

/* your sql user/password/database/etc */
$sqluser = "pmacct";
$sqlpass = "123456";
$sqldb = "pmacct";
$sqlhost = "localhost";

/* auto refresh the page after $refresh seconds */
$refresh = "60";

maximum number of hosts to show on a page
depends on your cpu/ram
if you have too many hosts on one page, the execution time of the script
exceeds the maximum execution time specified in php.ini and gets dropped.
$max_hosts_per_page = 150;

/* display hostnames instead of ips */
$hostnames = 1;

/* by default show stats for this $show_by. can be year month day or hour */
$show_by = "month";

/* by default sort stats by $sort_by $sort_type */
$sort_by = "ip";
$sort_type = "asc";

use ipfm or pmacct for getting stats
pmacct uses a lot less cpu

$use = "pmacct";

pmacct stuff
valid only if you $use="pmacct"

/* available years */
$pmacct_available_years = "2006 2007";

table where accounting data is
you shouldn't change it
$pmacct_table = "acct";

directory for ipfm logs
valid only if you $use="ipfm"
$ipfmdir = "/var/log/ipfm";

/* show php warnings/errors default = 0 */
$debug = 0;

Then we rename the bwstat-0.25 to bwstat and configure httpd to serve stuff from /home/bwstat
mv bwstat-0.25 bwstat

Edit the following two lines in /etc/httpd/httpd.conf
<DocumentRoot "/home/webpage/bwstat">
<Directory "/home/webpage/bwstat">

Then we restart httpd like this :
/etc/init.d/httpd restart

Then finally we launch pmacct like this :
pmacctd -f /usr/local/etc/pmacctd.conf

If it shows no errors that means it has succesfully started running. Then for our last step we go to
our webbrowser and type in the ip address of this server.

The login page will show up, where you will type username : admin and password : 123456 .

Next you click on hosts, and there you can add new hosts, you wish to monitor, this is all that needs to be done, you will see in about a minute or two that the counters will start to go up for monitored host.

You can of course tweak your config.php file as you need, not everyone's favorite color is blue, and not everyone likes to have 150 machines on one page.

Robert B

Robert Becskei
May the source be with us!
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 21st October 2017 - 08:09 PM