Fwctl::AcctReport - Generates reports from fwctl dump-acct command.
fwctl dump-acct
use Fwctl::AcctReport; my $report = new Fwctl::Report( options ... ); my $r = $report->summary_report; foreach my $r ( @$src_alias_sum ) { print $r->{name}, " = ", $r->{bytes_sum}, "\n"; }
The Fwctl::AcctReport(3) module can be used to generate packet and bandwith report from the data generated by the fwctl dump-acct command.
This module can be used as backend for two kinds of report. Summary which compiles the total number of packets and bytes received by each accounting chains over the report's period or histogram type report where you have the packets and bytes total for each sample (hour, day, etc) over the report's period.
The fwctl dump-acct commands dumps the packets and bytes total since the time of the last invocation. If the last invocation wasn't wholly comprised in the current sample, the total will be interpolated. This means that you should run the fwctl dump-acct command at least as frequently as the smallest sample period you want to use.
Ex. my $report = new Fwctl::AcctReport( start => 'yesterday', period => '1 day', sample => '1d', files => [ 'log' ] );
The new method accepts the following parameter :
new
Specifies the file from which to read the dumped acctounting informations. It is an array of file handle or file names. If this parameter is not specified the records will be read from STDIN.
Sets the start of the report's period. If the Date::Manip(3) module is installed, you can use any format that this module can parse. If that module isn't installed you must use the following format YYYY-MM-DD HH:MM:SS or any meaningful subset of that format.
If this option is not used, the report will start with the first record.
Sets the end of the report's period. If the Date::Manip(3) module is installed, you can use any format that this module can parse. If that module isn't installed you must use the following format YYYY-MM-DD HH:MM:SS or any meaningful subset of that format.
If this option is not used, the report will end with the last record.
Sets the length of the report's period. This length is interpreted relative to the report's start. This option has priority over the end option.
If you have the Date::Manip module installed, you can use any format that this module can parse. If that module isn't available, you can use a subset of the following format X weeks X days X hours X mins X secs.
Sets the length the sample's for the report. The sample_report will returns results aggregated over that length. For example, if you use 1d as sample's length, you will get the stats for every day from the beginning of the report until the end.
Restrict records to those whose name matches names.
You can use this parameter multiple times to specify multiple possibility. The record will be included if it matches any of those.
Return the start of the report in seconds since epoch.
Returns the end of the report in seconds since epoch.
Returns the length of the report's period ( $report->end() - $report->start() )
Returns the length of the sample period.
Returns an array reference to all the records read and which makes the report's samples.
Each record is an array ref. You can accessed the individual fields of the record by using the following constants. (Those can be imported by using the :fields import tag.)
:fields
The epoch start time of the sample.
The name of the accounting chain.
The number of packets received.
The total number of bytes.
The following report generation methods are available :
my $r = $report->summary_report();
Generates a report that shows the compiled statistics for every accounting chain.
The resulting report is an array ref of hash reference. Each report record's has the following fields.
The name of the chains.
The total number of packets over the report's period.
This number is a Math::BigInt(3) object.
The total number of bytes received over the report's period.
The average number of packets received by that chain by sample.
The average number of packets bytes by that chain by sample.
my $r = $report->sample_report();
Generates a report that compiles the stats for each sample for each chains.
The resulting report is an hash reference. Each key is a chain and each value is an array ref to the chain compiled statistics. Each element of the array is an hash reference comprises of the following elements :
The start time in seconds since epoch for that sample.
The total number of packets received in that sample.
The total number of bytes received in that sample.
Francis J. Lacoste <francis.lacoste@iNsu.COM>
Copyright (c) 2000 iNsu Innovations Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Fwctl(3) Fwctl::RuleSet(3) fwctl(8) fwctllog(8) fwctacctreport(8) Fwctl::Report(3) Date::Manip(3).
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Fwctl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fwctl
CPAN shell
perl -MCPAN -e shell install Fwctl
For more information on module installation, please visit the detailed CPAN module installation guide.