Changeset 198
- Timestamp:
- Jan 25, 2017, 11:04:43 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r197 r198 22 22 23 23 # apt-get install snmp fping libnet-cidr-lite-perl libnet-netmask-perl libnet-snmp-perl libnetaddr-ip-perl libyaml-perl 24 # libcrypt-des-perl libcrypt-hcesha-perl libdigest-hmac-perl 24 # libcrypt-des-perl libcrypt-hcesha-perl libdigest-hmac-perl 25 25 # arping net-tools fping bind9-host arpwatch 26 26 … … 651 651 if ($sw_model eq 'HP2424M') { 652 652 if ($sw_port > 24) { 653 653 654 654 my $reste = $sw_port - 24; 655 655 return "A$reste"; … … 659 659 if ($sw_model eq 'HP1600M') { 660 660 if ($sw_port > 16) { 661 661 662 662 my $reste = $sw_port - 16; 663 663 return "A$reste"; … … 667 667 if ($sw_model eq 'HP2810-48G' or $sw_model eq 'HP2810-24G') { 668 668 if ($sw_port > 48) { 669 669 670 670 my $reste = $sw_port - 48; 671 671 return "Trk$reste"; … … 675 675 if ($sw_model eq 'HP3500-24G') { 676 676 if ($sw_port > 289) { 677 677 678 678 my $reste = $sw_port - 289; 679 679 return "Trk$reste"; … … 750 750 sub snmp_get_swithport_hr { 751 751 my ($snmp_session, $swport) = @_; 752 752 753 753 my $research_index = $OID_NUMBER{ifIndex} .'.'. $swport; 754 754 my $result_index = $snmp_session->get_request( … … 775 775 776 776 next LOOP_ON_IP_ADDRESS if exists $computerdb->{$ip}{switch_port_hr} and defined $computerdb->{$ip}{switch_port_hr}; 777 777 778 778 $computerdb->{$ip}{switch_port_hr} = $computerdb->{$ip}{switch_port}; 779 779 } … … 912 912 for my $ip (keys %{$computerdb}) { 913 913 next LOOP_ON_COMPUTER if $mac ne $computerdb->{$ip}{mac_address}; 914 914 915 915 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $computerdb->{$ip}{timestamp}; 916 916 $year += 1900; … … 1176 1176 1177 1177 my @ip_list = shuffle get_list_ip($vlan); 1178 1178 1179 1179 LOOP_ON_IP_ADDRESS: 1180 1180 for my $ip (@ip_list) { … … 1182 1182 next LOOP_ON_IP_ADDRESS if 1183 1183 not exists $computerdb->{$ip}; 1184 1184 1185 1185 #&& $computerdb->{$ip}{timestamp} > $timestamp_barrier; 1186 1186 my $ip_timestamp = $computerdb->{$ip}{timestamp}; … … 1194 1194 hostname_fq => $ip_hostname_fq, 1195 1195 }; 1196 1196 1197 1197 if ( 1198 1198 ( $mactimedb{$ip_mac}->{timestamp} - $ip_timestamp > $timestamp_barrier … … 1578 1578 $ip_timestamp_mod -= 15 * 24 * 3600 if $ip_hostname_fq =~ m/$RE_FLOAT_HOSTNAME/; 1579 1579 $ip_timestamp_ref -= 15 * 24 * 3600 if $swithportdb{$swpt}->{hostname_fq} =~ m/$RE_FLOAT_HOSTNAME/; 1580 1580 1581 1581 if ($ip_timestamp_mod > $ip_timestamp_ref) { 1582 1582 $swithportdb{$swpt} = { … … 1602 1602 next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} =~ m/$RE_FLOAT_HOSTNAME/; 1603 1603 next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{timestamp} < $src_timestamp; 1604 1604 1605 1605 $src_ip = $ip; 1606 1606 $src_timestamp = $computerdb->{$ip}{timestamp}; … … 1901 1901 if (exists $computerdb->{$ip}) { 1902 1902 next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{timestamp} > $timestamp_barrier; 1903 1903 1904 1904 my $mac_address = $computerdb->{$ip}{mac_address}; 1905 1905 LOOP_ON_DATABASE: … … 1938 1938 sub cmd_ip_free_txt { 1939 1939 my %result_ip = @_; 1940 1940 1941 1941 printf "%-15s %-40s %-16s %s\n", qw(IPv4-Address Hostname-FQ Date VLAN); 1942 1942 print "-------------------------------------------------------------------------------\n"; … … 2152 2152 2153 2153 ALL_SWITCH: 2154 for my $one_ computer(@list_all_switch) {2155 my %resol_arp = resolve_ip_arp_host($one_ computer, q{*}, q{low}); # arp resolution2156 print "Info: switch loop $one_ computer\n" if $verbose;2154 for my $one_switch (@list_all_switch) { 2155 my %resol_arp = resolve_ip_arp_host($one_switch, q{*}, q{low}); # arp resolution 2156 print "Info: switch loop $one_switch\n" if $verbose; 2157 2157 next ALL_SWITCH if $resol_arp{mac_address} eq 'unknow'; 2158 2158 … … 2164 2164 2165 2165 if ($verbose) { 2166 print "VERBOSE_3: $one_ computer$resol_arp{ipv4_address} $resol_arp{mac_address}\n";2167 print "VERBOSE_3: $one_ computer--- ",2166 print "VERBOSE_3: $one_switch $resol_arp{ipv4_address} $resol_arp{mac_address}\n"; 2167 print "VERBOSE_3: $one_switch --- ", 2168 2168 join(' + ', keys %{$where{$resol_arp{ipv4_address}}}), 2169 2169 "\n"; … … 2173 2173 print "VERBOSE_4: db_switch_ip_hostnamefq $resol_arp{ipv4_address} -> $resol_arp{hostname_fq}\n" if $verbose; 2174 2174 2175 $SWITCH_DB{$one_ computer}->{ipv4_address} = $resol_arp{ipv4_address};2176 $SWITCH_DB{$one_ computer}->{mac_address} = $resol_arp{mac_address};2177 $SWITCH_DB{$one_ computer}->{timestamp} = $timestamp;2175 $SWITCH_DB{$one_switch}->{ipv4_address} = $resol_arp{ipv4_address}; 2176 $SWITCH_DB{$one_switch}->{mac_address} = $resol_arp{mac_address}; 2177 $SWITCH_DB{$one_switch}->{timestamp} = $timestamp; 2178 2178 } 2179 2179
Note: See TracChangeset
for help on using the changeset viewer.