Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

DB2 Log analyser

by theroninwins (Friar)
on Jan 08, 2008 at 14:20 UTC ( [id://661092]=sourcecode: print w/replies, xml ) Need Help??
Category: Database Utilities
Author/Contact Info Theroninwins
Description: Analyses DB2 logs and searches for errors. Has a verbose mode. The comments used to be in german so I rather shortened then while translating
#!/usr/local/bin/perl

use strict;
use Data::Dumper; 

print "\n\n";
print"Write the file name using / and not \\ . Verbose means all loads
+ will be shown non-verbose means only the ones with errors are shown"
+;

print "\n\n";

###Inputfile
print "File path:  ";
my $doc = <STDIN>;
$doc =~ s/\//\\/g;     #Switch / with \ 

my $holdTerminator = $/;
undef $/;

###Parse File to $buffer
open (INPUT, $doc);
my $buffer = <INPUT>;
close (INPUT);

###Split the input file spliting at load
$/ = $holdTerminator;
my @lines = split /load / , $buffer;

###Variables###
my $line;
my $result;
my $string;
my $loadline;
my $index = 1;
my $arraysize = @lines;  # Arraysize

print "\n\n";

###Verbose?###
print "Use verbose mode? Yes or No:  ";
my $flagbuffer = <STDIN>;

print "\n\n";

###Flag check###
if ($flagbuffer=~ m/Yes|Y|yes|y/){


   ###VERBOSE###
   foreach $line (@lines)
   {
     # The first and last one is not a load command
$arraysize-1 auf
    if ($index<$arraysize){
       print "LOAD No.: $index \n"; #parse load no.
       $line = $lines[$index];

       if($line=~ m/(e.*?nonrecoverable)/){$result = $1}; #parse load 
+command

       print "LOAD: $result\n"; #print load no.

       if ($line =~ m/SQL2036N|SQL3107W|SQL3304N/) #search for error
       {
             if ($line =~ m/SQL2036N/)
      {
      print "Status: ERROR  Errorcode: SQL2036N --> File or unit not f
+ound\n";
      }
      elsif($line =~ m/SQL3304N/)
      {
      print "Status: ERROR  Errorcode: SQL3304N --> Table does not exi
+st\n";
      }
       }
       else
       {
     print "Status: OK \n"; #If no error
       }
       print "----------------------------------------------\n\n";

       $index = $index +1;
   }
}


###NON VERBOSE###
}
else
{
    # The first and last one is not a load command
    if ($index<$arraysize){
       foreach $line (@lines)
       {

            $line = $lines[$index];

            if ($line =~ m/SQL2036N|SQL3107W|SQL3304N/) #Errorsearch
            {
               print "LOAD No.: $index \n"; #Print load no.
               $line = $lines[$index];

               if($line=~ m/(e.*?nonrecoverable)/){$result = $1}; #par
+se load command

               print "LOAD: $result\n";#print load no.

           if ($line =~ m/SQL2036N/) # error search
           {
           print "Status: ERROR  Errorcode: SQL2036N File or Unit is w
+rong!\n";
           }
           elsif($line =~ m/SQL3304N/)
           {
           print "Status: ERROR  Errorcode: SQL3304N Table does not ex
+ist n\n";
           }
               print "----------------------------------------------\n
+\n";
            }


$index = $index +1;
       }
    }

}  #End

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://661092]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found