Changeset 150
- Timestamp:
- Jun 8, 2016, 6:48:24 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r149 r150 87 87 Readonly my %SWITCH_KIND => ( 88 88 # HP 89 J3299A => { model => 'HP224M',match => 'HP J3299A ProCurve Switch 224M' },90 J4120A => { model => 'HP1600M',match => 'HP J4120A ProCurve Switch 1600M' },91 J9029A => { model => 'HP1800-8G',match => 'PROCURVE J9029A' },92 J9449A => { model => 'HP1810-8G',match => 'HP ProCurve 1810G - 8 GE' },93 J4093A => { model => 'HP2424M',match => 'HP J4093A ProCurve Switch 2424M' },94 J9279A => { model => 'HP2510G-24',match => 'ProCurve J9279A Switch 2510G-24' },95 J9280A => { model => 'HP2510G-48',match => 'ProCurve J9280A Switch 2510G-48' },96 J4813A => { model => 'HP2524',match => 'HP J4813A ProCurve Switch 2524' },97 J4900A => { model => 'HP2626A',match => 'HP J4900A ProCurve Switch 2626' },98 J4900B => { model => 'HP2626B',match => 'J4900B.+?Switch 2626' },# ProCurve J4900B Switch 2626 # HP J4900B ProCurve Switch 262699 J4899B => { model => 'HP2650',match => 'ProCurve J4899B Switch 2650' },100 J9021A => { model => 'HP2810-24G',match => 'ProCurve J9021A Switch 2810-24G' },101 J9022A => { model => 'HP2810-48G',match => 'ProCurve J9022A Switch 2810-48G' },102 J8692A => { model => 'HP3500-24G',match => 'J8692A Switch 3500yl-24G' },103 J4903A => { model => 'HP2824',match => 'J4903A.+?Switch 2824,' },104 J4110A => { model => 'HP8000M',match => 'HP J4110A ProCurve Switch 8000M' },105 JE074A => { model => 'HP5120-24G',match => 'HP Comware.+?A5120-24G EI' },106 JD374A => { model => 'HP5500-24F',match => 'HP Comware.+?A5500-24G-SFP EI' },89 J3299A => { type => 1, model => 'HP224M', match => 'HP J3299A ProCurve Switch 224M' }, 90 J4120A => { type => 1, model => 'HP1600M', match => 'HP J4120A ProCurve Switch 1600M' }, 91 J9029A => { type => 1, model => 'HP1800-8G', match => 'PROCURVE J9029A' }, 92 J9449A => { type => 1, model => 'HP1810-8G', match => 'HP ProCurve 1810G - 8 GE' }, 93 J4093A => { type => 1, model => 'HP2424M', match => 'HP J4093A ProCurve Switch 2424M' }, 94 J9279A => { type => 1, model => 'HP2510G-24', match => 'ProCurve J9279A Switch 2510G-24' }, 95 J9280A => { type => 1, model => 'HP2510G-48', match => 'ProCurve J9280A Switch 2510G-48' }, 96 J4813A => { type => 1, model => 'HP2524', match => 'HP J4813A ProCurve Switch 2524' }, 97 J4900A => { type => 1, model => 'HP2626A', match => 'HP J4900A ProCurve Switch 2626' }, 98 J4900B => { type => 1, model => 'HP2626B', match => 'J4900B.+?Switch 2626' },# ProCurve J4900B Switch 2626 # HP J4900B ProCurve Switch 2626 99 J4899B => { type => 1, model => 'HP2650', match => 'ProCurve J4899B Switch 2650' }, 100 J9021A => { type => 1, model => 'HP2810-24G', match => 'ProCurve J9021A Switch 2810-24G' }, 101 J9022A => { type => 1, model => 'HP2810-48G', match => 'ProCurve J9022A Switch 2810-48G' }, 102 J8692A => { type => 1, model => 'HP3500-24G', match => 'J8692A Switch 3500yl-24G' }, 103 J4903A => { type => 1, model => 'HP2824', match => 'J4903A.+?Switch 2824,' }, 104 J4110A => { type => 1, model => 'HP8000M', match => 'HP J4110A ProCurve Switch 8000M' }, 105 JE074A => { type => 2, model => 'HP5120-24G', match => 'HP Comware.+?A5120-24G EI' }, 106 JD374A => { type => 2, model => 'HP5500-24F', match => 'HP Comware.+?A5500-24G-SFP EI' }, 107 107 # BayStack 108 BS350T => { model => 'BS350T',match => 'BayStack 350T HW' },108 BS350T => { type => 1, model => 'BS350T', match => 'BayStack 350T HW' }, 109 109 # Nexans 110 N3483G => { model => 'NA3483-6G',match => 'GigaSwitch V3 TP SFP-I 48V ES3' },110 N3483G => { type => 2, model => 'NA3483-6G', match => 'GigaSwitch V3 TP SFP-I 48V ES3' }, 111 111 # DELL 112 N2048 => { model => 'DN2048',match => 'Dell Networking N2048,' },113 N4064F => { model => 'DN4064F',match => 'Dell Networking N4064F,' },112 N2048 => { type => 2, model => 'DN2048', match => 'Dell Networking N2048,' }, 113 N4064F => { type => 2, model => 'DN4064F', match => 'Dell Networking N4064F,' }, 114 114 # 3COM 115 'H3C5500' => { model => 'H3C5500', match => 'H3C S5500-SI Series' },116 '3C17203' => { model => '3C17203', match => '3Com SuperStack 3 24-Port' },117 '3C17204' => { model => '3C17204', match => '3Com SuperStack 3 48-Port' },118 '3CR17562-91' => { model => '3CR17562-91', match => '3Com Switch 4500 50-Port' },119 '3CR17255-91' => { model => '3CR17255-91', match => '3Com Switch 5500G-EI 48-Port' },120 '3CR17251-91' => { model => '3CR17251-91', match => '3Com Switch 5500G-EI 48-Port' },121 '3CR17571-91' => { model => '3CR17571-91', match => '3Com Switch 4500 PWR 26-Port' },122 '3CRWX220095A' => { model => '3CRWX220095A', match => '3Com Wireless LAN Controller' },123 '3CR17254-91' => { model => '3CR17254-91', match => '3Com Switch 5500G-EI 24-Port' },124 '3CRS48G-24S-91' => { model => '3CRS48G-24S-91', match => '3Com Switch 4800G 24-Port' },125 '3CRS48G-48S-91' => { model => '3CRS48G-48S-91', match => '3Com Switch 4800G 48-Port' },126 '3C17708' => { model => '3C17708', match => '3Com Switch 4050' },127 '3C17709' => { model => '3C17709', match => '3Com Switch 4060' },128 '3C17707' => { model => '3C17707', match => '3Com Switch 4070' },129 '3CR17258-91' => { model => '3CR17258-91', match => '3Com Switch 5500G-EI 24-Port SFP' },130 '3CR17181-91' => { model => '3CR17181-91', match => '3Com Switch 5500-EI 28-Port FX' },131 '3CR17252-91' => { model => '3CR17252-91', match => '3Com Switch 5500G-EI PWR 24-Port' },132 '3CR17253-91' => { model => '3CR17253-91', match => '3Com Switch 5500G-EI PWR 48-Port' },133 '3CR17250-91' => { model => '3CR17250-91', match => '3Com Switch 5500G-EI 24-Port' },134 '3CR17561-91' => { model => '3CR17561-91', match => '3Com Switch 4500 26-Port' },135 '3CR17572-91' => { model => '3CR17572-91', match => '3Com Switch 4500 PWR 50-Port' },136 '3C17702-US' => { model => '3C17702-US', match => '3Com Switch 4900 SX' },137 '3C17700' => { model => '3C17700', match => '3Com Switch 4900' },115 'H3C5500' => { type => 1, model => 'H3C5500', match => 'H3C S5500-SI Series' }, 116 '3C17203' => { type => 1, model => '3C17203', match => '3Com SuperStack 3 24-Port' }, 117 '3C17204' => { type => 1, model => '3C17204', match => '3Com SuperStack 3 48-Port' }, 118 '3CR17562-91' => { type => 1, model => '3CR17562-91', match => '3Com Switch 4500 50-Port' }, 119 '3CR17255-91' => { type => 1, model => '3CR17255-91', match => '3Com Switch 5500G-EI 48-Port' }, 120 '3CR17251-91' => { type => 1, model => '3CR17251-91', match => '3Com Switch 5500G-EI 48-Port' }, 121 '3CR17571-91' => { type => 1, model => '3CR17571-91', match => '3Com Switch 4500 PWR 26-Port' }, 122 '3CRWX220095A' => { type => 1, model => '3CRWX220095A', match => '3Com Wireless LAN Controller' }, 123 '3CR17254-91' => { type => 1, model => '3CR17254-91', match => '3Com Switch 5500G-EI 24-Port' }, 124 '3CRS48G-24S-91' => { type => 1, model => '3CRS48G-24S-91', match => '3Com Switch 4800G 24-Port' }, 125 '3CRS48G-48S-91' => { type => 1, model => '3CRS48G-48S-91', match => '3Com Switch 4800G 48-Port' }, 126 '3C17708' => { type => 1, model => '3C17708', match => '3Com Switch 4050' }, 127 '3C17709' => { type => 1, model => '3C17709', match => '3Com Switch 4060' }, 128 '3C17707' => { type => 1, model => '3C17707', match => '3Com Switch 4070' }, 129 '3CR17258-91' => { type => 1, model => '3CR17258-91', match => '3Com Switch 5500G-EI 24-Port SFP' }, 130 '3CR17181-91' => { type => 1, model => '3CR17181-91', match => '3Com Switch 5500-EI 28-Port FX' }, 131 '3CR17252-91' => { type => 1, model => '3CR17252-91', match => '3Com Switch 5500G-EI PWR 24-Port' }, 132 '3CR17253-91' => { type => 1, model => '3CR17253-91', match => '3Com Switch 5500G-EI PWR 48-Port' }, 133 '3CR17250-91' => { type => 1, model => '3CR17250-91', match => '3Com Switch 5500G-EI 24-Port' }, 134 '3CR17561-91' => { type => 1, model => '3CR17561-91', match => '3Com Switch 4500 26-Port' }, 135 '3CR17572-91' => { type => 1, model => '3CR17572-91', match => '3Com Switch 4500 PWR 50-Port' }, 136 '3C17702-US' => { type => 1, model => '3C17702-US', match => '3Com Switch 4900 SX' }, 137 '3C17700' => { type => 1, model => '3C17700', match => '3Com Switch 4900' }, 138 138 ); 139 139 … … 424 424 } 425 425 426 my $swport = $result->{$research1}; 427 $session->close; 428 429 # IMPORTANT !! 430 # ceci empeche la detection sur certains port ... 431 # en effet les switch sont relies entre eux par un cable reseau et du coup 432 # tous les arp de toutes les machines sont presentes sur ces ports (ceux choisis ici sont les miens) 433 # cette partie est a ameliore, voir a configurer dans l'entete 434 # 21->24 45->48 435 # my $flag = 0; 436 SWITCH_PORT_IGNORE: 437 foreach my $p (@{$sw->{portignore}}) { 438 next SWITCH_PORT_IGNORE if $swport ne get_numerical_port($sw->{model},$p); 439 # $flag = 1; 440 next LOOP_ON_SWITCH; 441 } 442 # if ($flag == 0) { 443 $ret{switch_hostname} = $sw->{hostname}; 444 $ret{switch_description} = $sw->{description}; 445 $ret{switch_port} = get_human_readable_port($sw->{model}, $swport); # $swport; 446 447 last LOOP_ON_SWITCH; 448 # } 449 # } 450 # $session->close; 426 my $swport = $result->{$research1}; 427 428 my $research_hr = $OID_NUMBER{ifName} . $swport; 429 $result = $session->get_request( 430 -varbindlist => [$research_hr] 431 ); 432 my $swport_hr = $swport; 433 $swport_hr = get_port_human_readable_short($result->{$research_hr}) if defined $result; 434 435 $session->close; 436 437 # IMPORTANT !! 438 # ceci empeche la detection sur certains port ... 439 # en effet les switch sont relies entre eux par un cable reseau et du coup 440 # tous les arp de toutes les machines sont presentes sur ces ports (ceux choisis ici sont les miens) 441 # cette partie est a ameliore, voir a configurer dans l'entete 442 # 21->24 45->48 443 SWITCH_PORT_IGNORE: 444 foreach my $p (@{$sw->{portignore}}) { 445 next SWITCH_PORT_IGNORE if $swport ne get_numerical_port($sw->{model},$p); 446 next LOOP_ON_SWITCH; 447 } 448 449 $ret{switch_hostname} = $sw->{hostname}; 450 $ret{switch_description} = $sw->{description}; 451 $ret{switch_port} = get_human_readable_port($sw->{model}, $swport); # $swport; 452 $ret{switch_port_hr} = $swport_hr; # human readable 453 454 last LOOP_ON_SWITCH; 451 455 } 452 456 return %ret; … … 668 672 } 669 673 674 sub get_port_human_readable_short { 675 my $sw_port_hr = shift; 676 677 $sw_port_hr =~ s/Ten-GigabitEthernet/Te/; 678 $sw_port_hr =~ s/GigabitEthernet/Gi/; 679 680 return $sw_port_hr; 681 } 682 683 sub computerdb_load { 684 my $computerdb = YAML::Syck::LoadFile("$KLASK_DB_FILE"); 685 686 return $computerdb; 687 } 688 670 689 ################ 671 690 # Les commandes … … 732 751 printf '%-22s %2s %-30s %-15s %18s', 733 752 $where{switch_hostname}, 734 $where{switch_port },753 $where{switch_port_hr}, 735 754 $resol_arp{hostname_fq}, 736 755 $resol_arp{ipv4_address}, … … 781 800 printf "%-22s %2s %-30s %-15s %-18s %s\n", 782 801 $computerdb->{$ip}{switch_hostname}, 783 $computerdb->{$ip}{switch_port },802 $computerdb->{$ip}{switch_port_hr}, 784 803 $computerdb->{$ip}{hostname_fq}, 785 804 $ip, … … 808 827 printf "%-22s %2s %-30s %-15s %-18s %s\n", 809 828 $computerdb->{$ip}{switch_hostname}, 810 $computerdb->{$ip}{switch_port },829 $computerdb->{$ip}{switch_port_hr}, 811 830 $computerdb->{$ip}{hostname_fq}, 812 831 $ip, … … 945 964 switch_description => $where{switch_description}, 946 965 switch_port => $where{switch_port}, 966 switch_port_hr => $where{switch_port_hr}, 947 967 timestamp => $timestamp, 948 968 network => $net, … … 960 980 switch_description => $where{switch_description}, 961 981 switch_port => $where{switch_port}, 982 switch_port_hr => $where{switch_port_hr}, 962 983 timestamp => $resol_arp{timestamp}, 963 984 network => $net, … … 1165 1186 printf "%-28s %2s <------- %-40s %-15s %-18s %-16s %s\n", 1166 1187 $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}, 1167 $computerdb->{$ip}{switch_port },1188 $computerdb->{$ip}{switch_port_hr}, 1168 1189 $computerdb->{$ip}{hostname_fq}, 1169 1190 $ip, … … 1242 1263 my $switch_hostname = $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description} || 'unkown'; 1243 1264 chomp $switch_hostname; 1244 my $switch_hostname_sort = sprintf '%s %3s' ,$switch_hostname, $computerdb->{$ip}{switch_port };1265 my $switch_hostname_sort = sprintf '%s %3s' ,$switch_hostname, $computerdb->{$ip}{switch_port_hr}; 1245 1266 1246 1267 my $ip_sort = sprintf '%03i%03i%03i%03i', split m/ \. /xms, $ip; … … 1256 1277 <tr class="$typerow"> 1257 1278 <td sorttable_customkey="$switch_hostname_sort">$switch_hostname</td> 1258 <td class="bklask-port">$computerdb->{$ip}{switch_port }</td>1279 <td class="bklask-port">$computerdb->{$ip}{switch_port_hr}</td> 1259 1280 <td><-------</td> 1260 1281 <td sorttable_customkey="$host_short">$computerdb->{$ip}{hostname_fq}</td> … … 1408 1429 my $swpt = sprintf "%-28s %2s", 1409 1430 $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}, 1410 $computerdb->{$ip}{switch_port };1431 $computerdb->{$ip}{switch_port_hr}; 1411 1432 $swithportdb{$swpt} ||= { 1412 1433 ip => $ip,
Note: See TracChangeset
for help on using the changeset viewer.