Code

more functionality for log-parser
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Mar 2008 16:20:18 +0000 (16:20 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Mar 2008 16:20:18 +0000 (16:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10003 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/tests/log-parser.pl

index 6158e87f2bc264032d7f57199037b12c5f776162..6b9e6c2dbd0f3e4e05c1a8f47745b21061b09ac5 100755 (executable)
@@ -23,13 +23,23 @@ use warnings;
 use Getopt::Long;
 use Data::Dumper;
 
-my $log_file = "/var/log/gosa-si-server.log"; 
+my $log_file = "/home/hickert/log.gosa-si-server"; 
+#my $log_file = "/var/log/gosa-si-server.log"; 
 my $within_session = 0;
 my $within_incoming = 0;
 my $within_header = 0;
 my $session;
 my $incoming;
 my $header;
+my $syslog_state;
+
+sub check_syslog_state {
+       my ($line) = @_ ;
+       if($line =~ /$syslog_state:/ ) {
+               return $line;
+       }
+       return;
+}
 
 sub check_header {
        my ($line) = @_ ;
@@ -87,6 +97,7 @@ GetOptions(
                "s|session=s"  => \$session,
                "i|incoming=s" => \$incoming,
                "h|header=s"   => \$header,
+               "l|log=s" => \$syslog_state,
                );
 
 # check script pram
@@ -102,7 +113,11 @@ if (defined $incoming) {
 if (defined $header) {
        print "header: $header\n";
        $script_pram->{'header'} = $header;
-}      
+}
+if (defined $syslog_state) {
+       print "syslog_state: $syslog_state\n"; 
+       $script_pram->{'syslog_state'} = $syslog_state;
+}
 
 if (keys(%$script_pram) == 0) {
        # print usage and die
@@ -120,6 +135,7 @@ while ( my $line = <FILE>){
        # start of a new message, plot saved log lines
        if ($line =~ /INFO: Incoming msg with session ID \d+ from / ) {
                if ($positive_msg) {
+                       print "#####################################################\n";
                        print join("\n", @lines)."\n"; 
                }
 
@@ -148,6 +164,11 @@ while ( my $line = <FILE>){
                        my $l = &check_header($line);
                        if (defined $l) { $positiv_counter++; } 
                }
+               
+               elsif ($pram eq 'syslog_state') {
+                       my $l = &check_syslog_state($line);
+                       if (defined $l) { $positiv_counter++; }
+               }
        }
 
        if (keys(%$script_pram) == $positiv_counter) {