Changeset 132 for trunk/klask


Ignore:
Timestamp:
Nov 1, 2013, 2:09:52 PM (10 years ago)
Author:
g7moreau
Message:
  • Many update and fix in bad-vlan-config method
  • Activate fastping in updatedb method (without, pb when two IP on same network)
  • Create graph in horizontal and not vertical any more
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r131 r132  
    187187sub fast_ping {
    188188   # Launch this command without waiting...
    189    system "fping -c 1 @_ >/dev/null 2>&1 &";
     189   system "fping -q -c 1 @_ >/dev/null 2>&1 &";
    190190   return;
    191191   }
     
    768768      my $current_interface = get_current_interface($net);
    769769
    770       #fast_ping(@computer);
     770      fast_ping(@computer);
    771771
    772772      LOOP_ON_COMPUTER:
     
    12851285   my $computerdb = YAML::Syck::LoadFile("$KLASK_DB_FILE");
    12861286
     1287   # create a database with the most recent computer by switch port
    12871288   my %swithportdb = ();
    12881289   LOOP_ON_IP_ADDRESS:
     
    12901291      # to be improve in the future
    12911292      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
     1293      next LOOP_ON_IP_ADDRESS if ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}) eq 'unknow';
     1294      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{switch_port} eq '0';
    12921295
    12931296      my $ip_timestamp   = $computerdb->{$ip}{timestamp};
     
    13061309         };
    13071310
    1308       if (
    1309          ($ip_hostname_fq =~ m/$RE_FLOAT_HOSTNAME/ and $ip_timestamp > $swithportdb{$swpt}->{timestamp} + (15 * 24 * 3600))
    1310          or
    1311          ($ip_hostname_fq !~ m/$RE_FLOAT_HOSTNAME/ and (
    1312             ($swithportdb{$swpt}->{hostname_fq} =~ m/$RE_FLOAT_HOSTNAME/ and $ip_timestamp > $swithportdb{$swpt}->{timestamp} - (15 * 24 * 3600))
    1313             or
    1314             ($swithportdb{$swpt}->{hostname_fq} !~ m/$RE_FLOAT_HOSTNAME/ and $ip_timestamp > $swithportdb{$swpt}->{timestamp})
    1315             ))
    1316          ) {
     1311      # if float computer, set date 15 day before warning...
     1312      my $ip_timestamp_mod = $ip_timestamp;
     1313      my $ip_timestamp_ref = $swithportdb{$swpt}->{timestamp};
     1314      $ip_timestamp_mod -= 15 * 24 * 3600 if $ip_hostname_fq =~ m/$RE_FLOAT_HOSTNAME/;
     1315      $ip_timestamp_ref -= 15 * 24 * 3600 if $swithportdb{$swpt}->{hostname_fq} =~ m/$RE_FLOAT_HOSTNAME/;
     1316     
     1317      if ($ip_timestamp_mod > $ip_timestamp_ref) {
    13171318         $swithportdb{$swpt} = {
    13181319            ip          => $ip,
     
    13391340         $src_timestamp = $computerdb->{$ip}{timestamp};
    13401341         }
    1341      
     1342
     1343      # keep only if float computer is the most recent
    13421344      next if $src_timestamp == 0;
    1343      
     1345      next if $swithportdb{$swpt}->{timestamp} < $src_timestamp;
     1346
    13441347      my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $swithportdb{$swpt}->{timestamp};
    13451348      $year += 1900;
    13461349      $mon++;
    1347       my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min;
     1350      my $date = sprintf '%04i-%02i-%02i/%02i:%02i', $year, $mon, $mday, $hour, $min;
    13481351
    13491352      ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $computerdb->{$src_ip}{timestamp};
    13501353      $year += 1900;
    13511354      $mon++;
    1352       my $src_date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min;
    1353 
    1354       printf "%s / %-10s +-> %-10s  %s / %s # %s\n",
     1355      my $src_date = sprintf '%04i-%02i-%02i/%02i:%02i', $year, $mon, $mday, $hour, $min;
     1356
     1357      printf "%s / %-10s +-> %-10s  %s %s %s %s\n",
    13551358         $swpt, $swithportdb{$swpt}->{vlan}, $computerdb->{$src_ip}{network},
    13561359         $date,
    13571360         $src_date,
     1361         $computerdb->{$src_ip}{mac_address},
    13581362         $computerdb->{$src_ip}{hostname_fq};
    13591363      }
     
    19841988
    19851989   print "digraph G {\n";
     1990   print "rankdir = LR;\n";
    19861991
    19871992   print "site [label = \"site\", color = black, fillcolor = gold, shape = invhouse, style = filled];\n";
Note: See TracChangeset for help on using the changeset viewer.