-1

I am trying to verify that an AP can be found on my wireless controller via PHP. I need to be able to pass in the AP name and match it to the list found. Should be simple enough, but I haven't messed with SNMP for a tick.

I know the OID is correct for the name. I used the Cisco OID View page here: http://www.oidview.com/mibs/9/CISCO-LWAPP-AP-MIB.html

Which gave me the tree view:

Object Name                                          Object Identifier
ciscoLwappApMIB ciscoLwappApMIB               (base) 1.3.6.1.4.1.9.9.513
ciscoLwappApMIBNotifs ciscoLwappApMIBNotifs          (base).0
ciscoLwappApMIBObjects ciscoLwappApMIBObjects        (base).1
ciscoLwappAp ciscoLwappAp                            (base).1.1
cLApTable cLApTable                                  (base).1.1.1
cLApEntry cLApEntry                                  (base).1.1.1.1
cLApSysMacAddress cLApSysMacAddress                  (base).1.1.1.1.1
cLApIfMacAddress cLApIfMacAddress                    (base).1.1.1.1.2
cLApMaxNumberOfDot11Slots cLApMaxNumberOfDot11Slots  (base).1.1.1.1.3
cLApEntPhysicalIndex cLApEntPhysicalIndex            (base).1.1.1.1.4
cLApName cLApName                                    (base).1.1.1.1.5

So if I print_r($test); I get the following list:

Array
(
    [0] => STRING: "My-AP-Name-1"
    [1] => STRING: "My-AP-Name-2"
    [2] => STRING: "My-AP-Name-3"
    [3] => STRING: "My-AP-Name-4"
    [4] => STRING: "My-AP-Name-5"
    ...

I would like to keep things as simple as possible. Something like this:

    $ap = "My-AP-Name";

    $test = snmp2_walk($host, $community_string, "1.3.6.1.4.1.9.9.513.1.1.1.1.5");

    if ( in_array( $ap, $test ) ) {
        echo "We found $ap";
    } else {
        echo "Sorry, but it looks like $ap cannot be located.";
    }

Is there not a way to just return the list of names via SNMP?

W3bGuy
  • 735
  • 7
  • 20

1 Answers1

0

So I was able to achieve what I was after by simply doing a strpos check on each item in the array. However, I would like to find a more efficient way to do this in case there are more APs in the future.

Current working:

foreach ( $test as $key => $name) {
    if ( strpos( $name, $ap ) !== FALSE ) {
        echo "We found $ap";
        return true;
    }
}
W3bGuy
  • 735
  • 7
  • 20