A class for performing SNMP V2 queries on Cisco devices

copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
author Barry O'Donovan

 Methods

Recursivily crawls all CDP neighbours to build up a flat array of all devices indexed by the CDP device id.

crawl(array $devices, string $device, array $ignore) : array

Array form is same as that returned by neighbours()

see \neighbours()

Parameters

$devices

array

Unless you're doing something funky, just pass an empty array. This is where the result will be found.

$device

string

CDP device ID of next host to crawl. On first pass, set to null - used internally when recursing

$ignore

array

An array of CDP device IDs to ignore. I.e. to not include in recursive crawling

Returns

arrayThe resultant array of all crawled devices (same as that passed in the @param $devices parameter)

Get the device's CDP (Cisco Discovery Protocol) ID

id() : string

Returns

stringThe device's CDP (Cisco Discovery Protocol) ID

Get the device's interfaces CDP enabled status

interfaceEnabled() : array

Applies the TruthValue post processor (self::ppTruthValue()) to turn SNMP values into true / false.

Returns

arrayThe device's interfaces CDP enabled status' (as boolean true / false)

Get the device's interface names as seen in CDP

interfaceNames() : array

Returns

arrayThe device's interface names as seen in CDP

Find the layer 2 topology as an array with no link mentioned more than once.

linkTopology(array $devices) : array

Huh? This function:

  • takes the result of crawl() (or calls crawl()) to get the CDP topology
  • foreach device, builds an array of device to device links
  • SO LONG as that link has already not been accounted for in the other direction.

I.e. if a link is found A -> B, then the same B -> A link will not be included

The array returned is, for example:

[cr-sw04.degkcp.example.ie] => Array ( [cd-sw02.degkcp.example.ie] => Array ( [GigabitEthernet1/0/3] => Array ( [remotePort] => FastEthernet0/1 [isLAG] => false )

 [cr-sw03.degkcp.example.ie] => Array
 (
     [GigabitEthernet1/0/23] => Array
     (
         [remotePort] => GigabitEthernet1/0/23
         [isLAG]      => false
     )
     [GigabitEthernet1/0/24] => Array
     (
         [remotePort] => GigabitEthernet1/0/24
         [isLAG]      => false
     )
 )

)

This tells us that cr-sw04(GigabitEthernet1/0/3) is connected to cd-sw02(FastEthernet0/1).

It also tells us that cr-sw04 has two connections to cr-sw03.

You'll notice it also tells us if it's a LAG or not. More information can be added as needed.

see \crawl()

Parameters

$devices

array

The result of crawl() (if null, this function performs a crawl())

Returns

arrayL2 topology as described above.

Get the device's CDP neighbour capabilities (as a decimal integer) indexed by the current device's port ID

neighbourCapability() : array

Returns

arrayThe device's CDP neighbour capabilities (as a decimal integer) indexed by the current device's port ID

Get the device's CDP neighbours (by their CDP ID) indexed by the current device's port ID

neighbourId() : array

Returns

arrayThe device's CDP neighbours (by their CDP ID) indexed by the current device's port ID

Get the device's CDP neighbours connected port *description* indexed by the current device's port ID

neighbourPort() : array

E.g. a sample call may return:

Array ( [10101] => GigabitEthernet0/1 [10102] => FastEthernet0/2 [10103] => GigabitEthernet1/0/24 [10105] => GigabitEthernet1/0/2 )

meaning, for example, that our local port with ID 10101 is connected to port GigabitEthernet0/1 on the neighbour connected to that local port. You can discover the neighbour ID via neighbourId().

see \neighbourId()

Returns

arrayThe device's CDP neighbours connected port *description* indexed by the current device's port ID

CDP utility function to get all CDP neighbours and their connected ports.

neighbours() : array

Returns an array of neighbours indexed by the neighbour CDP ID. For example:

Array ( [cr-sw03.ixdub1.opensolutions.ie] => Array ( [0] => Array ( [localPortId] => 10101 [localPort] => GigabitEthernet1/0/1 [remotePort] => GigabitEthernet0/1 )

        [1] => Array
            (
                [localPortId] => 10102
                [localPort] => GigabitEthernet1/0/2
                [remotePort] => FastEthernet0/2
            )

    )
[ ... ]

)

see \neighbourId()
see \OSS\SNMP\MIBS\Interface::descriptions()
see \neighbourPort()

Returns

arrayCDP neighbours and their connected ports

 Constants

 

OID_CDP_DEVICE_ID

OID_CDP_DEVICE_ID 

 

OID_CDP_INTERFACE_ENABLED

OID_CDP_INTERFACE_ENABLED 

 

OID_CDP_INTERFACE_NAME

OID_CDP_INTERFACE_NAME 

 

OID_CDP_NEIGHBOUR_CAPABILITY

OID_CDP_NEIGHBOUR_CAPABILITY 

 

OID_CDP_NEIGHBOUR_ID

OID_CDP_NEIGHBOUR_ID 

 

OID_CDP_NEIGHBOUR_PORT

OID_CDP_NEIGHBOUR_PORT