Amanda-2.6.0

Amanda::Logfile


NAME

Amanda::Logfile - manage Amanda trace logs


SYNOPSIS

  use Amanda::Logfile qw(:logtype_t); # XXX change
  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);
    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


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::Tapefile manpage, and note that this module will be renamed to the Amanda::Tapelist manpage in Amanda-2.6.1).

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 Mon Nov 17 19:29:37 2008 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.0