Amanda::Curinfo::Info - Perl extension for representing dump information
use Amanda::Curinfo::Info;
my $info = Amanda::Curinfo::Info->new($infofile);
Amanda::Curinfo::Info
is the format representation for the curinfo
database. It handles the reading and writing of the individual
entries, while the entry management is left to Amanda::Curinfo
.
Further parsing is also dispatched to Amanda::Curinfo::History
,
Amanda::Curinfo::Stats
, and Amanda::Curinfo::Perf
.
The constructor for a new info object is very simple.
my $info = Amanda::Curinfo::Info->new();
Will return an empty info object with the necessary fields all blank.
Given an existing $info
object, for example, as provided by
Amanda::Curinfo::get_info
, there are other functions present in this
library, but they are helper functions to the previously described
methods, and not to be used directly.
It should also be noted that the reading and writing methods of
Amanda::Curinfo::Info
are not meant to be used directly, and should be
left to Amanda::Curinfo.
Reading a previously stored info object is handled with the same subroutine.
my $info = Amanda::Curinfo::Info->new($infofile);
Here, $info
will contain all the information that was stored in
$infofile
.
To write the file to a new location, use the following command:
$info->write_to_file($infofile);
There are also three corresponding container classes that hold data and perform parsing functions. They should only be used when actually writing info file data.
my $history = Amanda::Curinfo::History->new( $level, $size, $csize, $date, $secs ); my $stats = Amanda::Curinfo::Stats->new( $level, $size, $csize, $secs, $date, $filenum, $label );
my $perf = Amanda::Curinfo::Perf->new(); $perf->set_rate( $pct1, $pct2, $pct3 ); $perf->set_comp( $dbl1, $dbl2, $dbl3 );
Note that Amanda::Curinfo::Perf
is different. This is because its
structure is broken up into two lines in the infofile format, and the
length of the rate
and comp
arrays maybe subject to change in
the future.
You can also instantiate these objects directly from a properly-formatted line in an infofile:
my $history = Amanda::Curinfo::History->from_line($hist_line); my $stats = Amanda::Curinfo::Stats->from_line($stat_line);
my $perf = Amanda::Curinfo::Perf->new(); $perf->set_rate_from_line($rate_line); $perf->set_comp_from_line($comp_line);
Again, creating Amanda::Curinfo::Perf
is broken into two calls
because its object appears on two lines.
Writing these objects back to the info file, however, are all identical:
print $infofh $history->to_line(); print $infofh $stats->to_line(); print $infofh $perf_full->to_line("full"); print $infofh $perf_incr->to_line("incr");
Additionally, the $perf
object accepts a prefix to the line.
This package is meant to replace the file reading and writing portions of server-src/infofile.h. If you notice any bugs or compatibility issues, please report them.
Paul C. Mantz <[email protected]>
This page was automatically generated Tue Nov 19 20:05:35 2013 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.