PHP-cli app that implements a parser which reads the Apache access log and saves its content to a database.
php parser.php [ -f ] file [ -d ] database [ -t ] table
This command line can be used to execute a parser which reads the Apache access log, parses it and saves it to a database
- It parses a standard apache access.log file as reference
- It saves the input into a Mysql Table
- LogFormat:
%h %l %u %t % r %>s %b common
.
Speed sample:
- Computations :8297 ms
- System calls :5500 ms
- Total lines :86506 lines
Log sample line:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
- -f: (optional) Contains the url to the file
default value: /data/access_log
- -d: (optional) Contains the Database name (created if not exist)
default value: apache_log
- -t: (optional) Contains the table name (created if not exist)
default value: log
- I included an access log sample within the folder for test purpose.
- There is no need to create the database nor the table as this scripts creates one for each with default values. However these params can be changed directly inside the config file
/Conf/config.php
or passed directly as parameters in command line (see example of usage). - This script also provides a time analysis for the exec time.
Please change the user and password for database directly within the config file if it is not the default root user and empty password.
This is an Example of usage of this script: