Amanda-2.6.1

Amanda::Logfile


NAME

Amanda::Logfile - manage Amanda trace logs


SYNOPSIS

  use Amanda::Logfile qw(:logtype_t);
  use Amanda::Config qw( :getconf config_dir_relative );
  for my $logfile (Amanda::Logfile::find_log()) {
    $logfile = config_dir_relative(getconf($CNF_LOGDIR)) . "/" . $logfile;
    my $hdl = Amanda::Logfile::open_logfile($logfile);
    while (my ($type, $prog, $str) = Amanda::Logfile::get_logline($hdl)) {
      if ($type == $L_INFO) {
        my $pname = Amanda::Logfile::program_t_to_string($prog);
        print "Found info line from $pname: $str\n";
      }
    }
    Amanda::Logfile::close_logfile($log);
    my @dumps = Amanda::Logfile::search_logfile("TapeLabel-001", "19780615", $logfile, 1);
    my @matching = Amanda::Logfile::dumps_match([@dumps], "myhost", "/usr", undef, undef, 0);
    for my $dump (@matching) {
      print "$dump->{'label'}:$dump->{'filenum'} = $dump->{'hostname'}:$dump->{'disk'}\n";
    }
  }


API STATUS

Stabilizing


RAW LOGFILE ACCESS

This section corresponds to the C logfile module.

Raw access to logfiles is accomplished by opening a logfile and fetching log lines one by one via the get_logline function.

A log line is represented by a list ($type, $prog, $string) where $type is one of the L_* constants (available in export tag logtype_t), $prog is one of the P_* constants (available in export tag program_t), and $str is the remainder of the line.

Both families of constants can be converted to symbolic names with logtype_t_to_string and program_t_to_string, respectively.

FUNCTIONS

open_logfile($filename)

Opens a logfile for reading, returning an opaque log file handle.

close_logfile($handle)

Closes a log file handle.

get_logline($handle)

Return a list as described above representing the next log line in $handle, or nothing at the end of the logfile.

All of these functions can be imported by name if desired.


Amanda::Find::find_result_t objects

These objects contain information about dumps, as read from logfiles. Instance variables are:

timestamp
hostname
diskname
level
label
filenum
status
partnum
sec
kb

Note that the format for these variables are based on that found in the logfiles. In particular, partnum is a string, usually with a slash (/) in it. Also, timestamp is the timestamp for the run in which the client dump took place, and not for the timestamp of the logfile.


HIGHER-LEVEL FUNCTIONS

Functions in this section extract information from logfiles.

find_log()

Return a list of logfiles for active tapes. The tapelist must be loaded before this function is called (see the Amanda::Tapelist manpage).

search_logfile($label, $datestamp, $logfile, $add_missing_disks)

Return all results in $logfile matching $label and $datestamp. If $add_missing_disks is true, then any disks in the logfile not present in the disklist are added to the disklist; otherwise, such dumps are skipped.

dumps_match([@results], $hostname, $diskname, $datestamp, $level, $ok)

Return a filtered version of @results containing only results that match the given expressions. If $ok is true, don't match partial results. Note that $level is given as a string, since it is a match expression.

All of these functions can be imported by name.


ABOUT THIS PAGE

This page was automatically generated Fri Feb 5 19:41:21 2010 from the Amanda source tree, and documents the most recent development version of Amanda. For documentation specific to the version of Amanda on your system, use the 'perldoc' command.


Amanda-2.6.1