You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Paul Chvostek <pa...@it.ca> on 2003/07/04 19:04:00 UTC
[users@httpd] Logging to MySQL?
I've been looking at Apache's mod_log_mysql and mod_mylo, and if I don't
need the extended featureset offered by mod_log_mysql, I can't help but
wonder if I'd get any better performance than with something like:
LogFormat "INSERT INTO httpdlog (vhost,host,logname,...) ('%v','%h','%l',...);" mysqlfmt
CustomLog "|/usr/local/bin/mysql -uuser -ppass logdb" mysqlfmt
Aside from the potential security issue of having a MySQL password
visible to a 'ps' command, what's the disadvantage of simply piping
INSERT statements directly into the text client?
I would think that a single instance of the mysql text client would
count as a "persistent" connection, and even the overhead of a shell
wrapper can't be much more than that of the mod_log_mysql DSO.
Any thoughts? Do I really need the module? Will it save me memory?
--
Paul Chvostek <pa...@it.ca>
Operations / Abuse / Whatever
it.canada, hosting and development http://www.it.ca/
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Logging to MySQL?
Posted by Paul Chvostek <pa...@it.ca>.
On Fri, Jul 04, 2003 at 10:57:21PM +0200, Max Dittrich wrote:
> >
> > LogFormat "INSERT INTO httpdlog (vhost,host,logname,...) ('%v','%h','%l',...);" mysqlfmt
> > CustomLog "|/usr/local/bin/mysql -uuser -ppass logdb" mysqlfmt
>
> Single quotes doesn't get escaped by mod_log_config, so you can get in
> trouble logging %r.
Hrm.... How 'bout:
LogFormat "--\n%v\n%h\n%l\n%r\n...\n" logbyline
CustomLog "|/root/bin/logbyline2mysql" logbyline
And /root/bin/logbyline2mysql:
======== 8< CUT HERE 8< =========
#!/usr/bin/awk -f
BEGIN {
cmd="/usr/local/bin/mysql -uuser -ppass logdb";
fmt="INSERT INTO httpdlog (vhost,host,logname,req,...) ('%s','%s','%s','%s',...);";
}
$0 ~ /--/ {
getline v;
getline h;
getline l;
getline r; r=gensub("'","''","g",r);
...
printf (fmt, v, h, l, r, ...) | cmd;
}
======== 8< CUT HERE 8< =========
Could be optimized a bit, but would pre-processing through awk still
take less resources than loading another module?
--
Paul Chvostek <pa...@it.ca>
Operations / Abuse / Whatever
it.canada, hosting and development http://www.it.ca/
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Logging to MySQL?
Posted by Max Dittrich <Ma...@t-online.de>.
Paul Chvostek wrote:
> I've been looking at Apache's mod_log_mysql and mod_mylo, and if I don't
> need the extended featureset offered by mod_log_mysql, I can't help but
> wonder if I'd get any better performance than with something like:
>
> LogFormat "INSERT INTO httpdlog (vhost,host,logname,...) ('%v','%h','%l',...);" mysqlfmt
> CustomLog "|/usr/local/bin/mysql -uuser -ppass logdb" mysqlfmt
Single quotes doesn't get escaped by mod_log_config, so you can get in
trouble logging %r.
[...]
2cents,
.max
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org