You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.8 KiB

Index: flow2rrd.pl
--- flow2rrd.pl.orig 2004-12-26 19:49:13.000000000 +0100
+++ flow2rrd.pl 2011-02-09 11:21:26.000000000 +0100
@@ -31,6 +31,7 @@
# external requirements
use POSIX; # from OpenPKG "perl"
+use IO::All; # from OpenPKG "perl-sys"
use IO::File; # from OpenPKG "perl"
use Getopt::Long; # from OpenPKG "perl"
use File::Temp; # from OpenPKG "perl"
@@ -229,8 +230,12 @@
my $ctx = &data_init($cfg);
# scan flow-tools stream on STDIN for NetFlow records
+ my $data < io("-");
+ my ($tf, $tmpfile) = mkstemp(($ENV{'TMPDIR'} || '/tmp') . "/flow2rrd.XXXXXX");
+ $tf->syswrite($data);
+ $tf->close();
Cflow::verbose(0);
- Cflow::find(sub { &foreach_record($cfg, $ctx) }, "-");
+ Cflow::find(sub { &foreach_record($cfg, $ctx) }, $tmpfile);
sub foreach_record {
my ($cfg, $ctx) = @_;
@@ -259,6 +264,7 @@
&data_accumulate($cfg, $ctx);
}
&rrd_store($cfg, $ctx);
+ unlink($tmpfile);
# initialize data tracking context
sub data_init {
@@ -370,7 +376,7 @@
# the flow matches them...
my $matched_total = 0;
LOOP: foreach my $host (@{$cfg->{'Host'}}) {
- foreach my $target (grep { $_ !~ m/^-/ } keys(%{$host->{-target}})) {
+ foreach my $target (@{$host->{-target}->{-order}}) {
my $matched = 0;
my $inbound; $inbound = undef;
my $np = $ctx->{-network}->{$host->{-name}.":".$target};
@@ -430,7 +436,7 @@
sprintf("%d", $ctx->{-endtime}).":".$dv_list
);
my $err = RRDs::error();
- warn "failed to store data to RRD file: $err" if (defined($err));
+ warn "WARNING: failed to store data to RRD file: $err" if (defined($err));
}
}