Changeset 216
- Timestamp:
- Feb 18, 2017, 2:36:44 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r215 r216 2061 2061 } 2062 2062 2063 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port;2064 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;2065 2066 2063 my $sw = $SWITCH_DB{$switch_name}; 2067 2064 my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} ); 2068 2065 print "$error \n" if $error; 2069 2066 2067 # Retrieve numeric port value 2068 my $port_num = snmp_get_switchport_num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2069 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2070 2071 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_num; 2072 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose; 2073 2070 2074 my $result = $session->set_request( 2071 2075 -varbindlist => [$search_portstatus, INTEGER, 1], 2072 2076 ); 2077 print $session->error()."\n" if $session->error_status(); 2073 2078 2074 2079 $session->close; … … 2100 2105 } 2101 2106 2102 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port;2103 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;2104 2105 2107 my $sw = $SWITCH_DB{$switch_name}; 2106 2108 my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} ); 2107 2109 print "$error \n" if $error; 2110 2111 # Retrieve numeric port value 2112 my $port_num = snmp_get_switchport_num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2113 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2114 2115 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_num; 2116 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose; 2108 2117 2109 2118 my $result = $session->set_request( … … 2144 2153 # Retrieve numeric port value 2145 2154 my $port_num = snmp_get_switchport_num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2146 die "Error : Port $port not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/;2155 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2147 2156 2148 2157 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_num; … … 2152 2161 -varbindlist => [$search_portstatus] 2153 2162 ); 2163 print $session->error()."\n" if $session->error_status(); 2154 2164 if (defined $result) { 2155 2165 print "$PORT_UPDOWN{$result->{$search_portstatus}}\n"; 2156 2166 } 2167 2168 $session->close; 2157 2169 2158 2170 #system "snmpget -v 1 -c public $switch_name 1.3.6.1.2.1.2.2.1.7.$port";
Note: See TracChangeset
for help on using the changeset viewer.