Re: logging to spread with apache2?

George Schlossnagle <[email protected]> Sun, 21 Jul 2002 22:49:19 -0400
Newsgroups gmane.comp.apache.mod-log-spread.user
Message-ID <[email protected]>
It's not C, but it's lean and fast (and all the work is really done in 
XS):

#!/usr/bin/perl

######################################################################
# Logger.pl
#
# Copyright (c) 2000 George Schlossnagle.  All rights reserved.
# This program is free software, you can redistribute it and/or
# modify it under the same terms as Perl itself.  This software
# is provided ``as is'' and any express or implied warranties,
# including, but not limited to, the fitness for a patricular
# purpose are disclaimed.  Yadda yadda yadda.
#
######################################################################

#use ExtUtils::testlib;
use Spread qw(:SP :MESS :ERROR);
use Getopt::Std;
$| = 1;

# Read in options
getopts('dg:hs:', \%opts);
$debug = $opts{d};
&usage() unless ($group = $opts{g});
$hosttoggle = $opts{h};
$spreaddaemon = ($opts{s}?$opts{s}:3333);


# Set spread connection params
#$hostname = `hostname`;
chomp ($hostname = `hostname`) ;
$args{'spread_name'} = $spreaddaemon;
$args{'private_name'} = "$$-$hostname";
$args{'priority'} = 0;
$args{'group_membership'} = 1;

# Connect to daemon
print "Trying to connect to spread...\n" if $debug;
($mbox, $privategroup) = Spread::connect(
         \%args
         );
print "$sperrno\n" unless (defined($mbox) && $debug);

#Logging loop
while(<STDIN>){
chomp;
print "MESSAGE $_\n";
if(($ret = Spread::multicast($mbox,
                              RELIABLE_MESS, $group, 0,
                              ($hosttoggle?$hostname." ".$_:$_)))>0) {
   print STDERR "Successfully multicasted $ret bytes to [$group]\n" if 
$debug;
} else {
   print STDERR "Failed multicast $_ to $group: $sperrno\n" if $debug;
}
}

sub usage(){
         print STDERR "Usage:  Logger -g group [-h] [-s daemon] [-d]\n";
         exit 0;
}



On Sunday, July 21, 2002, at 10:36 PM, Aditya wrote:

> It doesn't look like apache2 is supported with mod_log_spread
> currently, however using the "reliable piped logging"
> (http://httpd.apache.org/docs-2.0/logs.html#piped) seems like an
> option. Does anyone have a small, simple C program (I guess I could
> just modify flooder.c to do this...) that I can pipe the logs to in
> Apache2?
>
> Thanks,
> Adi
>
>
>
> _______________________________________________
> mls-users mailing list
> [email protected]
> http://lists.backhand.org/mailman/listinfo/mls-users
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc          http://www.omniti.com
// (c) 240.460.5234   (e) [email protected]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0