Changeset 35 for trunk/klask


Ignore:
Timestamp:
Feb 12, 2008, 1:54:43 PM (16 years ago)
Author:
g7moreau
Message:
  • Add command search-mac-on-switch

klask search-mac-on-switch switch_name mac_address

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r34 r35  
    5656   dotsw      => \&cmd_exportsw_dot,
    5757   iplocation => \&cmd_iplocation,
     58   'search-mac-on-switch' => \&cmd_search_mac_on_switch,
    5859   );
    5960
     
    817818   }
    818819
     820sub cmd_search_mac_on_switch {
     821   my $switch_name = shift;
     822   my $mac_address = shift;
     823   
     824   my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($mac_address);
     825   print "Klask search OID $research on switch $switch_name\n";
     826
     827   my ($session, $error) = Net::SNMP->session( -hostname => $switch_name );
     828   print "$error \n" if $error;
     829
     830   my $result = $session->get_request(
     831      -varbindlist => [$research]
     832      );
     833   
     834   if (not defined($result) or $result->{$research} eq 'noSuchInstance') {
     835      print "Klask do not find MAC $mac_address on switch $switch_name\n";
     836      $session->close;
     837      }
     838
     839   my $swport = $result->{$research};
     840   $session->close;
     841
     842   print "Klask find MAC $mac_address on switch $switch_name port $swport\n";
     843   }
    819844
    820845sub cmd_updatesw {
Note: See TracChangeset for help on using the changeset viewer.