LOG_DB_DAEMON(8) User Contributed Perl Documentation LOG_DB_DAEMON(8) (NAME) log_db_daemon - Squid 0.5. (SYNOPSIS) log_db_daemon DSN [] (DESCRIPTION) access.log Squid . squid . : squid-2.7 Squid-3.2 mysql 5.0.26 and 5.1 perl 5.8.8 OpenSUSE 10.2 (OPTIONS) DSN (DSN) . access_log . : access_log daemon:/host/database/table/username/password squid : access_log daemon://database/table/username/password squid "DBI:mysql:database=squid" --debug (stderr). (CONFIGURATION) Squid (Squid configuration) access_log (access log) . access_log daemon:/mysql_host:port/database/table/username/password squid 'daemon' Squid logfile_daemon . Squid . squid . mysql_host:port mysql . 'localhost' . database . 'squid_log' . table . 'access_log' . username . 'squid' . password . . : access_log daemon:/ squid ( ) (null) : access_log daemon://///password squid logfile_daemon Squid . logfile_daemon /path/to/squid/libexec/logfile-daemon_mysql.pl . (Database configuration) 'squid_log' 'access_log' . 'squid' . (Database) : CREATE DATABASE squid_log; (User) : GRANT INSERT,SELECT,CREATE ON squid_log.* TO 'squid'@'localhost' IDENTIFIED BY 'squid'; FLUSH PRIVILEGES; CREATE INSERT SELECT 'squid' . . (Table) . : 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 EXTRACTION) (Sample queries) () SELECT DISTINCT ip_client FROM access_log; SELECT DATE(FROM_UNIXTIME(time_since_epoch)) AS date_day, COUNT(*) AS num_of_requests FROM access_log GROUP BY 1 ORDER BY 1; : SELECT squid_request_status, COUNT(*) AS n FROM access_log GROUP BY squid_request_status ORDER BY 2 DESC; : SELECT squid_request_status, (COUNT(*)/(SELECT COUNT(*) FROM access_log)*100) AS percentage FROM access_log GROUP BY squid_request_status ORDER BY 2 DESC; HIT MISS: SELECT 'hits', (SELECT COUNT(*) FROM access_log WHERE squid_request_status LIKE '%HIT%') / (SELECT COUNT(*) FROM access_log)*100 AS percentage UNION SELECT 'misses', (SELECT COUNT(*) FROM access_log WHERE squid_request_status LIKE '%MISS%') / (SELECT COUNT(*) FROM access_log)*100 AS percentage; SELECT '0..500', COUNT(*)/(SELECT COUNT(*) FROM access_log)*100 AS percentage FROM access_log WHERE time_response >= 0 AND time_response < 500 UNION SELECT '500..1000', COUNT(*)/(SELECT COUNT(*) FROM access_log)*100 AS percentage FROM access_log WHERE time_response >= 500 AND time_response < 1000 UNION SELECT '1000..2000', COUNT(*)/(SELECT COUNT(*) FROM access_log)*100 AS percentage FROM access_log WHERE time_response >= 1000 AND time_response < 2000 UNION SELECT '>= 2000', COUNT(*)/(SELECT COUNT(*) FROM access_log)*100 AS percentage FROM access_log WHERE time_response >= 2000; MIME SELECT http_mime_type, SUM(http_reply_size) as total_bytes FROM access_log GROUP BY http_mime_type ORDER BY 2 DESC; SELECT ip_client, SUM(http_reply_size) AS total_bytes FROM access_log GROUP BY 1 ORDER BY 2 DESC; (KNOWN ISSUES) (Speed issues) MyISAM InnoDB (referential integrity) . "ENGINE=MYISAM" SQL . () . DDL . (Table cleanup) "L" ( << >>) . . "rotate log" ( ) << >> . Squid . (Testing) ( ) . . (AUTHORS) Marcello Romani Amos Jeffries . (COPYRIGHT) * Copyright (C) 1996-2026 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. (C) 2008 Marcello Romani Perl Perl 5.8.8 ( ) Perl 5 . (QUESTIONS) Squid . (REPORTING BUGS) . https://wiki.squid-cache.org/SquidFaq/BugReporting . https://bugs.squid-cache.org Squid Bugs Squid (SEE ALSO) squid(8) GPL(7) Squid https://wiki.squid-cache.org/SquidFaq Squid http://www.squid-cache.org/Doc/config perl v5.42.2 2026-08-25 LOG_DB_DAEMON(8)