The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

VBTK::Log - Monitoring of sequential ASCII text logs

SYNOPSIS

  # Monitor /var/adm/messages, looking for warning or error messages.
  $obj = new VBTK::Log(
      SourceList => '/var/adm/messages');
  $obj->addVBObj(
      VBObjName => ".$::HOST.log.messages",
      Rules     => {
          '($data =~ /unix:|hardware error|panic/i)'      => 'Fail',
          '($data =~ /fail|warning|refuse/i)' => 'Warn' },
  ) if ($obj);

  &VBTK::runAll;

DESCRIPTION

This perl library is a front-end to the VBTK::Wrapper class. It supports the same public methods as the VBTK::Wrapper class, but with common defaults to simplify the monitoring of a log file.

METHODS

The following methods are supported

$o = new VBTK::Wrapper::Log (<parm1> => <val1>, <parm2> => <val2>, ...)

This method calls 'new VBTK::Wrapper' after defaulting the parameters to tail the specified log file. For a detailed description of the parameters, see VBTK::Wrapper. The defaults are as follows. If you like all the defaults then you don't have to pass in any parms.

Interval
    Interval => 60,
SourceList

A list of files to retrieve data from. The process will read the files in order specified. Usually, you only have one file in the list. (Required)

    SourceList => '/var/adm/messages',
VBDetail

Just dump out the rows as they are retrieved.

    VBDetail => [ '$data' ],
SkipLines
    Skiplines => '-0',
Follow

Usually you want to run in follow mode when monitoring a log file.

    Follow => 1,
FollowHeartbeat
    FollowHeartbeat => 1,
$vbObj = $o->addVBObj(<parm1> => <val1>, <parm2> => <val2>, ...)

This method calls VBTK::Parser::addVBObj after defaulting unspecified parameters to best follow a log file. For a detailed description of the addVBObj parameters, see VBTK::Parser. The defaults are as follows. If you like all the defaults then you don't have to pass in any parms

VBObjName

Name the VBObject using the local host's name.

    VBObjName => ".$::HOST.log.generic",
TextHistoryLimit
    TextHistoryLimit => 200,
ReverseText

Reverse the text, so that we see the most recently reported lines first.

    ReverseText => 1,
Rules

Watch for words like 'error', 'fail', or 'warn'

    Rules => {
      '($data =~ /error|fail/i)' => 'Fail',
      '($data =~ /warn/i)'       => 'Warn' },
StatusHistoryLimit

Limit to storing the last 30 status changes

    StatusHistoryLimit => 30,
ExpireAfter
    ExpireAfter => (<Interval> * 3) seconds
Description
    Description = qq(
        This object follows the output of the specified log file watching for 
        warnings or errors. ),

SEE ALSO

VBTK::Wrapper
VBTK::Parser
VBTK::ClientObject
VBTK::Server

AUTHOR

Brent Henry, vbtoolkit@yahoo.com

COPYRIGHT

Copyright (C) 1996-2002 Brent Henry

This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation available at: http://http://www.gnu.org/copyleft/gpl.html

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.