Perl Code Hangs Scribe

22 views
Skip to first unread message

TomTom

unread,
Nov 8, 2009, 4:14:36 PM11/8/09
to Scribe Server
Hey All, When I use the following perl code, I hang my scribe daemon.
#!/usr/bin/perl

use Scribe::Thrift::scribe;
use Thrift::Socket;
use Thrift::FramedTransport;
use Thrift::BinaryProtocol;
use strict;
use warnings;

my $host = 'localhost';
my $port = 1464;
##my $cat = [0] || 'test';
my $cat = 'test';

my $socket = Thrift::Socket->new($host,$port );
my $transport = Thrift::FramedTransport->new($socket);
my $proto = Thrift::BinaryProtocol->new($transport);

my $client = Scribe::Thrift::scribeClient->new($proto,$proto );
##my $le = Scribe::Thrift::LogEntry->new({ category => $cat });
my $le = Scribe::Thrift::LogEntry->new({ category =>
"new_perl_Test" });

$transport->open();

##while (my $line = <>) {


my $LOGFILE = "man.txt";
my $line;

open(LOGFILE, $LOGFILE) or die ("Could not open log file.");
foreach $line (<LOGFILE>) {
chomp ($line);
print "$line\n";

$le->message();
my$result = $client->Log([ $le ]);
if ( $result == Scribe::Thrift::ResultCode::TRY_LATER) {
print STDERR "TRY_LATER\n";
}
elsif ( $result != Scribe::Thrift::ResultCode::OK) {
print STDERR "Unknown result code: \n";
}
}

$transport ->close();

Any one have any luck?

anthony

unread,
Nov 12, 2009, 9:39:20 PM11/12/09
to Scribe Server
Did you ever get this figured out? I haven't done any testing using
perl generated thrift client code, but you should be able to log to
scribe from perl.

I'm assuming your server was hanging when the client called Log(),
right? Are you able to send messages to your server using the
scribe_cat script? And are you passing Log() an array of LogEntry
objects where each entry contains both a category and message? (I
don't know perl, but the line "$le->message();" looks odd to me).

-Anthony

Chris Goffinet

unread,
Nov 12, 2009, 10:09:20 PM11/12/09
to scribe...@googlegroups.com
I agree with Anthony, I think this line:

$le->message();

should be:

$le->message = $line;

TomTom

unread,
Nov 13, 2009, 9:02:49 AM11/13/09
to Scribe Server
I haven't figured this one out yet. Chris, thanks for the help.
I have moved on and tried getting Log::Dispatch::Scribe working. We
are a red hat shop, so I am in the middle of converting all the
dependent CPAN modules into RPMs.

My main interest in using Log::Dispatch::Scribe, is it comes with
scribe_cat.pl, which allows you to do the bad ass Apache Custom Log
pipes.

CustomLog "|scribe_cat.pl --category=www" "%h %l %u %t \"%r\" %>s %b
\"%{Referer}i\" \"%{User-agent}i\""

I was never able to get my modified scribe_cat script to correctly
read from an Apache pipe. I was using the readline() function, and it
wouldn't keep with the log flow. The read() function would just hang.
Apparently Perl is better at this for some reason.

I dug into Silas's scribe_log. He suggests using supervisor to
restart the process if it ever dies, which is cool as hell. We use
puppet though, and supervisor is a little hard to manage via puppet. I
have to use some funky puppet functions to add and remove the
supervisor program and command lines. I can post this code if anyone
is interested in OO puppet.

Oh, well once I get out of RPM dependency hell, I'd be happy to make
all the Perl work available to the group. Thanks again Chris and
Anthony, have a great weekend.
-Tom

On Nov 12, 10:09 pm, Chris Goffinet <c...@chrisgoffinet.com> wrote:
> I agree with Anthony, I think this line:
>
> $le->message();
>
> should be:
>
> $le->message = $line;
>

TomTom

unread,
Nov 13, 2009, 10:41:09 AM11/13/09
to Scribe Server
Hello Fellows,
I have a working scribe installation. I also have a working
Log::Dispatch::Scribe rpm installation. There is however a nasty perl
dependency issue. It is a known issue within the CPAN community.
http://www.google.com/search?q=sys+syslog+conflicts+with+log+dispatch&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Version .13 Sys::Syslog comes with our upstream provider the RHEL/
CentOS perl distribution.

Log::Dispatch requires Sys::Syslog to be at our greater than .16. I
have RPM’d up Sys::Syslog v .27, and I am only able to install it via
an rpm –force. This force does change the Sys::Syslog modules in the
core of our perl distribution /usr/lib64/perl5/site_perl/5.8.8/x86_64-
linux-thread-multi

I am trying to sort it out now with our developers how uncomfortable
they might be with me monkeying with core perl. scribe_cat.pl seems to
be a great app, and appears to be worth getting it all going.

TomTom

unread,
Nov 17, 2009, 9:57:14 PM11/17/09
to Scribe Server
Hey Anthony or Chris,
Do you guys use a technique like Silas's
http://www.silassewell.com/blog/2009/05/12/pipe-apache-or-any-logs-to-scribe/
to monitor log files? What "Super Servers" do you guys use to
monitor the log eater? Do you guys use supervisor? I had never heard
of it before. It appears to be a great though. I am very impressed
with its capabilities. Do you guys have an production preferences?
Your advice is greatly appreciated.
Have a nice evening!
-Tom

On Nov 13, 10:41 am, TomTom <mcgona...@gmail.com> wrote:
> Hello Fellows,
>  I have a working scribe installation. I also have a working
> Log::Dispatch::Scribe rpm installation. There is however a nasty perl
> dependency issue. It is a known issue within the CPAN community.http://www.google.com/search?q=sys+syslog+conflicts+with+log+dispatch...

Chris Goffinet

unread,
Nov 17, 2009, 11:40:06 PM11/17/09
to scribe...@googlegroups.com
For piping apache logs, we just use a modified version of scribe_cat
(I owe anthony some fixes/rewritings that I'll get to this week) that
works with Apache and we use CustomLog / pipe method. Its really easy
and doesn't require additional extensions/outside applications to be
involved.

-Chris

Kevin Weil

unread,
Nov 18, 2009, 5:20:19 AM11/18/09
to Scribe Server
Another option: we have a custom apache module that can log directly
to Scribe up at http://github.com/emaland/mod_log_scribe. It still
needs more testing (it's not in production anywhere), but it is
basically working.

Kevin

On Nov 17, 8:40 pm, Chris Goffinet <c...@chrisgoffinet.com> wrote:
> For piping apache logs, we just use a modified version of scribe_cat  
> (I owe anthony some fixes/rewritings that I'll get to this week) that  
> works with Apache and we use CustomLog / pipe method. Its really easy  
> and doesn't require additional extensions/outside applications to be  
> involved.
>
> -Chris
>
> On Nov 17, 2009, at 6:57 PM, TomTom wrote:
>
> > Hey Anthony or Chris,
> > Do you guys use a technique like Silas's
> >http://www.silassewell.com/blog/2009/05/12/pipe-apache-or-any-logs-to...
Reply all
Reply to author
Forward
0 new messages