Re: Virtual Host Logging Perl Script
Hi there, On Tue, 15 Jul 2003, Jez Hancock wrote: Does anyone how one could log errorlog entries in a similar manner to the script above - ie pipe the errorlog to a script which appends one copy of the error entry to a main error logfile and another copy to the virtual host's error logfile? It's possible, but I don't think you really want to do it. You would be asking the server to do more than is necessary while handling each request (you probably already are:). Would it not be better for example to rotate your logs frequently, and to process them afterwards, off-line? You would then have a choice of doing things with the various log file analysis tools too. If you are a little bit creative in what you log, it can be simple to extract the information you need for each vhost from one file. Have you considered using something other than flat files for logging? 73, Ged.
Re: Virtual Host Logging Perl Script
On Wed, Jul 16, 2003 at 12:40:06PM +0200, Guillaume Fougnies wrote: Wed, Jul 16, 2003 at 11:07:47AM +0100: Jez Hancock wrote: I would do this but we wanted to give our users 'live' logfiles, rather than making them wait until log rotation before being able to view them (or did I misunderstand you?). During my work on the ENodes project, i've developed a tiny threaded logger in c to manage internal logfiles (by webmaster/website/version). (you can rewrite it in perl with a 5.8.x built with thread...) Perl handlers send log lines through a UNIX socket to the logger which is opening logfiles when needed and keeping them opened. It avoids the overhead of opening and locking each time the file and provides as many online debug logfile as you ask. /me nods. This would save a lot of overhead. The only benefit of opening a new pipe each time I suppose is that you don't need to worry about rotation. The logger is launched in a 'PerlRequire' file. The client have a persistant connection to the logger. If it fits your needs, you can get sources here: http://www.enodes.org Server : utils/enodes_logger/enodes_logger.c Client module: enodes_core/modules/ENodes/Core/ApLog.pm Many thanks, I'll investigate now. Well ENodes sounds very interesting, particularly the part about webmasters being able to test new versioning without applying changes and the reduced httpd restart feature. Very interesting. Will certainly have a look at this, we're currently considering something called webcp, a PHP project which has much potential but is sitll unfortunately very much in beta. Thanks! -- Jez http://www.munk.nu/
Re: Virtual Host Logging Perl Script
Hi Jez, On Wed, 16 Jul 2003, Jez Hancock wrote: [snip] We started looking at mod_log_sql: [snip] but had trouble getting it to work on FreeBSD unfortunately. I'd have thought something a bit lighter might do for this. Right now it seems a bit silly having a separate ErrorLog line in each of the apache virtual host stubs, but as far as I am aware there isn't an easier way is there? You could look at mod_macro. 73, Ged.
RE: Virtual Host Logging Perl Script (mod_macro note)
Right now it seems a bit silly having a separate ErrorLog line in each of the apache virtual host stubs, but as far as I am aware there isn't an easier way is there? You could look at mod_macro. mod_macro (http://www.coelho.net/mod_macro) works great for me. I found that I had to make a few changes to get it to build for Apache 2.0.46. To wit: 110c110 module macro_module; --- module AP_MODULE_DECLARE_DATA macro_module; 810c810,811 char * name, * where, * recursion; --- char * name, * recursion; char * where = ???; 951c952 AP_DECLARE_DATA module macro_module = { --- module AP_MODULE_DECLARE_DATA macro_module = { The preload of 'where' may be redundant, I don't remember. I believe that the use of AP_MODULE_DECLARE_DATA was change that I had to make or nothing would build. YMMV mma
Re: Virtual Host Logging Perl Script (mod_macro note)
On Wed, Jul 16, 2003 at 12:40:10PM -0700, Marc M. Adkins wrote: Right now it seems a bit silly having a separate ErrorLog line in each of the apache virtual host stubs, but as far as I am aware there isn't an easier way is there? You could look at mod_macro. mod_macro (http://www.coelho.net/mod_macro) works great for me. I found that I had to make a few changes to get it to build for Apache 2.0.46. To My main motivation for running apache2 would be to make use of the PerChild MPM which from what I can glean is still not working :( This directive would save me a lot of hassles wrt running cgi scripts (php in particular) with the euid of the script owner. All this as I'm tussling with mod_suphp... -- Jez http://www.munk.nu/
Re: Virtual Host Logging Perl Script
Jez Hancock wrote: Hi, I've just written a short perl script to perform logging for our virtual hosts. The code has plenty of comments so I'll paste it below. My question is: would it be possible to use mod_perl in some way to perform the function of the script? In testing the speed of the script seems reasonable enough, is there a better way to do what I'm doing below? Take a look at: http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler a similar code will work for mp1 if you don't use 2.0. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Virtual Host Logging Perl Script
On Tue, Jul 15, 2003 at 01:32:11PM +0300, Stas Bekman wrote: Jez Hancock wrote: My question is: would it be possible to use mod_perl in some way to perform the function of the script? In testing the speed of the script seems reasonable enough, is there a better way to do what I'm doing below? Take a look at: http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler a similar code will work for mp1 if you don't use 2.0. Much obliged, that does look to be something I could use. Reminds me I need to be locking the logfile as well ;) Thanks Stas, -- Jez http://www.munk.nu/
Re: Virtual Host Logging Perl Script
On Tue, 2003-07-15 at 14:27, Jez Hancock wrote: On Tue, Jul 15, 2003 at 01:32:11PM +0300, Stas Bekman wrote: Take a look at: http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler a similar code will work for mp1 if you don't use 2.0. Much obliged, that does look to be something I could use. Reminds me I need to be locking the logfile as well ;) Actually, if you are just printing one short line I think you'll be fine without locking on unix systems. See the FAQ: http://www.perldoc.com/perl5.8.0/pod/perlfaq5.html#All-I-want-to-do-is-append-a-small-amount-of-text-to-the-end-of-a-file.--Do-I-still-have-to-use-locking- - Perrin
Re: Virtual Host Logging Perl Script
Perrin Harkins wrote: On Tue, 2003-07-15 at 14:27, Jez Hancock wrote: On Tue, Jul 15, 2003 at 01:32:11PM +0300, Stas Bekman wrote: Take a look at: http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler a similar code will work for mp1 if you don't use 2.0. Much obliged, that does look to be something I could use. Reminds me I need to be locking the logfile as well ;) Actually, if you are just printing one short line I think you'll be fine without locking on unix systems. See the FAQ: http://www.perldoc.com/perl5.8.0/pod/perlfaq5.html#All-I-want-to-do-is-append-a-small-amount-of-text-to-the-end-of-a-file.--Do-I-still-have-to-use-locking- Is this still correct in the threaded environment where the filehandle is shared across several threads? The writes are atomic 4k or so, indeed, but what happens if two threads write to the same filehandle at the same time on the SMP machine? Won't things get messed up? I haven't checked, perhaps perlio already provides an internal locking. Arthur would be a good person to ask. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Virtual Host Logging Perl Script
On Tue, 2003-07-15 at 16:11, Stas Bekman wrote: Is this still correct in the threaded environment where the filehandle is shared across several threads? Why would the filehandle be shared? Wouldn't you open a new handle in each thread? I expect this would be fine, since the behavior is enforced by the system library rather than by Perl. You can always use flock if you're feeling paranoid about it though. - Perrin
Re: Virtual Host Logging Perl Script
On Tue, Jul 15, 2003 at 02:39:18PM -0400, Perrin Harkins wrote: On Tue, 2003-07-15 at 14:27, Jez Hancock wrote: Much obliged, that does look to be something I could use. Reminds me I need to be locking the logfile as well ;) Actually, if you are just printing one short line I think you'll be fine without locking on unix systems. See the FAQ: http://www.perldoc.com/perl5.8.0/pod/perlfaq5.html#All-I-want-to-do-is-append-a-small-amount-of-text-to-the-end-of-a-file.--Do-I-still-have-to-use-locking- Ok thanks Perrin. The script is actually running nicely as it is right now on a server hosting 50 or so domains, although admittedly it's not taking a massive number of hits (10,000 or so per day). Does anyone how one could log errorlog entries in a similar manner to the script above - ie pipe the errorlog to a script which appends one copy of the error entry to a main error logfile and another copy to the virtual host's error logfile? -- Jez http://www.munk.nu/
Re: Virtual Host Logging Perl Script
Perrin Harkins wrote: On Tue, 2003-07-15 at 16:11, Stas Bekman wrote: Is this still correct in the threaded environment where the filehandle is shared across several threads? Why would the filehandle be shared? Wouldn't you open a new handle in each thread? Because it's shared on the OS level. You open a new perl IO handle in each thread, but I think that they all use the same filedescriptor underneath. I think Arthur was mentioning that at his ithreads talk. Need to run some tests to confirm that. I expect this would be fine, since the behavior is enforced by the system library rather than by Perl. You can always use flock if you're feeling paranoid about it though. Are you sure? Won't flock maintain a process-wide flag? Unless there is a special threads-aware implementation that does it right. This is of course just rambling based on known issuws with all the other process-wide variables like cwd, chroot, environ, etc. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: virtual host server root
I'm trying to create a root directory for each of my virtuals. the realm of the virtual that certainly shouldn't be within [snip] I've come up with three solutions, none of which I particularly like for various reasons. Have you looked at mod_macro? mod_macro has been a godsend for me. I was about thisclose to writing something to generate my http.conf for me. -- %_=split/;/,.;;n;u;e;ot;t;her;c; . # Andy Lester 'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'. # http://petdance.com hack;print map delete$_{$_},split//,q [EMAIL PROTECTED]
Re: virtual host server root
On Mar 01, 2002 at 19:30:37 +, Ged Haywood wrote: Hi there, On Wed, 27 Feb 2002, Rick Myers wrote: I'm trying to create a root directory for each of my virtuals the realm of the virtual that certainly shouldn't be within [snip] I've come up with three solutions, none of which I particularly like for various reasons Have you looked at mod_macro? I hadn't until now, but it looks interesting Not quite what I had in mind though Thanks --rick
Re: Virtual Host?
I set up something similar recently. What I would recommend is setting up a separate samba view to 'just' that dirctory on your unix disk which you wish to make publically accessible - set this up in your smb.conf file. You can specify valid users (just the webserver?), whether it is writable accross the network, default netmask etc. You can then set appropriate write permissions on it, without making your whole secure and wonderful unix partion vulnerable to access from your not so wonderful NT server. If you only need a view to those files which you want to add to your web server readable directories, there is no need to make the whole drive visible from the outside. Just map that view to a drive, point your httpd.conf at the drive and you're sorted. R. On Mon, 10 Sep 2001, Medi Montaseri wrote: I think people are responding with how to fix this on a Unix. He is on a NT. Assuming the disk is on the Unix and the Unix is running Samba, then just define a network drive on your NT, say V: which mapps to \\yourunixbox\disk7 -- Rafiq Ismail Software Engineer and Systems Administrator http://www.codix.net All the best people in life seem to like Linux. - Steve Wozniak
Re: Virtual Host?
I think people are responding with how to fix this on a Unix. He is on a NT. Assuming the disk is on the Unix and the Unix is running Samba, then just define a network drive on your NT, say V: which mapps to \\yourunixbox\disk7 Then in your http.conf on your NT, define an alias like Alias /wav/ v:what\ever\folder And from there, URLs pointing to http://xyz/wav will be looked up from v: On Mon, 10 Sep 2001, Purcell, Scott wrote: Hello, I have Apache w/modperl running on my NT box. The box has Samba on it, and I can see my Unix volumes from my SGI box. There is a volume there /DISK7 and I would like to be able to use that as a kind of Virtual host through the Apache Web server. /DISK7 has a bunch of .mov files that instead of copying to the htdocs directory, I would like to be able to href link to them and have them displayed. So my question is, where in the config (or how do I) configure the httpd.conf to allow me to use /DISK7 as part of the doc root? Thanks, Scott Purcell -- - Medi Montaseri [EMAIL PROTECTED] Unix Distributed Systems EngineerHTTP://www.CyberShell.com CyberShell Engineering -
RE: Virtual Host?
How about a symbolic link... On Mon, 10 Sep 2001, Rob Bloodgood wrote: i think you may have to mount it mount -t smb -o username=user,password=pass //ntserver//disk7 /mnt/smbshare then just add /mnt/smbshare to doc root! Except that, to the best of my knowledge, Samba can only mount to regular mount points on Linux. Rob #!/usr/bin/perl -w use Disclaimer qw/:standard/; -- - Medi Montaseri [EMAIL PROTECTED] Unix Distributed Systems EngineerHTTP://www.CyberShell.com CyberShell Engineering -
Re: Virtual Host?
Purcell, Scott wrote: Hello, I have Apache w/modperl running on my NT box. The box has Samba on it, and I can see my Unix volumes from my SGI box. There is a volume there /DISK7 and I would like to be able to use that as a kind of Virtual host through the Apache Web server. /DISK7 has a bunch of .mov files that instead of copying to the htdocs directory, I would like to be able to href link to them and have them displayed. So my question is, where in the config (or how do I) configure the httpd.conf to allow me to use /DISK7 as part of the doc root? Thanks, Scott Purcell i think you may have to mount it mount -t smb -o username=user,password=pass //ntserver//disk7 /mnt/smbshare then just add /mnt/smbshare to doc root!
RE: Virtual Host?
i think you may have to mount it mount -t smb -o username=user,password=pass //ntserver//disk7 /mnt/smbshare then just add /mnt/smbshare to doc root! Except that, to the best of my knowledge, Samba can only mount to regular mount points on Linux. Rob #!/usr/bin/perl -w use Disclaimer qw/:standard/;