OSSP CVS Repository

ossp - Check-in [4932]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4932
Date: 2004-Dec-29 13:03:13 (local)
2004-Dec-29 12:03:13 (UTC)
User:rse
Branch:
Comment: - Reduce flow accumulation window from 5 min to 1 min in order to get more detailed graphs. - Speed up processing of flows under "flow2rrd --stable" a little bit. - Allow floating point numbers for the time ranges in the Web UI.
Tickets:
Inspections:
Files:
ossp-pkg/flow2rrd/ChangeLog      1.9 -> 1.10     10 inserted, 0 deleted
ossp-pkg/flow2rrd/flow2rrd.pl      1.14 -> 1.15     29 inserted, 19 deleted

ossp-pkg/flow2rrd/ChangeLog 1.9 -> 1.10

--- ChangeLog    2004/12/27 15:58:23     1.9
+++ ChangeLog    2004/12/29 12:03:13     1.10
@@ -9,6 +9,16 @@
   ChangeLog
 
   Changes between 0.9.1 and 0.9.2 (26-Dec-2004 to 27-Dec-2004):
+    
+    *) Reduce flow accumulation window from 5 min to 1 min in order
+       to get more detailed graphs.
+       [Ralf S. Engelschall]
+
+    *) Speed up processing of flows under "flow2rrd --stable" a little bit.
+       [Ralf S. Engelschall]
+
+    *) Allow floating point numbers for the time ranges in the Web UI.
+       [Ralf S. Engelschall]
 
     *) Reduce color-reduction for incoming traffic to not underflow too
        fast and render the incoming/outgoing legend more as a table.


ossp-pkg/flow2rrd/flow2rrd.pl 1.14 -> 1.15

--- flow2rrd.pl  2004/12/27 16:11:47     1.14
+++ flow2rrd.pl  2004/12/29 12:03:13     1.15
@@ -207,15 +207,20 @@
 #print Data::Dumper->Dump([$cfg]);
 
 #   hostname/target/service to 15 chars RRD DS name mapping
+my $rrd_ds_name_cache = {};
 sub make_rrd_ds_name {
     my ($host, $target, $service) = @_;
-    $host    =~ s|[^a-zA-Z0-9_-]||sg;
-    $host    = substr($host . ("_"x5), 0, 5);
-    $target  =~ s|[^a-zA-Z0-9_-]||sg;
-    $target  = substr($target . ("_"x5), 0, 5);
-    $service =~ s|[^a-zA-Z0-9_-]||sg;
-    $service = substr($service . ("_"x5), 0, 5);
-    my $ds_name = sprintf("%s_%s_%s", $host, $target, $service);
+    my $ds_name = $rrd_ds_name_cache->{$host.$target.$service};
+    if (not defined($ds_name)) {
+        $host    =~ s|[^a-zA-Z0-9_-]||sg;
+        $host    = substr($host . ("_"x5), 0, 5);
+        $target  =~ s|[^a-zA-Z0-9_-]||sg;
+        $target  = substr($target . ("_"x5), 0, 5);
+        $service =~ s|[^a-zA-Z0-9_-]||sg;
+        $service = substr($service . ("_"x5), 0, 5);
+        $ds_name = sprintf("%s_%s_%s", $host, $target, $service);
+        $rrd_ds_name_cache->{$host.$target.$service} = $ds_name;
+    }
     return $ds_name;
 }
 
@@ -224,7 +229,7 @@
 ##
 
 if ($opt->{-store}) {
-    my $step = 5*60; # 5 min
+    my $step = 1*60; # 1 min
 
     #   initialize data
     my $ctx = &data_init($cfg);
@@ -316,13 +321,14 @@
             my $rra = sprintf('RRA:LAST:0:%d:%d', $steps, $rows);
             push(@rra, $rra);
         }
-        &mkrra($step,     5*60,     7*24*60*60); #  5 min  res. for 1 week
-        &mkrra($step,    10*60,    14*24*60*60); # 10 min  res. for 2 weeks
-        &mkrra($step,    30*60,    30*24*60*60); # 30 min  res. for 1 month
-        &mkrra($step,    60*60,  3*30*24*60*60); #  1 hour res. for 3 months
-        &mkrra($step,  3*60*60,  6*30*24*60*60); #  3 hour res. for 6 months
-        &mkrra($step,  6*60*60,   365*24*60*60); #  6 hour res. for 1 year
-        &mkrra($step, 24*60*60, 4*365*24*60*60); #  1 days res. for 4 year
+        &mkrra($step,     1*60,     7*24*60*60); #  1 min  res. for 1 week
+        &mkrra($step,     2*60,    14*24*60*60); #  2 min  res. for 2 weeks
+        &mkrra($step,     5*60,    30*24*60*60); #  5 min  res. for 1 month
+        &mkrra($step,    15*60,  3*30*24*60*60); # 15 min  res. for 3 months
+        &mkrra($step,  1*60*60,  6*30*24*60*60); #  1 hour res. for 6 months
+        &mkrra($step,  2*60*60,   365*24*60*60); #  2 hour res. for 1 year
+        &mkrra($step,  6*60*60, 2*365*24*60*60); #  6 hour res. for 2 years
+        &mkrra($step, 12*60*60, 4*365*24*60*60); # 12 hour res. for 4 years
 
         #   create RRD database
         RRDs::create($cfg->{'Database'}, '--start', $time, '--step', $step, @ds, @rra);
@@ -362,13 +368,14 @@
         #   iterate over all target and services to see whether
         #   the flow matches them...
         my $matched_total = 0;
-        LOOP: foreach my $host (@{$cfg->{'Host'}}) {
+        LOOP:
+        foreach my $host (@{$cfg->{'Host'}}) {
             foreach my $target (@{$host->{-target}->{-order}}) {
                 my $matched = 0;
                 my $inbound; $inbound = undef;
                 my $np = $ctx->{-network}->{$host->{-name}.":".$target};
-                if ($np->match_string($Cflow::srcip)) { $inbound = 0; }
-                if ($np->match_string($Cflow::dstip)) { $inbound = 1; }
+                if    ($np->match_string($Cflow::srcip)) { $inbound = 0; }
+                elsif ($np->match_string($Cflow::dstip)) { $inbound = 1; }
                 if (defined($inbound)) {
                     foreach my $service (@{$host->{-target}->{$target}->{-service}}) {
                         my $services = $cfg->{'Service'}->{$service};
@@ -457,7 +464,7 @@
             elsif ($t =~ m|(\d{2})-([A-Za-z]{3})-(\d{4})|) {
                 $t = str2time($t);
             }
-            elsif ($t =~ m|^(\d+)([smhdwMY])$|) {
+            elsif ($t =~ m|^([\d.]+)([smhdwMY])$|) {
                 $t = $1;
                 if    ($2 eq 's') { $t *=            1; }
                 elsif ($2 eq 'm') { $t *=           60; }
@@ -467,6 +474,9 @@
                 elsif ($2 eq 'M') { $t *=  30*24*60*60; }
                 elsif ($2 eq 'Y') { $t *= 365*24*60*60; }
             }
+            elsif ($t =~ m|^([\d.]+)$|) {
+                $t = $1;
+            }
             else {
                 $t = 0;
             }

CVSTrac 2.0.1