NAME

App::Netdisco::SSHCollector::Platform::NXOS

DESCRIPTION

Collect ARP, MAC table, and connected subnet data from Cisco NXOS devices.

PUBLIC METHODS

arpnip($host, $ssh)

Retrieve ARP entries from device. $host is the hostname or IP address of the device. $ssh is a Net::OpenSSH connection to the device.

Returns a list of hashrefs in the format { mac => MACADDR, ip => IPADDR }. Entries from all VRFs are flattened into a single returned list. Example: [ { ip => '192.0.2.10', mac => '0011.2233.4455' }, { ip => '2001:db8::1', mac => 'aabb.ccdd.eeff' } ].

arpnip_by_vrf($host, $ssh, $args)

As arpnip, used when store_vrfs is on. Reads show vrf | json, then sends the show ip arp vrf NAME | json and show ipv6 neighbor vrf NAME | json commands of the listed VRFs chained with ;, at most 16 commands and 640 bytes per exec request, and names each entry's VRF from the list (default is ''). Each reply document is assigned by its own VRF name and table shape, not its position. A VRF's family is read whole only when exactly one document for it decodes and holds as many rows as its own count (cnt-total for ARP, count for IPv6); a request that fails, or a document that does not decode, leaves the VRF and families after it unread. VRF names that differ only in case are all 0 and never queried, and make vrf_list_complete 0. Rows without a MAC (INCOMPLETE) are skipped but count as rows. Link-local neighbors are kept.

Returns { entries => [ { ip, mac, vrf } ], vrf_read => { VRF => 0|1 }, vrf_list_complete => 0|1, families => [4, 6] }, or undef when show vrf | json fails or lists no VRF. A list row with no usable name, or a list without default, makes vrf_list_complete 0; the global table is read either way. A VRF named all is 0 and is never queried. A VRF is 1 only when both families were read whole.

A subclass that overrides arpnip must also override arpnip_by_vrf, or with store_vrfs on this arpnip_by_vrf is used instead of the override.

macsuck($host, $ssh)

Retrieve MAC address table entries from device. $host is the hostname or IP address of the device. $ssh is a Net::OpenSSH connection to the device.

Returns a hashref keyed by VLAN and interface, where leaf keys are MAC addresses, in the format { VLAN => { PORT => { MACADDR => COUNT } } }. Example: { 10 => { 'Ethernet1/1' => { '00:11:22:33:44:55' => 1 } }, 20 => { 'port-channel12' => { 'aa:bb:cc:dd:ee:ff' => 2 } } }.

subnets($host, $ssh)

Retrieve directly connected IPv4 subnets from device routing tables. $host is the hostname or IP address of the device. $ssh is a Net::OpenSSH connection to the device.

Returns a list of IPv4 CIDR strings in the format X.X.X.X/NN. Example: [ '10.1.1.0/24', '192.0.2.0/25' ].

subnets_by_vrf($host, $ssh, $args)

As subnets, used when store_vrfs is on, and reading IPv6 as well. Sends show ip route direct vrf all | json and show ipv6 route direct vrf all | json, each as one exec request (no pty), and names each prefix's VRF from vrf-name-out (the worker maps default to ''). direct lists only connected and local-direct routes, so no default or learned route is returned, but host routes (/32, /128) are: the worker filters them. VRF names, such as egress-loadbalance-resolution-, are passed through as the device prints them. Where NX-OS prints a hash for a one-row table, it is read as a list of one.

Returns { VRF => [ { prefix => '10.1.1.0', len => 24 }, ... ] }, or undef when neither command returned usable JSON. A VRF with no connected routes is absent. A command that fails contributes nothing and the other family's prefixes are still returned. A failure is an SSH error (including a non-zero exit, which a Syntax error reply gives), a reply that does not decode, or a reply that is not the expected table. Some images leave the exec channel open after a complete reply; that costs the SSH inactivity timeout and that family.

A subclass that overrides subnets must also override subnets_by_vrf, or with store_vrfs on this subnets_by_vrf is used instead of the override.