Changeset 132
- Timestamp:
- Nov 1, 2013, 2:09:52 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r131 r132 187 187 sub fast_ping { 188 188 # Launch this command without waiting... 189 system "fping - c 1 @_ >/dev/null 2>&1 &";189 system "fping -q -c 1 @_ >/dev/null 2>&1 &"; 190 190 return; 191 191 } … … 768 768 my $current_interface = get_current_interface($net); 769 769 770 #fast_ping(@computer);770 fast_ping(@computer); 771 771 772 772 LOOP_ON_COMPUTER: … … 1285 1285 my $computerdb = YAML::Syck::LoadFile("$KLASK_DB_FILE"); 1286 1286 1287 # create a database with the most recent computer by switch port 1287 1288 my %swithportdb = (); 1288 1289 LOOP_ON_IP_ADDRESS: … … 1290 1291 # to be improve in the future 1291 1292 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'; 1292 1295 1293 1296 my $ip_timestamp = $computerdb->{$ip}{timestamp}; … … 1306 1309 }; 1307 1310 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) { 1317 1318 $swithportdb{$swpt} = { 1318 1319 ip => $ip, … … 1339 1340 $src_timestamp = $computerdb->{$ip}{timestamp}; 1340 1341 } 1341 1342 1343 # keep only if float computer is the most recent 1342 1344 next if $src_timestamp == 0; 1343 1345 next if $swithportdb{$swpt}->{timestamp} < $src_timestamp; 1346 1344 1347 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $swithportdb{$swpt}->{timestamp}; 1345 1348 $year += 1900; 1346 1349 $mon++; 1347 my $date = sprintf '%04i-%02i-%02i 1350 my $date = sprintf '%04i-%02i-%02i/%02i:%02i', $year, $mon, $mday, $hour, $min; 1348 1351 1349 1352 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $computerdb->{$src_ip}{timestamp}; 1350 1353 $year += 1900; 1351 1354 $mon++; 1352 my $src_date = sprintf '%04i-%02i-%02i 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", 1355 1358 $swpt, $swithportdb{$swpt}->{vlan}, $computerdb->{$src_ip}{network}, 1356 1359 $date, 1357 1360 $src_date, 1361 $computerdb->{$src_ip}{mac_address}, 1358 1362 $computerdb->{$src_ip}{hostname_fq}; 1359 1363 } … … 1984 1988 1985 1989 print "digraph G {\n"; 1990 print "rankdir = LR;\n"; 1986 1991 1987 1992 print "site [label = \"site\", color = black, fillcolor = gold, shape = invhouse, style = filled];\n";
Note: See TracChangeset
for help on using the changeset viewer.