no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | apache2mysql [2012/10/16 22:05] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======= Insert apache log summaries into mysql database ======= | ||
+ | ===== Synopsis ===== | ||
+ | I wrote this tool to get loadtimes over the course of a day from apachelogs into a SQL database for reporting, graphing and further analysis. | ||
+ | |||
+ | Uses awk, and mysqlimport for maximum performance | ||
+ | performance: | ||
+ | |||
+ | ===== Compability ===== | ||
+ | Tested on FreeBSD 6.4 and FreeBSD 8.0. | ||
+ | |||
+ | ===== Requirements ===== | ||
+ | |||
+ | ==== Apache ==== | ||
+ | |||
+ | Requires custom logformat as specified here | ||
+ | note: this was created for java, hence the JSESSIONID, if you have a session id as a cookiefield replace JSESSIONID with your cookie field. | ||
+ | |||
+ | <file txt httpd.conf> | ||
+ | LogFormat "%t %v %h %{JSESSIONID}C %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | ||
+ | </ | ||
+ | |||
+ | ==== MySQL ==== | ||
+ | |||
+ | Requires a destination mysql table | ||
+ | <file sql create_database.sql> | ||
+ | CREATE TABLE IF NOT EXISTS tablename ( datetime datetime NOT NULL, hostname varchar(32) NOT NULL, url varchar(200) NOT NULL, avgsize float NOT NULL, avgtime float NOT NULL, hits int(11) NOT NULL, PRIMARY KEY (datetime, | ||
+ | </ | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | < | ||
+ | $path/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== SQL Examples ===== | ||
+ | |||
+ | get statistics averaged by day instead of hour. | ||
+ | |||
+ | <file sql dayavg.sql> | ||
+ | SELECT DATE(datetime) as date, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Download ===== | ||
+ | |||
+ | Latest version 1.0 {{files: | ||
+ | |||
+ | |||
+ | ===== Changelog ===== | ||
+ | === 1.0 === | ||
+ | o Initial public release |