Rafael Porres Molina > SNMP-LogParser-1.15290 > SNMP::LogParserDriver::ExampleDriver

Download:
SNMP-LogParser-1.15290.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

SNMP::LogParserDriver::ExampleDriver

SYNOPSIS ^

This is an example Driver class to check for strings in the log file of the form "test string". Every time that this string is found the variable "counter" is incremented.

DESCRIPTION ^

Here we show each of the functions

new

New is just a passthrough to the parent class

 sub new {
   my $class = shift;
   my $self  = $class->SUPER::new();
   bless ($self, $class);
   return $self;
 }

evalBegin

Here we initialize the "counter" variable. We declare it in the "savespace" hash so that it is persistent across run invocations of logparser

 sub evalBegin {
   my $self = shift;  
   $self->{savespace}{counter} = 0 if (!defined($self->{savespace}{counter}));
   $self->{savespace}{lines} = 0 if (!defined($self->{savespace}{counter}));
 }

evalIterate

Here we parse each line, incrementing the counter value if it matches the string (we also keep track of lines)

 sub evalIterate {
   my $self = shift;
   my ($line) = @_;
   $self->{savespace}{lines} ++;
   if ($line =~ /test string/g) {
      $self->{savespace}{counter} ++;
   }
 }

evalEnd

Here we tell the system that we want to output on the properties file all the variables in the save space...

 sub evalEnd {
   my $self = shift;
   $self->properties($self->savespace);
 }

REQUIREMENTS AND LIMITATIONS ^

OPTIONS ^

BUGS ^

TODO ^

SEE ALSO ^

AUTHOR ^

Nito at Qindel dot ES -- 7/9/2006

COPYRIGHT & LICENSE ^

Copyright 2007 by Qindel Formacion y Servicios SL, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: