NAME
ClearCase::Report::VxfsSyslog - Parse "vxfs" notification messages in syslog
VERSION
This document describes version 0.15, released October, 2004.
SYNOPSIS
use ClearCase::Report::VxfsSyslog;
my $reptObj = new ClearCase::Report::VxfsSyslog;
Collect any "vxfs" notifications from the system log file.
$reptObj->collectData;
or ($stat,$err) = $reptObj->collectData;
or $reptObj = ClearCase::Report::VxfsSyslog->collectData;
or ($reptObj,$stat) = ClearCase::Report::VxfsSyslog->collectData;
or $reptObj->collectData( $starttime );
or $reptObj->collectData( $starttime, $syslogfile );
Report any "vxfs" notifications from the system log file.
$arrayRef = $reptObj->formatData;
print @{ $arrayRef };
or print @{ $reptObj->formatData };
or if ($reptObj->hasErrorsToReport) {
print @{ $reptObj->formatData };
} else {
$reportHost = $reptObj->reportHost;
print "$base: No errors to report on $reportHost.\n";
}
DEPENDENCIES
Dependencies for this class include the following.
Date::Format, Date::Parse, PTools::Proc::Backtick, PTools::SDF::File::Mnttab and PTools::Time::Elapsed.
DESCRIPTION
This class collects vxfs errors from the Unix system log file which, by default, is "/var/adm/syslog/syslog.log".
Constructor
- collectData ( [ StartTime ] [, SysLogFile ] [, TextString ] )
-
Collect any vxfs errors from the system log file.
- StartTime
-
If a StartTime, in Unix "epoch" format, is passed the parser will ignore any errors that occur prior to this time. This is handy when running this script on a schedule so as to prevent duplicate notification of errors that have already been reported.
- SysLogFile
-
Read an alternate SysLogFile. By default the Unix system log file named "/var/adm/syslog/syslog.log".
- TextString
-
Pass a TextString to look for alternate error strings in the SysLogFile. By default the parser looks for the string "vxfs: ".
Example:
use ClearCase::Report::VxfsSyslog; $reptObj = new ClearCase::Report::VxfsSyslog;
Methods
- formatData ( Flag )
-
Returns a reference to an array of zero or more lines of formated data collected from the system log file.
- Flag
-
When any non-null Flag value is passed, this method returns "raw" colon-separated data suitable for logging or other formatting.
Without a Flag value this module returns zero or more lines of formatted output consisting of about four lines for each error detected.
Example of printing formatted data:
print @{ $reptObj->formatData };
Example of printing "raw" data:
$arrayRef = $reptObj->formatData( "raw" ); print @{ $arrayRef };
- formatEntry ( Args )
-
This is the method that turns "raw" data collected from the system log file into formatted data as returned by the formatData method.
- Args
-
To allow flexability when formatting "raw" data collected, the Args variable can be in either of the following formats:
Either a string of colon-separated variables
"$first:$last:$host:$dev:$error:$path:$mesg"
or a list of variables (this is the format of the "raw" output from the formatData method).
($first,$last,$host,$dev,$error,$path,$mesg)
Example:
$arrayRef = $reptObj->formatData( "raw" ); foreach $entry ( @$arrayRef ) { print $reptObj->formatEntry( $entry ); }
- startTime
-
This method returns a timestamp (Unix "epoch" format) corresponding to the first log entry processed in the syslog file. This is not the time the script started.
$firstLogEntryTime = $reptObj->startTime;
- endTime
-
This method returns a timestamp (Unix "epoch" format) corresponding to the last log entry processed in the syslog file. This is not the time the script ended.
This value is handy to save, in a file for example, and then used as the StartTime parameter to the collectData method during the next run of a reporting script.
$lastLogEntryTime = $reptObj->endTime;
- reportHost
-
This method returns the hostname of the machine on which the data is collected, which is handy when collecting raw data into a single log file for multiple hosts. This returns the fully qualified domain name ("fqdn").
$hostname = $reptObj->reportHost;
- hasErrors
- hasErrorsToReport
- noErrors
- noErrorsToReport
-
Determine if this module collected any errors to report.
if ( $reptObj->hasErrorsToReport ) { $arrayRef = $reptObj->formatData( $formatFlag ); print @{ $arrayRef }; } elsif ( $reptObj->noErrorsToReport ) { $reportHost = $reptObj->reportHost; print "$base: No errors to report on $reportHost.\n"; }
- status
- stat
- err
-
Determine if the collectData method detected any errors while collecting error entries from the system log file.
($stat,$err) = $reptObj->status; $stat and die $err; $stat = $reptObj->stat; # scalar context returns status number ($err) = $reptObj->stat; # array context returns error message ($err) = $reptObj->err;
- dump
-
Display the contents of an object of this class. This is handy during development / testing / debugging scripts using this module.
print $reptObj->dump;
INHERITANCE
None currently.
AUTHOR
Chris Cobb, <chris@ccobb.net>
COPYRIGHT
Copyright (c) 2002-2004 by Hewlett-Packard. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.