mac address of the device attached to the switch - SNMP

This is a discussion on mac address of the device attached to the switch - SNMP ; Hello all, I tried to write perl script to retrive MAC address of the devices connected to the switch. But.. it doesn't work. I went through groups.google.com, I've found some tricks, but they don't work here... My switch is HP ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: mac address of the device attached to the switch

  1. mac address of the device attached to the switch

    Hello all,

    I tried to write perl script to retrive MAC address of the devices
    connected to the switch.
    But.. it doesn't work. I went through groups.google.com, I've found
    some tricks, but they don't work here...
    My switch is HP Procurve 2524.

    This could be answer for my questions
    http://groups.google.pl/group/comp.p...5369ca8d26301f
    but it doesn't work - perl says nosuchname for this number
    1.3.6.1.2.1.17.4.3.1.0 which is Dot1dTpFdbEntry
    Also, it is "not-accessible" in rfc 1286 so.. I don't really understand..
    I went through all HP enterprise mib tree, and I didn't find anything I
    could
    use (or it didn't work for this device).
    Am I doing something wrong?

    Could you help?

    regards,

    Mariusz Preiss


  2. Re: mac address of the device attached to the switch

    Użytkownik "Sierp" napisał w wiadomości
    news:ce23e$434d6a76$3eb317d9$12403@news.chello.pl. ..
    > I tried to write perl script to retrive MAC address of the devices
    > connected to the switch.
    > But.. it doesn't work. I went through groups.google.com, I've found
    > some tricks, but they don't work here...
    > My switch is HP Procurve 2524.


    problem solved
    for google guys, the answer script in perl

    my $TpFdbTable = '1.3.6.1.2.1.17.4.3.1.1';
    $response = $session->get_table(-baseoid => $TpFdbTable);

    if (!defined($response)) {
    printf("ERROR: %s.\n", $session->error);
    $session->close;
    exit 1;
    }

    foreach $TpFdbTable(keys %$response) {
    $_MacAdd=$response->{$TpFdbTable};
    push (@array,$_MacAdd);
    }

    @array = sort @array;
    $prev = "not equal to $array[0]";
    @result = grep($_ ne $prev && ($prev = $_, 1), @array);

    foreach (@result) {
    $_MacResult = "$_";

    $length = length($_MacResult);
    $MacLength=length($_MacResult);
    $MacLength=$MacLength-2;
    $_MacResult=substr($_MacResult,2,$MacLength);

    print "\U$_MacResult\E\n";
    }

    regards,

    Mariusz


+ Reply to Thread