Skip to content

Instantly share code, notes, and snippets.

@CirKu17
Created September 5, 2012 12:40
Show Gist options
  • Save CirKu17/3635976 to your computer and use it in GitHub Desktop.
Save CirKu17/3635976 to your computer and use it in GitHub Desktop.
logwatch-tor (logwatch script for tor logs)
#!/usr/bin/perl -w
use strict;
use Logwatch ':all';
my @warnings;
my $current_count = 0;
my $message = "";
while (defined(my $line=<STDIN>)) {
chomp $line;
if ( $line =~ m/^(\w+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\.(\d\d\d)\s+\[(warn|err)\](.*)/i ) {
$message = $8;
if ( ( $line =~ m/count\s+(\d*)/ ) && ( $1 > $current_count ) ) {
pop @warnings if ($1 > 1) ;
$current_count = $1;
}
push @warnings, $message unless ( $message ~~ @warnings) ;
}
}
foreach (@warnings){ print $_,"\n"; }
exit(0);
Title = "Tor"
LogFile = messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment