The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Logging everthing not already being logged ("*.*;blah.none /var/log/all.log")
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>

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org