PBS::Logs - general parser for PBS log files


PBS-Logs documentation  | view source Contained in the PBS-Logs distribution.

Index


NAME

Top

PBS::Logs - general parser for PBS log files

SYNOPSIS

Top

See the sections below:

  use PBS::Logs;

DESCRIPTION

Top

EXPORT

None by default.

SEE ALSO

Top

The PBS Pro 5.4 Administrator Guide
PBS::Logs::Acct
PBS::Logs::Event

AUTHOR

Top

Dr R K Owen, <rkowen@nersc.gov>

COPYRIGHT AND LICENSE

Top

new('file_name')

Top

new(\@array_ref)

Top

new(\*FILE_HANDLE)

Top

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])

Top

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()

Top

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.)

current()

Top

Return the "current" concatenated PBS record that has been read and that meets the selection criterion. Remember, though, that actuall PBS logs can have a record that is spread across multiple lines. New records begin with a date/time-stamp. This gives the entire record as one line.

start()

Top

Begin reading at the start of the log, if not a filter.

end()

Top

End reading of the log and close it out, if not a filter. Sets all the internal values to undef.

get()

Top

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)

Top

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])

Top

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.


PBS-Logs documentation  | view source Contained in the PBS-Logs distribution.