Re: problem with error_log_spread.pl
"Theo E. Schlossnagle" <[email protected]> Fri, 15 Nov 2002 17:23:50 -0500
| Newsgroups | gmane.comp.apache.mod-log-spread.user |
|---|---|
| Organization | Center for Networking and Distributed Systems |
| Message-ID | <[email protected]> |
Jay West wrote:
> Theo wrote...
>
> >Add after:
> >
> > print STDERR "Failed multicast $_ to $group: $sperrno\n" if $debug;
> >+ Spread::disconnect($mbox);
> >+ ($mbox, $privategroup) = Spread::connect(\%args);
> >
> >That will attempt a reconnect after every failed multicast attempt
>
> ensuring
>
> >that as soon as Spread is available, it will log.
>
>
> Ok, I will try that. But that won't get rid of the "Could not connect"
> messages would it? What I think will happen is spread will still
> sporadically fail to connect, but when it tries to send a message it should
> try to reconnect. That should work, but the programmers will see all the
> "could not connect" messages and call me at midnight *GRIN*. I think I will
> make the above suggested patch, it's a good idea to have it do that. But
> I'll also dig into the O'reilly perl book and see about having it try
> multiple times for the initial connect before giving up.
Just take out the "could not connect" print statement!
- print "$sperrno\n" unless (defined($mbox) && $debug);
Besides. You should monitor Spread orthogonally. We use netsaint here to
monitor our various Spread rings. Works very very well. I would be happy to
contribute this to the Spread project -- just hadn't thought of it until now.
The spreadlogd monitor is pretty applicable to mod_log_spread, so I'll
attach that here. Netsaint works well, we are pretty happy with it.
Included at the end of this message is a perl script to check that spreadlogd
is working (will log messages) sent on any given webserver. To check
webesrver "www1", logging to group "mysite", and spread running on "4803", run:
check_spreadlogd -H www -P 4803 -G mysite
This drops right into netsaint.
--
Theo Schlossnagle
Principal Consultant
OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
Phone: +1 410 872 4910 x201 Fax: +1 410 872 4911
1024D/82844984/95FD 30F1 489E 4613 F22E 491A 7E88 364C 8284 4984
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7
-----------------------------------------------------------
-- Presenting at ApacheCon --
-- November 18th, 2002 --
-- Las Vegas, Nevada --
-- Backhand: understanding and building HA/LB clusters --
-- http://apachecon.com/2002/US/ --
-- --
-- Learn all there is to know about high availability --
-- internet systems and load balancing techniques --
-- focusing on applications driven by the Apache web --
-- server! --
-----------------------------------------------------------
#!/usr/bin/perl
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
use strict;
use Spread qw(:MESS $sperrno);
use Time::HiRes qw( gettimeofday tv_interval );
use Getopt::Long;
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME $opt_H $opt_P $opt_G $opt_T
$spreaddaemon @members $messages);
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"H|host=s" => \$opt_H,
"P|port=i" => \$opt_P,
"G|group=s" => \$opt_G);
$opt_T ||= 5;
$spreaddaemon = $opt_P.'@'.$opt_H;
@members = ();
$messages = 0;
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm ($opt_T+5);
my($mbox, $pgroup) = Spread::connect( { spread_name => $spreaddaemon,
private_name => "ns-sld-$$",
} );
unless($mbox) {
print "SPREADLOGD CRITICAL: $spreaddaemon $sperrno\n";
exit $ERRORS{'CRITICAL'};
}
unless(Spread::join($mbox, $opt_G)) {
print "SPREADLOGD CRITICAL: cannot join $opt_G $sperrno\n";
exit $ERRORS{'CRITICAL'};
}
my $st = [gettimeofday];
while(my(@spvals) = Spread::receive($mbox, 1)) {
last if(tv_interval($st) > $opt_T);
if($spvals[3] & MEMBERSHIP_MESS) {
@members = grep /^#sld-/, @{$spvals[2]};
} elsif($spvals[3] & REGULAR_MESS) {
$messages++;
}
}
Spread::disconnect($mbox);
alarm 0;
};
if($@) {
print "SPREADLOGD CRITICAL: timeout\n";
exit $ERRORS{'CRITICAL'};
}
unless(scalar(@members)) {
print "SPREADLOAD CRITICAL: no spreadlogd\n";
exit $ERRORS{'CRITICAL'};
}
print "SPREADLOGD OK: ".join(',', @members)." on $opt_G with $messages
messages\n";
exit $ERRORS{'OK'};