Changeset 104 for trunk/klask


Ignore:
Timestamp:
Dec 12, 2011, 2:11:24 PM (12 years ago)
Author:
g7moreau
Message:
  • Multi VLAN clean DB
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r103 r104  
    844844   my $timestamp_barrier = 3600 * 24 * $days_to_clean;
    845845
     846   my %mactimedb = ();
    846847   ALL_VLAN:
    847848   for my $vlan (@vlan_name) {
    848849
    849850      my @ip_list   = get_list_ip($vlan);
    850       my %mactimedb = ();
    851851     
    852852      LOOP_ON_IP_ADDRESS:
     
    857857           
    858858            #&& $computerdb->{$ip}{timestamp} > $timestamp_barrier;
    859          my $ip_timestamp = $computerdb->{$ip}{timestamp};
    860          my $ip_mac       = $computerdb->{$ip}{mac_address};
     859         my $ip_timestamp   = $computerdb->{$ip}{timestamp};
     860         my $ip_mac         = $computerdb->{$ip}{mac_address};
     861         my $ip_hostname_fq = $computerdb->{$ip}{hostname_fq};
     862
     863         $mactimedb{$ip_mac} ||= {
     864            ip          => $ip,
     865            timestamp   => $ip_timestamp,
     866            vlan        => $vlan,
     867            hostname_fq => $ip_hostname_fq,
     868            };
    861869         
    862          $mactimedb{$ip_mac} ||= [ $ip, $ip_timestamp ];
    863          
    864          if ( $mactimedb{$ip_mac}->[1] - $ip_timestamp > $timestamp_barrier ) {
     870         if ( $mactimedb{$ip_mac}->{timestamp} - $ip_timestamp > $timestamp_barrier
     871            and not $mactimedb{$ip_mac}->{hostname_fq} =~ m/^float/ ) {
    865872            print "remove ip $ip\n" if $verbose;
    866873            delete $computerdb->{$ip};
     
    868875            }
    869876
    870          if ( $ip_timestamp - $mactimedb{$ip_mac}->[1] > $timestamp_barrier ) {
    871             print "remove ip ".$mactimedb{$ip_mac}->[0]."\n" if $verbose;
    872             delete $computerdb->{$mactimedb{$ip_mac}->[0]};
     877         if ( $ip_timestamp - $mactimedb{$ip_mac}->{timestamp} > $timestamp_barrier
     878            and not $ip_hostname_fq =~ m/^float/ ) {
     879            print "remove ip ".$mactimedb{$ip_mac}->{ip}."\n" if $verbose;
     880            delete $computerdb->{$mactimedb{$ip_mac}->{ip}};
    873881            $database_has_changed++;
    874882            }
    875883
    876          if ( $ip_timestamp > $mactimedb{$ip_mac}->[1]) {
    877             $mactimedb{$ip_mac} = [ $ip, $ip_timestamp ];
     884         if ( $ip_timestamp > $mactimedb{$ip_mac}->{timestamp}) {
     885            $mactimedb{$ip_mac} = {
     886               ip          => $ip,
     887               timestamp   => $ip_timestamp,
     888               vlan        => $vlan,
     889               hostname_fq => $ip_hostname_fq,
     890               };
    878891            }
    879892         }
Note: See TracChangeset for help on using the changeset viewer.