|
NAMElog_db_daemon - Database logging daemon for SquidVersion 0.5. SYNOPSISlog_db_daemon DSN [options]DESCRIPTIONThis program writes Squid access.log entries to a database. Presently only accepts the squid native log format.The script has been developed and tested in the following environment:
OPTIONS
CONFIGURATIONSquid configurationaccess_log directiveThe path to the access log file is used to provide the database connection parameters. access_log daemon:/mysql_host:port/database/table/username/password squid The 'daemon' prefix is mandatory and tells squid that the logfile_daemon helper is to be used instead of the normal file logging. The last parameter tells squid which log format to use when writing lines to the log daemon. Presently squid format is supported.
To leave all fields to their default values, you can use a single slash: access_log daemon:/ squid To specify only the database password, which by default is empty, you must leave unspecified all the other parameters by using null strings: access_log daemon://///password squid logfile_daemon directive This is the current way of telling squid where the logfile daemon resides. logfile_daemon /path/to/squid/libexec/logfile-daemon_mysql.pl The script must be copied to the location specified in the directive. Database configurationLet's call the database 'squid_log' and the log table 'access_log'. The username and password for the db connection will be both 'squid'.Database Create the database: CREATE DATABASE squid_log; User Create the user: GRANT INSERT,SELECT,CREATE ON squid_log.* TO 'squid'@'localhost' IDENTIFIED BY 'squid'; FLUSH PRIVILEGES; Note that only CREATE, INSERT and SELECT privileges are granted to the 'squid' user. This ensures that the logfile daemon script cannot change or modify the log entries. Table The Daemon will attempt to initialize this table if none exists when it starts. The table created should look like: CREATE TABLE access_log ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, time_since_epoch DECIMAL(15,3), time_response INTEGER, ip_client CHAR(15), ip_server CHAR(15), http_status_code VARCHAR(10), http_reply_size INTEGER, http_method VARCHAR(20), http_url TEXT, http_username VARCHAR(20), http_mime_type VARCHAR(50), squid_hier_status VARCHAR(20), squid_request_status VARCHAR(20) ); DATA EXTRACTIONSample queries.
KNOWN ISSUESSpeed issuesThe MyISAM storage engine is known to be faster than the InnoDB one, so although it doesn't support transactions and referential integrity, it might be more appropriate in this scenario. You might want to append "ENGINE=MYISAM" at the end of the table creation code in the above SQL script.Indexes should be created according to the queries that are more frequently run. The DDL script only creates an implicit index for the primary key column. Table cleanupThis script currently implements only the "L" (i.e. "append a line to the log") command, therefore the log lines are never purged from the table. This approach has an obvious scalability problem.One solution would be to implement e.g. the "rotate log" command in a way that would calculate some summary values, put them in a "summary table" and then delete the lines used to calculate those values. Similar cleanup code could be implemented in an external script and run periodically independently from squid log commands. TestingThis script has only been tested in low-volume scenarios (single client, less than 10 req/s). Tests in high volume environments could reveal performance bottlenecks and bugs.AUTHORThis program was written by Marcello Romani <marcello.romani@libero.it> , Amos Jeffries <amosjeffries@squid-cache.org>COPYRIGHT* Copyright (C) 1996-2021 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. Copyright (C) 2008 by Marcello Romani This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. QUESTIONSQuestions on the usage of this program can be sent to the Squid Users mailing list <squid-users@lists.squid-cache.org>REPORTING BUGSBug reports need to be made in English. See http://wiki.squid-cache.org/SquidFaq/BugReporting for details of what you need to include with your bug report.Report bugs or bug fixes using http://bugs.squid-cache.org/ Report serious security bugs to Squid Bugs <squid-bugs@lists.squid-cache.org> Report ideas for new improvements to the Squid Developers mailing list <squid-dev@lists.squid-cache.org> SEE ALSOsquid (8), GPL (7),The Squid FAQ wiki http://wiki.squid-cache.org/SquidFaq The Squid Configuration Manual http://www.squid-cache.org/Doc/config/
Visit the GSP FreeBSD Man Page Interface. |