Changeset 370 for trunk


Ignore:
Timestamp:
Dec 9, 2017, 4:19:54 PM (6 years ago)
Author:
g7moreau
Message:
  • Update some style coding...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r369 r370  
    5353
    5454   # SNMP parameter initialisation
    55    my %session = ( -hostname   => $sw->{'hostname'} );
     55   my %session = (-hostname => $sw->{'hostname'});
    5656   $session{-version} = $sw->{'version'}  || 1;
    57    $session{-port}    = $sw->{'snmpport'} || $DEFAULT{'snmpport'}  || 161;
     57   $session{-port}    = $sw->{'snmpport'} || $DEFAULT{'snmpport'} || 161;
    5858   if (exists $sw->{'version'} and $sw->{'version'} eq '3') {
    5959      $session{-username} = $sw->{'username'} || 'snmpadmin';
     
    323323   # LANG=C ip neigh show to 194.254.66.62
    324324   # 194.254.66.62 dev eth331 lladdr 00:08:7c:bb:0f:c0 REACHABLE
    325 #   my $cmd_arp  = shell_command "arp -a $param_ip_or_host -i $ret{'interface'}";
    326 #   if ( $cmd_arp =~ m{ (\S*) \s \( ( $RE_IPv4_ADDRESS ) \) \s at \s ( $RE_MAC_ADDRESS ) }xms ) {
    327 #      ( $ret{'hostname_fq'}, $ret{'ipv4_address'}, $ret{'mac_address'} )  = ($1, $2, $3);
    328 #      }
     325   #   my $cmd_arp  = shell_command "arp -a $param_ip_or_host -i $ret{'interface'}";
     326   #   if ( $cmd_arp =~ m{ (\S*) \s \( ( $RE_IPv4_ADDRESS ) \) \s at \s ( $RE_MAC_ADDRESS ) }xms ) {
     327   #      ( $ret{'hostname_fq'}, $ret{'ipv4_address'}, $ret{'mac_address'} )  = ($1, $2, $3);
     328   #      }
    329329   if ($ret{'mac_address'} eq 'unknow') {
    330330      # Last chance to have the mac_address
     
    420420
    421421      $sw->{'description'} = $result->{$OID_NUMBER{'sysName'}} || $sw->{'hostname'};
    422       $sw->{'model'} = get_switch_model($result->{$OID_NUMBER{'sysDescription'}});
    423       $sw->{'revision'} = get_switch_revision($result->{$OID_NUMBER{'sysDescription'}});
     422      $sw->{'model'}       = get_switch_model($result->{$OID_NUMBER{'sysDescription'}});
     423      $sw->{'revision'}    = get_switch_revision($result->{$OID_NUMBER{'sysDescription'}});
    424424      printf "%-26s 0--------->>>> %-25s %s\n", $sw->{'hostname'}, $sw->{'description'}, $sw->{'model'}.'('.$sw->{'revision'}.')' if $verbose;
    425425
     
    459459      );
    460460   my @chars = split m//xms, $car;
    461    return $table{$chars[-2]}*16 + $table{$chars[-1]};
     461   return $table{$chars[-2]} * 16 + $table{$chars[-1]};
    462462   }
    463463
     
    475475      }
    476476
    477    return join q{:}, map { substr( uc("00$_"), -2) } split m/ [:-] /xms, $mac_address;
     477   return join q{:}, map {substr(uc("00$_"), -2)} split m/ [:-] /xms, $mac_address;
    478478   }
    479479
     
    540540sub fqdn_html_breakable {
    541541   my $ref_fqdn = \($_[0]);
    542    
     542
    543543   # Add HTML <wbr> before every . to permit line break
    544544   $$ref_fqdn =~ s{\.}{.<wbr />}g;
     
    550550   my $mac_address     = shift;
    551551   my $switch_proposal = shift || q{};
    552    my $vlan_id = shift || 0;
     552   my $vlan_id         = shift || 0;
    553553
    554554   my %ret;
    555555   $ret{'switch_description'} = 'unknow';
    556    $ret{'switch_port_id'} = '0';
    557 
    558    return %ret if $mac_address eq 'unknow';;
     556   $ret{'switch_port_id'}     = '0';
     557
     558   return %ret if $mac_address eq 'unknow';
    559559
    560560   my @switch_search = @SWITCH_LIST;
     
    568568
    569569   my $oid_search_port1 = $OID_NUMBER{'searchPort1'} . mac_address_hex2dec($mac_address);
    570    my $oid_search_port2 = $OID_NUMBER{'searchPort2'} .'.'. $vlan_id . mac_address_hex2dec($mac_address);
     570   my $oid_search_port2 = $OID_NUMBER{'searchPort2'} . '.' . $vlan_id . mac_address_hex2dec($mac_address);
    571571
    572572   LOOP_ON_SWITCH:
    573573   for my $sw (@switch_search) {
    574       my ($session, $error) = Net::SNMP->session( %{$sw->{'snmp_param_session'}} );
     574      my ($session, $error) = Net::SNMP->session(%{$sw->{'snmp_param_session'}});
    575575      print "$error \n" if $error;
    576576
     
    585585         }
    586586
    587       if (not (defined $result and $result->{$oid_search_port1} ne 'noSuchInstance')) {
     587      if (not(defined $result and $result->{$oid_search_port1} ne 'noSuchInstance')) {
    588588         $session->close;
    589589         next LOOP_ON_SWITCH;
     
    629629
    630630   my $oid_search_port1 = $OID_NUMBER{'searchPort1'} . mac_address_hex2dec($mac_address);
    631    my $oid_search_port2 = $OID_NUMBER{'searchPort2'} .'.'. $vlan_id . mac_address_hex2dec($mac_address);
     631   my $oid_search_port2 = $OID_NUMBER{'searchPort2'} . '.' . $vlan_id . mac_address_hex2dec($mac_address);
    632632   LOOP_ON_ALL_SWITCH:
    633633   for my $sw (@SWITCH_LIST) {
     
    653653            if ($swport_hr eq $portignore) {
    654654               $session->close;
    655                next LOOP_ON_ALL_SWITCH
     655               next LOOP_ON_ALL_SWITCH;
    656656               }
    657657            }
     
    715715
    716716   for my $net (@vlan_name) {
    717       my @line  = @{$KLASK_CFG->{'network'}{$net}{'ip-subnet'}};
     717      my @line = @{$KLASK_CFG->{'network'}{$net}{'ip-subnet'}};
    718718      for my $cmd (@line) {
    719719         for my $method (keys %{$cmd}) {
     
    729729      for my $ip (@{$net}) {
    730730         $ip =~ s{ /32 }{}xms;
    731          push @res,  $ip;
     731         push @res, $ip;
    732732         }
    733733      }
     
    752752#---------------------------------------------------------------
    753753sub normalize_port_human_readable {
    754    my $sw_port_hr  = shift;
     754   my $sw_port_hr = shift;
    755755
    756756   # Manufacturer abbreviation
     
    786786   # First get the index, second get the name (port_hr)
    787787
    788    my $oid_search_ix = $OID_NUMBER{'ifIndex'} .'.'. $swport_id;
     788   my $oid_search_ix = $OID_NUMBER{'ifIndex'} . '.' . $swport_id;
    789789   my $result_ix = $snmp_session->get_request(
    790790      -varbindlist => [$oid_search_ix]
     
    811811   if ($swport_hr =~ m/^(Trk|Br|Po)/) {
    812812      my $oid_search_index = $OID_NUMBER{'ifAggregator'}; # base OID
    813       my @args = ( -varbindlist => [$oid_search_index]);
     813      my @args = (-varbindlist => [$oid_search_index]);
    814814      LOOP_ON_OID_PORT:
    815       while ( defined $snmp_session->get_next_request(@args) ) {
     815      while (defined $snmp_session->get_next_request(@args)) {
    816816         my ($oid_current) = $snmp_session->var_bind_names;
    817          last LOOP_ON_OID_PORT if  not Net::SNMP::oid_base_match($oid_search_index, $oid_current);
     817         last LOOP_ON_OID_PORT if not Net::SNMP::oid_base_match($oid_search_index, $oid_current);
    818818
    819819         # IEEE8023-LAG-MIB::dot3adAggPortSelectedAggID.28 = INTEGER: 337
     
    849849
    850850   my $oid_search_ix = $OID_NUMBER{'ifIndex'}; # base OID
    851    my @args = ( -varbindlist => [$oid_search_ix]);
     851   my @args = (-varbindlist => [$oid_search_ix]);
    852852   LOOP_ON_OID_PORT:
    853    while ( defined $snmp_session->get_next_request(@args) ) {
     853   while (defined $snmp_session->get_next_request(@args)) {
    854854      my ($oid_current) = $snmp_session->var_bind_names;
    855       last LOOP_ON_OID_PORT if  not Net::SNMP::oid_base_match($oid_search_ix, $oid_current);
     855      last LOOP_ON_OID_PORT if not Net::SNMP::oid_base_match($oid_search_ix, $oid_current);
    856856
    857857      my $port_ifIndex = $snmp_session->var_bind_list->{$oid_current};
     
    862862      @args = (-varbindlist => [$oid_current]);
    863863
    864       my $oid_search_ifName = $OID_NUMBER{'ifName'} .'.'. $port_ifIndex;
     864      my $oid_search_ifName = $OID_NUMBER{'ifName'} . '.' . $port_ifIndex;
    865865      my $result = $snmp_session->get_request(-varbindlist => [$oid_search_ifName]);
    866866      next LOOP_ON_OID_PORT if not defined $result;
     
    887887
    888888   my $oid_search_index = $OID_NUMBER{'vlanName'}; # base OID
    889    my @args = ( -varbindlist => [$oid_search_index]);
     889   my @args = (-varbindlist => [$oid_search_index]);
    890890   LOOP_ON_VLAN:
    891    while ( defined $snmp_session->get_next_request(@args) ) {
     891   while (defined $snmp_session->get_next_request(@args)) {
    892892      my ($oid_current) = $snmp_session->var_bind_names;
    893893      last LOOP_ON_VLAN if not Net::SNMP::oid_base_match($oid_search_index, $oid_current);
     
    950950      @_);
    951951
    952    init_switch_names('yes');    #nomme les switchs
     952   init_switch_names('yes'); # nomme les switchs
    953953   print "\n";
    954954
     
    958958
    959959   DETECT_ALL_ROUTER:
    960    for my $one_router ( get_list_main_router(get_list_network()) ) {
     960   for my $one_router (get_list_main_router(get_list_network())) {
    961961      print "Info: router loop $one_router\n" if $args{'verbose'};
    962962      my %resol_arp = resolve_ip_arp_host($one_router, q{*}, q{low}); # resolution arp
     
    976976
    977977      ALL_SWITCH_CONNECTED:
    978       for my $switch_detected ( keys %{$where{$ip_router}} ) {
     978      for my $switch_detected (keys %{$where{$ip_router}}) {
    979979
    980980         my $switch = $where{$ip_router}->{$switch_detected};
     
    989989   my %db_switch_link_with = ();
    990990
    991    my @list_all_switch = ();
     991   my @list_all_switch  = ();
    992992   my @list_switch_ipv4 = ();
    993993   for my $sw (@SWITCH_LIST) {
     
    10061006         my %resol_arp_alt = resolve_ip_arp_host($fake_ip, q{*}, q{low}); # arp resolution
    10071007         if ($resol_arp_alt{'mac_address'} ne 'unknow') {
    1008             $resol_arp{'mac_address'}   = $resol_arp_alt{'mac_address'};
    1009             $resol_arp{'interface'}     = $resol_arp_alt{'interface'};
     1008            $resol_arp{'mac_address'} = $resol_arp_alt{'mac_address'};
     1009            $resol_arp{'interface'}   = $resol_arp_alt{'interface'};
    10101010            $resol_arp{'ipv4_address'} .= '*';
    10111011            # Force a MAC trace on switch
     
    10401040   ALL_SWITCH_IP_ADDRESS:
    10411041   for my $ip (@list_switch_ipv4) {
    1042 #   for my $ip (Net::Netmask::sort_by_ip_address(@list_switch_ipv4)) {
     1042      #   for my $ip (Net::Netmask::sort_by_ip_address(@list_switch_ipv4)) {
    10431043
    10441044      print "VERBOSE_5: loop on $db_switch_ip_hostnamefq{$ip}\n" if $args{'verbose'};
    10451045
    10461046      next ALL_SWITCH_IP_ADDRESS if not exists $where{$ip};
    1047 #      next ALL_SWITCH_IP_ADDRESS if not exists $SWITCH_PORT_COUNT{ $db_switch_ip_hostnamefq{$ip} };
     1047      #      next ALL_SWITCH_IP_ADDRESS if not exists $SWITCH_PORT_COUNT{ $db_switch_ip_hostnamefq{$ip} };
    10481048
    10491049      DETECTED_SWITCH:
    1050       for my $switch_detected ( keys %{$where{$ip}} ) {
     1050      for my $switch_detected (keys %{$where{$ip}}) {
    10511051
    10521052         my $switch = $where{$ip}->{$switch_detected};
     
    10571057         next if $switch->{'hostname'} eq $db_switch_ip_hostnamefq{$ip}; # $computerdb->{$ip}{'hostname'};
    10581058
    1059          $db_switch_link_with{ $db_switch_ip_hostnamefq{$ip} } ||= {};
    1060          $db_switch_link_with{ $db_switch_ip_hostnamefq{$ip} }->{ $switch->{'hostname'} } = $switch->{'port_hr'};
     1059         $db_switch_link_with{$db_switch_ip_hostnamefq{$ip}} ||= {};
     1060         $db_switch_link_with{$db_switch_ip_hostnamefq{$ip}}->{$switch->{'hostname'}} = $switch->{'port_hr'};
    10611061         print "VERBOSE_7: +++++\n" if $args{'verbose'};
    10621062         }
     
    10641064      }
    10651065
    1066    my %db_switch_connected_on_port = ();
     1066   my %db_switch_connected_on_port          = ();
    10671067   my $maybe_more_than_one_switch_connected = 'yes';
    1068    my $cloop = 0;
     1068   my $cloop                                = 0;
    10691069
    10701070   while ($maybe_more_than_one_switch_connected eq 'yes' and $cloop < 100) {
     
    10811081         }
    10821082
    1083       $maybe_more_than_one_switch_connected  = 'no';
     1083      $maybe_more_than_one_switch_connected = 'no';
    10841084
    10851085      SWITCH_AND_PORT:
     
    10921092         my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
    10931093         my @sw_on_same_port = keys %{$db_switch_connected_on_port{$swport}};
    1094          print "VERBOSE_10: $swport -- ".$#sw_on_same_port." -- @sw_on_same_port\n" if $args{'verbose'};
     1094         print "VERBOSE_10: $swport -- " . $#sw_on_same_port . " -- @sw_on_same_port\n" if $args{'verbose'};
    10951095
    10961096         CONNECTED:
     
    11131113      }
    11141114
    1115    my %db_switch_parent =();
     1115   my %db_switch_parent = ();
    11161116
    11171117   for my $sw (keys %db_switch_link_with) {
     
    11741174sub cmd_help {
    11751175
    1176 print <<'END';
     1176   print <<'END';
    11771177klask - port and search manager for switches, map management
    11781178
     
    12131213sub cmd_version {
    12141214
    1215 print <<'END';
     1215   print <<'END';
    12161216klask - port and search manager for switches, map management
    12171217Copyright (C) 2005-2017 Gabriel Moreau <Gabriel.Moreau(A)univ-grenoble-alpes.fr>
     
    12281228   my @computer = @_;
    12291229
    1230    init_switch_names();    #nomme les switchs
     1230   init_switch_names(); # nomme les switchs
    12311231   fast_ping(@computer);
    12321232
    12331233   LOOP_ON_COMPUTER:
    12341234   for my $clientname (@computer) {
    1235       my %resol_arp = resolve_ip_arp_host($clientname);          #resolution arp
     1235      my %resol_arp = resolve_ip_arp_host($clientname); # resolution arp
    12361236      my $vlan_name = get_current_vlan_name_for_interface($resol_arp{'interface'});
    12371237      my $vlan_id   = get_current_vlan_id($vlan_name);
    1238       my %where     = find_switch_port($resol_arp{'mac_address'}, '', $vlan_id); #retrouve l'emplacement
     1238      my %where     = find_switch_port($resol_arp{'mac_address'}, '', $vlan_id); # retrouve l'emplacement
    12391239
    12401240      next LOOP_ON_COMPUTER if $where{'switch_description'} eq 'unknow' or $resol_arp{'hostname_fq'} eq 'unknow' or $resol_arp{'mac_address'} eq 'unknow';
     
    12451245         $resol_arp{'hostname_fq'},
    12461246         $resol_arp{'ipv4_address'},
    1247          $resol_arp{'mac_address'}."\n";
     1247         $resol_arp{'mac_address'} . "\n";
    12481248      }
    12491249   return;
     
    12521252#---------------------------------------------------------------
    12531253sub cmd_searchdb {
    1254    my @ARGV  = @_;
     1254   my @ARGV = @_;
    12551255
    12561256   my $kind;
     
    12611261
    12621262   my %possible_search = (
    1263       host  => \&cmd_searchdb_host,
    1264       mac   => \&cmd_searchdb_mac,
     1263      host => \&cmd_searchdb_host,
     1264      mac  => \&cmd_searchdb_mac,
    12651265      );
    12661266
     
    12711271   }
    12721272
    1273 
    12741273#---------------------------------------------------------------
    12751274sub cmd_searchdb_host {
     
    12811280   LOOP_ON_COMPUTER:
    12821281   for my $clientname (@computer) {
    1283       my %resol_arp = resolve_ip_arp_host($clientname);      #resolution arp
    1284       my $ip = $resol_arp{'ipv4_address'};
     1282      my %resol_arp = resolve_ip_arp_host($clientname); # resolution arp
     1283      my $ip        = $resol_arp{'ipv4_address'};
    12851284
    12861285      next LOOP_ON_COMPUTER unless exists $computerdb->{$ip};
    12871286
    1288       my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $computerdb->{$ip}{'timestamp'};
     1287      my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computerdb->{$ip}{'timestamp'};
    12891288      $year += 1900;
    12901289      $mon++;
     
    13041303#---------------------------------------------------------------
    13051304sub cmd_searchdb_mac {
    1306    my @mac = map { normalize_mac_address($_) } @_;
     1305   my @mac = map {normalize_mac_address($_)} @_;
    13071306
    13081307   my $computerdb = computerdb_load();
     
    13141313         next LOOP_ON_COMPUTER if $mac ne $computerdb->{$ip}{'mac_address'};
    13151314
    1316          my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $computerdb->{$ip}{'timestamp'};
     1315         my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computerdb->{$ip}{'timestamp'};
    13171316         $year += 1900;
    13181317         $mon++;
     
    13481347
    13491348   my @network = @ARGV;
    1350       @network = get_list_network() if not @network;
     1349   @network = get_list_network() if not @network;
    13511350
    13521351   test_switchdb_environnement();
    13531352
    13541353   my $computerdb = {};
    1355       $computerdb = computerdb_load() if -e "$KLASK_DB_FILE";
     1354   $computerdb = computerdb_load() if -e "$KLASK_DB_FILE";
    13561355   my $timestamp = time;
    13571356
     
    13611360   my $number_of_computer = get_list_ip(@network); # + 1;
    13621361   my $size_of_database   = keys %{$computerdb};
    1363       $size_of_database  = 1 if $size_of_database == 0;
    1364    my $i = 0;
     1362   $size_of_database = 1 if $size_of_database == 0;
     1363   my $i                 = 0;
    13651364   my $detected_computer = 0;
    13661365
    1367    init_switch_names('yes', $verb_description, $check_hostname, $check_location);    #nomme les switchs
     1366   init_switch_names('yes', $verb_description, $check_hostname, $check_location); # nomme les switchs
    13681367
    13691368   {
     
    14001399   my %router_mac_ip = ();
    14011400   DETECT_ALL_ROUTER:
    1402 #   for my $one_router ('194.254.66.254') {
    1403    for my $one_router ( get_list_main_router(@network) ) {
     1401   #   for my $one_router ('194.254.66.254') {
     1402   for my $one_router (get_list_main_router(@network)) {
    14041403      my %resol_arp = resolve_ip_arp_host($one_router);
    1405       $router_mac_ip{ $resol_arp{'mac_address'} } = $resol_arp{'ipv4_address'};
     1404      $router_mac_ip{$resol_arp{'mac_address'}} = $resol_arp{'ipv4_address'};
    14061405      }
    14071406
     
    14091408   for my $current_net (@network) {
    14101409
    1411       my @computer = get_list_ip($current_net);
     1410      my @computer          = get_list_ip($current_net);
    14121411      my $current_interface = get_current_interface($current_net);
    14131412
     
    14181417         $i++;
    14191418
    1420          my $total_percent = int (($i*100)/$number_of_computer);
     1419         my $total_percent = int(($i * 100) / $number_of_computer);
    14211420
    14221421         my $localtime = time - $timestamp;
    1423          my ($sec,$min) = localtime $localtime;
     1422         my ($sec, $min) = localtime $localtime;
    14241423
    14251424         my $time_elapse = 0;
    1426             $time_elapse = $localtime * ( 100 - $total_percent) / $total_percent if $total_percent != 0;
    1427          my ($sec_elapse,$min_elapse) = localtime $time_elapse;
    1428 
    1429          printf "\rComputer scanned: %4i/%i (%2i%%)",  $i,                $number_of_computer, $total_percent;
    1430          printf ', detected: %4i/%i (%2i%%)', $detected_computer, $size_of_database,   int(($detected_computer*100)/$size_of_database);
    1431          printf ' [Time: %02i:%02i / %02i:%02i]', int($localtime/60), $localtime % 60, int($time_elapse/60), $time_elapse % 60;
     1425         $time_elapse = $localtime * (100 - $total_percent) / $total_percent if $total_percent != 0;
     1426         my ($sec_elapse, $min_elapse) = localtime $time_elapse;
     1427
     1428         printf "\rComputer scanned: %4i/%i (%2i%%)", $i, $number_of_computer, $total_percent;
     1429         printf ', detected: %4i/%i (%2i%%)', $detected_computer, $size_of_database, int(($detected_computer * 100) / $size_of_database);
     1430         printf ' [Time: %02i:%02i / %02i:%02i]', int($localtime / 60), $localtime % 60, int($time_elapse / 60), $time_elapse % 60;
    14321431         printf ' %-8s %-14s', $current_interface, $one_computer;
    14331432
     
    14361435
    14371436         # do not search on router connection (why ?)
    1438          if ( exists $router_mac_ip{$resol_arp{'mac_address'}}) {
     1437         if (exists $router_mac_ip{$resol_arp{'mac_address'}}) {
    14391438            $computer_not_detected{$one_computer} = $current_net;
    14401439            next LOOP_ON_COMPUTER;
     
    14601459         my $vlan_name = get_current_vlan_name_for_interface($resol_arp{'interface'});
    14611460         my $vlan_id   = get_current_vlan_id($vlan_name);
    1462          my %where = find_switch_port($resol_arp{'mac_address'}, $switch_proposal, $vlan_id);
     1461         my %where     = find_switch_port($resol_arp{'mac_address'}, $switch_proposal, $vlan_id);
    14631462
    14641463         #192.168.24.156:
     
    14701469
    14711470         # do not have a mac address
    1472 #         if ($resol_arp{'mac_address'} eq 'unknow') {
    1473 #            $computer_not_detected{$one_computer} = $current_interface;
    1474 #            next LOOP_ON_COMPUTER;
    1475 #            }
     1471         #         if ($resol_arp{'mac_address'} eq 'unknow') {
     1472         #            $computer_not_detected{$one_computer} = $current_interface;
     1473         #            next LOOP_ON_COMPUTER;
     1474         #            }
    14761475
    14771476         # detected on a switch
     
    15131512
    15141513         # relance un arping sur la machine si celle-ci n'a pas été détectée depuis plus d'une semaine
    1515 #        push @computer_not_detected, $resol_arp{'ipv4_address'} if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
     1514         # push @computer_not_detected, $resol_arp{'ipv4_address'} if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
    15161515         $computer_not_detected{$resol_arp{'ipv4_address'}} = $current_net if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
    15171516
     
    15281527
    15291528   for my $one_computer (keys %computer_not_detected) {
    1530       my $current_net = $computer_not_detected{$one_computer};
     1529      my $current_net       = $computer_not_detected{$one_computer};
    15311530      my $current_interface = get_current_interface($current_net);
    15321531      system "arping -c 1 -w 1 -rR -i $current_interface $one_computer > /dev/null 2>&1" if get_current_scan_mode($current_net) eq 'active';
     
    15461545   for my $one_computer (@computer) {
    15471546
    1548       if ( $one_computer =~ m/^ $RE_IPv4_ADDRESS $/xms
    1549             and exists $computerdb->{$one_computer} ) {
     1547      if ($one_computer =~ m/^ $RE_IPv4_ADDRESS $/xms
     1548            and exists $computerdb->{$one_computer}) {
    15501549         delete $computerdb->{$one_computer};
    15511550         next;
     
    15661565#---------------------------------------------------------------
    15671566sub cmd_cleandb {
    1568    my @ARGV  = @_;
     1567   my @ARGV = @_;
    15691568
    15701569   my $days_to_clean = 15;
     
    15741573
    15751574   GetOptions(
    1576       'day|d=i'   => \$days_to_clean,
    1577       'verbose|v' => \$verbose,
     1575      'day|d=i'      => \$days_to_clean,
     1576      'verbose|v'    => \$verbose,
    15781577      'repair-dns|r' => \$repairdns,
    15791578      );
     
    15821581
    15831582   my $computerdb = computerdb_load();
    1584    my $timestamp = time;
     1583   my $timestamp  = time;
    15851584
    15861585   my $timestamp_barrier = 3600 * 24 * $days_to_clean;
     
    15911590   for my $vlan (shuffle @vlan_name) {
    15921591
    1593       my @ip_list   = shuffle get_list_ip($vlan);
     1592      my @ip_list = shuffle get_list_ip($vlan);
    15941593
    15951594      LOOP_ON_IP_ADDRESS:
    15961595      for my $ip (@ip_list) {
    15971596
    1598          next LOOP_ON_IP_ADDRESS if
    1599             not exists $computerdb->{$ip};
    1600 
    1601             #&& $computerdb->{$ip}{'timestamp'} > $timestamp_barrier;
     1597         next LOOP_ON_IP_ADDRESS
     1598            if not exists $computerdb->{$ip};
     1599
     1600         #&& $computerdb->{$ip}{'timestamp'} > $timestamp_barrier;
    16021601         my $ip_timestamp   = $computerdb->{$ip}{'timestamp'};
    16031602         my $ip_mac         = $computerdb->{$ip}{'mac_address'};
     
    16431642            }
    16441643
    1645          if ( $ip_timestamp > $mactimedb{$ip_mac}->{'timestamp'}) {
     1644         if ($ip_timestamp > $mactimedb{$ip_mac}->{'timestamp'}) {
    16461645            $mactimedb{$ip_mac} = {
    16471646               ip          => $ip,
     
    16701669      }
    16711670
    1672    if ( $database_has_changed ) {
     1671   if ($database_has_changed) {
    16731672      my $dirdb = $KLASK_DB_FILE;
    16741673         $dirdb =~ s{ / [^/]* $}{}xms;
     
    17291728
    17301729      my $vlan = '';
    1731       $vlan = $computerdb->{$ip}{'network'}.'('.get_current_vlan_id($computerdb->{$ip}{'network'}).')' if $computerdb->{$ip}{'network'};
     1730      $vlan = $computerdb->{$ip}{'network'} . '(' . get_current_vlan_id($computerdb->{$ip}{'network'}).')' if $computerdb->{$ip}{'network'};
    17321731
    17331732      my $arrow = '<---';
     
    18861885
    18871886         my $vlan = $db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'};
    1888          $vlan .= ' ('.get_current_vlan_id($db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'}).')' if $db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'};
     1887         $vlan .= ' (' . get_current_vlan_id($db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'}) . ')' if $db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'};
    18891888
    18901889         my $parent_port_hr = format_aggregator4html($db_switch_output_port{$sw});
     
    32883287   }
    32893288
    3290 
    32913289################################################################
    32923290# documentation
Note: See TracChangeset for help on using the changeset viewer.