#!/usr/bin/perl ###################################################################### # Copyright (c) 2000 George Schlossnagle. All rights reserved. # Modifications, Copyright 2008 Fedora Unity Project # Jonathan Steffan # 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 particular # purpose are disclaimed. ###################################################################### 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 = '4803@spreadlog.fedoraunity.org'; # Set spread connection params 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(){ chomp; print "MESSAGE $_\n"; if(($ret = Spread::multicast($mbox, RELIABLE_MESS, $group, 0, ($hosttoggle?$hostname." ".$_:$_."\n")))>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; }