Author: parv
Date: 27-12-04 17:33
Below is a perl program to generate an entry (on the stdout) for /etc/syslog.conf to log everything that is not already being logged. Put the output in /etc/syslog.conf yourself.
Purpose is to minimize dupilcation in /var/log/all.log. (Program was developed/tested w/ Perl 5.8.5.)
Usage: non-dup-entry /etc/syslog.conf
<code>
#!/usr/local/bin/perl
use strict; use warnings;
my @facility;
while (<>)
{ next if m/^ \s* \#/x or m/^ \s* $/xs;
push @facility , get_facility( (split)[0] );
}
print
join make_none( [ @facility ] )
, q/*.*;/ , qq{\t/var/log/all.log}
;
exit;
sub get_facility
{ my @list = shift;
return
map
{ m/^ (\S+) \. .+ $/x;
$1 ne '*' ? $1 : ();
}
map split( ';' ) , @list ;
}
sub make_none
{ my $list = shift;
return
join ';' , map "$_.none" , sort @{ get_uniq( $list ) };
}
sub get_uniq
{ my $list = shift;
my %uniq;
@uniq{ @{$list} } = ();
return [ keys %uniq ];
}
</code>
|
|