NAME
PBS::Logs - general parser for PBS log files
SYNOPSIS
See the sections below:
use PBS::Logs;
DESCRIPTION
EXPORT
None by default.
SEE ALSO
AUTHOR
Dr R K Owen, <rkowen@nersc.gov>
COPYRIGHT AND LICENSE
Copyright (C) 2005 The Regents of the University of California
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more details, which can be found at:
http://www.gnu.org/copyleft/lesser.html
or http://www.opensource.org/licenses/lgpl-license.php
new('file_name')
new(\@array_ref)
new(\*FILE_HANDLE)
Create a PBS::Logs object. It takes only one argument which is either a filename, array reference, or a FILE glob reference.
Pass a PBS log file name to read:
my $pl = new PBS::Logs('/var/spool/PBS/server_logs/20050512');
Slurp the file into an array and pass the array reference
open PL, '/var/spool/PBS/server_logs/20050512'
|| die "can not open log";
my @pl = <PL>;
my $pl = new PBS::Logs(\@pl);
Or finally, pass a FILEHANDLE glob. This can be useful if creating a filter.
my $pl = new PBS::Logs(\*STDIN);
debug([enable])
Debugging can be enabled for the entire class by calling PBS::Logs::debug(1)
.
Or debugging can be enabled for a single object with $obj->debug(1)
.
To disable debugging just set to 0.
Calling either form with no argument will just cause the current value to be returned.
line()
Return the "log line number" that will be read next (zero based), and returns -1 when at the "end of file". (Remember the "file" could have been slurped into an array.)
start()
Begin reading at the start of the log, if not a filter.
end()
End reading of the log and close it out, if not a filter. Sets all the internal values to undef.
get()
Get the next entry from the log and return as an array reference if in an scalar context, else return a list if called otherwise.
$a = $pl->get(); # returns array reference
@a = $pl->get(); # returns array
However, at the end of the log the array reference context will return undef and the array context will return an empty list ();
datetime($datetime)
Parse the PBS date-time string and return the number of seconds since the epoch if in a scalar context (UTC time), or return a 6-element array similar to the gmtime() or localtime() functions with (0:$sec, 1:$min, 2:$hour, 3:$mday, 4:$mon, 5:$year) where $mon is in the range 0..11 and $year is a 4-digit year.
$dt = '02/01/2005 18:48:10';
$a = $pl->datetime($dt); # returns seconds since January 1, 1970 UTC
@a = $pl->datetime($dt); # returns array
filter_datetime([start,end])
Sets or reads the datetime filter for the get() method.
get() will only retrieve lines that have a datetime between "start" and "end" inclusive.
Either one can be 'none' to signify that no filtering will be performed with respect to that time endpoint. No filtering is essentially ('none','none'). Or just do not call this method.
The start or end value can be given either in the PBS datetime format ( DD/MM/YYYY HH:MM:SS ) or in seconds from the epoch.
It will return '1' if successful, else undef if some warning occurs.
If no arguments are given then the method will return an array (start,end) where the values are in seconds since the epoch.