Changeset 121


Ignore:
Timestamp:
Apr 21, 2013, 10:05:56 AM (12 years ago)
Author:
g7moreau
Message:
  • Search on two OID
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r119 r121  
    9797   J4903A => { model => 'HP2824',     match => 'J4903A.+?Switch 2824,'           },
    9898   J4110A => { model => 'HP8000M',    match => 'HP J4110A ProCurve Switch 8000M' },
    99    JD374A => { model => 'HP5500-24F', match => 'HP Comware.+?A5500-24G-SFP EI'   },
     99   JD374A => { model => 'HP5500-24F', match => 'HP Comware.+?A5500-24G-SFP EI',    mibflag => 2  },
    100100   BS350T => { model => 'BS350T',     match => 'BayStack 350T HW'                },
    101101   N3483G => { model => 'NA3483-6G',  match => 'GigaSwitch V3 TP SFP-I 48V ES3'  },
     
    107107   sysContact      => '1.3.6.1.2.1.1.4.0',
    108108   sysLocation     => '1.3.6.1.2.1.1.6.0',
    109    searchPort      => '1.3.6.1.2.1.17.4.3.1.2',
     109   searchPort1     => '1.3.6.1.2.1.17.4.3.1.2',
     110   searchPort2     => '1.3.6.1.2.1.17.7.1.2.2.1.2.1',
    110111   );
    111112
     
    338339      }
    339340
    340    my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address);
     341   my $research1 = $OID_NUMBER{searchPort1} . mac_address_hex_to_dec($mac_address);
     342   my $research2 = $OID_NUMBER{searchPort2} . mac_address_hex_to_dec($mac_address);
    341343
    342344   LOOP_ON_SWITCH:
     
    346348
    347349      my $result = $session->get_request(
    348          -varbindlist => [$research]
     350         -varbindlist => [$research1, $research2]
    349351         );
    350       if (not defined $result or $result->{$research} eq 'noSuchInstance') {
     352      if (not defined $result or $result->{$research1} eq 'noSuchInstance' or $result->{$research2} eq 'noSuchInstance') {
    351353         $session->close;
    352354         next LOOP_ON_SWITCH;
    353355         }
    354356
    355          my $swport = $result->{$research};
     357         my $swport = $result->{$research1};
     358         $swport = $result->{$research2} if $result->{$research1} eq 'noSuchInstance';
    356359         $session->close;
    357360
     
    398401#      }
    399402
    400    my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address);
     403   my $research1 = $OID_NUMBER{searchPort1} . mac_address_hex_to_dec($mac_address);
     404   my $research2 = $OID_NUMBER{searchPort2} . mac_address_hex_to_dec($mac_address);
    401405   LOOP_ON_ALL_SWITCH:
    402406   for my $sw (@SWITCH) {
     
    405409
    406410      my $result = $session->get_request(
    407          -varbindlist => [$research]
     411         -varbindlist => [$research1, $research2]
    408412         );
    409413
    410       if(defined $result and $result->{$research} ne 'noSuchInstance'){
    411          my $swport = $result->{$research};
     414      if(defined $result and ($result->{$research1} ne 'noSuchInstance' or $result->{$research2} ne 'noSuchInstance')){
     415         my $swport = $result->{$research1};
     416         $swport = $result->{$research2} if $result->{$research1} eq 'noSuchInstance';
    412417
    413418         $ret->{$sw->{hostname}} = {};
     
    15101515         }
    15111516
    1512       my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address);
    1513       print "Klask search OID $research on switch $sw_name\n";
     1517      my $research1 = $OID_NUMBER{searchPort1} . mac_address_hex_to_dec($mac_address);
     1518      my $research2 = $OID_NUMBER{searchPort2} . mac_address_hex_to_dec($mac_address);
     1519      print "Klask search OID $research1 on switch $sw_name\n";
    15141520
    15151521      my ($session, $error) = Net::SNMP->session( %session );
     
    15171523
    15181524      my $result = $session->get_request(
    1519          -varbindlist => [$research]
     1525         -varbindlist => [$research1, $research2]
    15201526         );
    15211527
    1522       if (not defined $result or $result->{$research} eq 'noSuchInstance') {
     1528      if (not defined $result or $result->{$research1} eq 'noSuchInstance' or $result->{$research2} eq 'noSuchInstance') {
    15231529         print "Klask do not find MAC $mac_address on switch $sw_name\n";
    15241530         $session->close;
    15251531         }
    15261532
    1527       my $swport = $result->{$research};
     1533      my $swport = $result->{$research1};
     1534      $swport = $result->{$research2} if $result->{$research1} eq 'noSuchInstance';
    15281535      $session->close;
    15291536
Note: See TracChangeset for help on using the changeset viewer.