NAME

App::Netdisco::Util::SNMP

DESCRIPTION

Helper functions for SNMP::Info instances.

There are no default exports, however the :all tag will export all subroutines.

EXPORT_OK

get_communities( $device, $mode )

Takes the current device_auth setting and pushes onto the front of the list the last known good SNMP settings used for this mode (read or write).

snmp_comm_reindex( $snmp, $device, $vlan )

Takes an established SNMP::Info instance and makes a fresh connection using community indexing, with the given $vlan ID. Works for all SNMP versions.

Inherits the vtp_version from the previous SNMP::Info instance.

Passing VLAN "0" (zero) will reset the indexing to the basic v2 community or v3 empty context.

snmp_vrf_reindex( $snmp, $device, $vrf )

As snmp_comm_reindex, but for a VRF's SNMP context: on SNMPv3 the context is the VRF name as given, never the VLAN context prefix.

get_mibdirs

Return a list of directories in the `netdisco-mibs` folder.

decode_and_munge( $method, $data )

Takes some data from snmpwalk cache that has been Base64 encoded, decodes it and then munge to handle data format, before finally pretty render in JSON format.

sortable_oid( $oid, $seglen? )

Take an OID and return a version of it which is sortable using cmp operator. Works by zero-padding the numeric parts all to be length $seglen, which defaults to 6.

walk_mark( $snmp )

Returns the number of incomplete walks the SNMP::Info instance has recorded so far, for use with incomplete_walks. Returns 0 when the instance keeps no record.

incomplete_walks( $snmp, $mark )

Returns the incomplete walk outcomes recorded since walk_mark returned $mark, in order. Returns an empty list when the instance keeps no record.

incomplete_walk_message( $device, $what, @outcomes )

Returns a log message for $what on $device naming each incomplete walk outcome: its method, table, reason, rows read and walk method, with the repeaters and SNMP context when there are any. When an outcome is absent, the message says to check the MIBs the poller loads.

incomplete_walk_level( @outcomes )

Returns the App::Netdisco::Worker::Status a worker returns after keeping its stored rows for @outcomes: error when any outcome is absent, otherwise info. An absent walk means the poller's MIBs are broken, which must show on the job, while a cut-short walk leaves the job's status as it was before the guard. An error job queues no discover hooks, so a device first discovered while the MIBs are broken never sends its new_device hook.

This is not full broken-MIB detection. It sees only the walks a guarded worker names, and only while enable_incomplete_walk_protection is on. Leaves read behind a composite method, such as i_vlan_membership, go unseen, and there a broken install behaves as it did before the guard.

incomplete_walks_for( $device, $snmp, $mark, @methods )

Returns the incomplete walk outcomes that could have cut short a table a worker is about to write: those recorded since walk_mark returned $mark, then the latest walk_status of each named @methods when it is not complete, then the job's record of the early interfaces read when interfaces is among the @methods. Each outcome is returned once.

walk_status is read because a table walked by an earlier worker is cached, and reading it again records nothing, so the failure lies before $mark. It holds the latest outcome, so a method that failed and then succeeded on a re-walk is not returned. An absent reason counts as incomplete although SNMP::Info marks it complete, because it means the poller could not translate the object locally, such as a broken MIB checkout.

Returns an empty list when enable_incomplete_walk_protection is false, or when the instance keeps no walk record.