1. IPFM configuration --------------------------- IPFM program should be configured like this: FILENAME "/var/log/ipfm/ipfm-global-%Y-%m-%d.log" DUMP EVERY 30 minutes CLEAR EVERY 1 day SORT TOTAL #RESOLVE Resolve option must be disabled! phpTrafMon works only on IP numbers Path for writing log files can be different, but file pattern (ipfm-global-%Y-%m-%d.log) must not be changed 2. MySQL --------------------------- You have to create a user and a database for phpTrafMon in MySQL MySQL user for phpTrafMon should have at least those privileges: select, insert, update and delete. phpTrafMon requires six tables, after creating a user and a db, just execute thost commands: CREATE TABLE `classification` ( `date` varchar(10) NOT NULL default '', `host` varchar(8) NOT NULL default '', `user_input` bigint(20) unsigned NOT NULL default '0', `user_output` bigint(20) unsigned NOT NULL default '0', `user_total` bigint(20) unsigned NOT NULL default '0', `net_input` bigint(20) unsigned NOT NULL default '0', `net_output` bigint(20) unsigned NOT NULL default '0', `net_total` bigint(20) unsigned NOT NULL default '0', `perc_input` tinyint(3) unsigned NOT NULL default '0', `perc_output` tinyint(3) unsigned NOT NULL default '0', `perc_total` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`date`) ) TYPE=MyISAM; CREATE TABLE `comments` ( `id` int(10) unsigned NOT NULL auto_increment, `host` varchar(8) NOT NULL default '', `type` varchar(20) NOT NULL default '', `event_time` int(10) unsigned NOT NULL default '0', `comment_time` int(10) unsigned NOT NULL default '0', `user` varchar(8) NOT NULL default '', `input` bigint(20) unsigned NOT NULL default '0', `output` bigint(20) unsigned NOT NULL default '0', `comment` text NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=14 ; CREATE TABLE `global` ( `host` varchar(8) NOT NULL default '', `input` bigint(30) unsigned NOT NULL default '0', `output` bigint(30) unsigned NOT NULL default '0', `total` bigint(30) unsigned NOT NULL default '0', PRIMARY KEY (`host`) ) TYPE=MyISAM; CREATE TABLE `hosts` ( `host` varchar(8) NOT NULL default '', `name` varchar(50) NOT NULL default '', `gg` int(10) unsigned NOT NULL default '0', `tlen` varchar(25) NOT NULL default '', `mail` varchar(75) NOT NULL default '', `comments` int(6) unsigned NOT NULL default '0', PRIMARY KEY (`host`) ) TYPE=MyISAM; CREATE TABLE `hourly_traffic` ( `date` varchar(11) NOT NULL default '', `hour` tinyint(2) unsigned NOT NULL default '0', `host` varchar(8) NOT NULL default '', `input` bigint(20) unsigned NOT NULL default '0', `output` bigint(20) unsigned NOT NULL default '0', `total` bigint(20) unsigned NOT NULL default '0', UNIQUE KEY `data` (`date`,`hour`,`host`) ) TYPE=MyISAM; CREATE TABLE `points` ( `host` varchar(8) NOT NULL default '', `input` int(10) unsigned NOT NULL default '0', `output` int(10) unsigned NOT NULL default '0', `total` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`host`) ) TYPE=MyISAM; 3. phpTrafMon configuration --------------------------- You have to fill some configuration directives in /inc/config.php Everything is described there. 4. Prepare logs [if you have older IPFM log files] --------------------------- Execute shell command as root: chmod 666 [path_to_logs]/* This will allow php co convert logfiles. If you had resolve option enabled, you have to convert host names to IP numbers. Just fill tools/convert.php and run it. In logs directory you have to make a dir for backup and make it writable for php mkdir backup chmod 777 backup Run tools/rebuild.php script, that will fill database. 5. Files and dirs access rights --------------------------- Some files and directories have to be writable for php Execute shell command as root: chmod 666 tools/ipfm.log chmod 666 tools/ipfm.rebuild.log chmod 777 backup 6. Crontab entries --------------------------- Write into crontab those entries: #Classification 15 0 * * * chmod 666 [path_to_logs]/* 10 0 * * * [path_to_wget]/wget http://localhost/[path_to_classification]/tools/write.php --output-document=/dev/null -q 5 * * * * [path_to_wget]/wget http://localhost/[path_to_classification]/tools/hourly.php --output-document=/dev/null -q If you do not have wget installed on your server, you have to find different way to execute mainterance scripts. You can do this using php shell command: php scriptname.php, but then you will have to change path to config and functions in files: * tools/write.php * tools/hourly.php (this way of running mainterance scripts was not tested)