![]() ![]() |
Apr 2 2006, 03:27 PM
Post
#1
|
|
|
Its GNU/Linuxhelp.net ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Support Specialist Posts: 1,417 Joined: 3-January 04 From: Serbia and Montenegro (SCG) 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 http://www.ba.cnr.it/~paolo/pmacct/ CODE 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 wget http://www.ba.cnr.it/~paolo/pmacct/pmacct-0.10.0.tar.gz wget http://projects.celuloza.ro/bwstat/file.php?file=15 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 : CODE cd /home/pmacct-0.10.0 make clean ./configure --enable-mysql make make install then we create the following config file under /usr/local/etc pmacctd.conf Instead of eth5 use the interface that is connected to the firewall or internet directly. (for better understanding) eth4------| eth3------| eth2------|router|---eth5 eth1------| CODE ! ! 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 networks.def CODE ! ! local networks ! 192.168.0.0/24 192.168.1.0/24 192.168.2.0/24 192.168.4.0/24 192.168.11.0/24 Then we create the mysql database for pmaact and grant access for it only for user pmacct with password 123456 like this : CODE mysqladmin -u root create pmacct mysql then type the following : CODE grant all privileges on pmacct.* to pmacct@localhost identified by "123456"; quit Ok so now we are done with preparing mysql, let's configure bwstat. CODE cd /home/bwstat-0.25 cd config ./install 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 CODE mv config.php.default config.php and edit config.php like this CODE <? // $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 CODE mv bwstat-0.25 bwstat Edit the following two lines in /etc/httpd/httpd.conf CODE <DocumentRoot "/home/webpage/bwstat"> <Directory "/home/webpage/bwstat"> Then we restart httpd like this : CODE /etc/init.d/httpd restart Then finally we launch pmacct like this : CODE 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. Sincerely Robert B -------------------- Robert Becskei
robert83@linuxhelp.net -------------------- May the source be with us! -------------------- AMD X2-3800 @ 2400Mhz 2048MB DDR 400Mhz DFI Lanparty UT4 NF4 ULTRA-D GeForce 7800GT 250GB+250GB Pioneer DVD-RW 17inch Samsung Syncmaster 757NF WinXP Pro (SP2)/ CentOS 4.3 -------------------- |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 4th December 2008 - 03:53 PM |