Changeset 217
- Timestamp:
- Feb 18, 2017, 2:56:02 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r216 r217 786 786 787 787 my $swport_num = $swport_hr; 788 return $swport_num if $swport_num =~ m/^\d+$/; # direct return if already numeric 788 return $swport_num if $swport_num =~ m/^\d+$/; # direct return if already numeric (next loop is expensive) 789 789 790 790 my $research_index = $OID_NUMBER{ifIndex}; # base OID 791 791 my @args = ( -varbindlist => [$research_index]); 792 LOOP_O ID_PORT:792 LOOP_ON_OID_PORT: 793 793 while ( defined $snmp_session->get_next_request(@args) ) { 794 794 my ($oid_current) = $snmp_session->var_bind_names; 795 last if not Net::SNMP::oid_base_match($research_index, $oid_current);795 last LOOP_ON_OID_PORT if not Net::SNMP::oid_base_match($research_index, $oid_current); 796 796 797 797 my $port_ifIndex = $snmp_session->var_bind_list->{$oid_current}; … … 799 799 printf "PORT1: %s => %s\n", $oid_current, $port_ifIndex if $verbose; 800 800 801 # prepare next loop 801 # prepare next loop item 802 802 @args = (-varbindlist => [$oid_current]); 803 803 804 804 my $oid_ifName = $OID_NUMBER{ifName} .'.'. $port_ifIndex; 805 805 my $result = $snmp_session->get_request(-varbindlist => [$oid_ifName]); 806 next LOOP_O ID_PORT if not defined $result;806 next LOOP_ON_OID_PORT if not defined $result; 807 807 808 808 my $current_port_hr = normalize_port_human_readable($result->{$oid_ifName}); … … 810 810 if ($current_port_hr eq $swport_hr) { 811 811 print "PORT3: $current_port_hr <-> $port_index\n" if $verbose; 812 $swport_num = $port_index; 813 last LOOP_OID_PORT; 812 813 # return port number ifIndex need by OID portUpDown 814 $swport_num = $port_ifIndex; # other possible value could be $port_index 815 last LOOP_ON_OID_PORT; 814 816 } 815 817 } 816 818 return $swport_num; 817 819 } 818 819 # $research_index = $OID_NUMBER{ifName}; # base OID820 # @args = ( -varbindlist => [$research_index]);821 # while ( defined $snmp_session->get_next_request(@args) ) {822 # my ($oid_current) = $snmp_session->var_bind_names;823 # last if not Net::SNMP::oid_base_match($research_index, $oid_current);824 # my $current_port_hr = normalize_port_human_readable($snmp_session->var_bind_list->{$oid_current});825 # printf "%s => %s\n", $oid_current, $current_port_hr; # if $verbose;826 # if ( $current_port_hr =~ m/$swport_hr/i ) {827 # print "FIND PORT $current_port_hr -- $swport_h\n";828 # last829 # }830 # @args = (-varbindlist => [$oid_current]);831 # }832 # return;833 834 # my $result_index = $snmp_session->get_bulk_request(835 # -maxrepetitions => 10,836 # -varbindlist => [$research_index]837 # );838 # my $swifindex = $swport;839 # $swifindex = $result_index->{$research_index} if defined $result_index;840 #841 # my $research_hr = $OID_NUMBER{ifName} .'.'. $swifindex;842 # my $result_hr = $snmp_session->get_request(843 # -varbindlist => [$research_hr]844 # );845 # my $swport_hr = $swport;846 # $swport_hr = normalize_port_human_readable($result_hr->{$research_hr}) if defined $result_hr;847 # return $swport_hr;848 # }849 820 850 821 # Load computer database
Note: See TracChangeset
for help on using the changeset viewer.