VBTK::Log - Monitoring of sequential ASCII text logs
# 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;
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.
The following methods are supported
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 => 60,
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',
Just dump out the rows as they are retrieved.
VBDetail => [ '$data' ],
Skiplines => '-0',
Usually you want to run in follow mode when monitoring a log file.
Follow => 1,
FollowHeartbeat => 1,
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
Name the VBObject using the local host's name.
VBObjName => ".$::HOST.log.generic",
TextHistoryLimit => 200,
Reverse the text, so that we see the most recently reported lines first.
ReverseText => 1,
Watch for words like 'error', 'fail', or 'warn'
Rules => { '($data =~ /error|fail/i)' => 'Fail', '($data =~ /warn/i)' => 'Warn' },
Limit to storing the last 30 status changes
StatusHistoryLimit => 30,
ExpireAfter => (<Interval> * 3) seconds
Description = qq( This object follows the output of the specified log file watching for warnings or errors. ),
Brent Henry, vbtoolkit@yahoo.com
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.
To install VBTK, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VBTK
CPAN shell
perl -MCPAN -e shell install VBTK
For more information on module installation, please visit the detailed CPAN module installation guide.