Changeset 216


Ignore:
Timestamp:
Feb 18, 2017, 2:36:44 PM (8 years ago)
Author:
g7moreau
Message:
  • status enable and disable manage human readable port (need more real test)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r215 r216  
    20612061      }
    20622062
    2063    my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port;
    2064    print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;
    2065 
    20662063   my $sw = $SWITCH_DB{$switch_name};
    20672064   my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} );
    20682065   print "$error \n" if $error;
    20692066
     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
    20702074   my $result = $session->set_request(
    20712075      -varbindlist => [$search_portstatus, INTEGER, 1],
    20722076      );
     2077   print $session->error()."\n" if $session->error_status();
    20732078
    20742079   $session->close;
     
    21002105      }
    21012106
    2102    my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port;
    2103    print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;
    2104 
    21052107   my $sw = $SWITCH_DB{$switch_name};
    21062108   my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} );
    21072109   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;
    21082117
    21092118   my $result = $session->set_request(
     
    21442153   # Retrieve numeric port value
    21452154   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+$/;
    21472156
    21482157   my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_num;
     
    21522161      -varbindlist => [$search_portstatus]
    21532162      );
     2163   print $session->error()."\n" if $session->error_status();
    21542164   if (defined $result) {
    21552165      print "$PORT_UPDOWN{$result->{$search_portstatus}}\n";
    21562166      }
     2167
     2168   $session->close;
    21572169
    21582170   #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.