configuration
switchmap classes that manage various configurations.
ConfigPoller Objects
class ConfigPoller(ConfigAPIClient)
Class gathers all configuration information.
__init__
def __init__()
Intialize the class.
Arguments:
None
Returns:
None
hostnames
def hostnames()
Get hostnames.
Arguments:
None
Returns:
result- result
polling_interval
def polling_interval()
Get polling_interval.
Arguments:
None
Returns:
result- result
snmp_auth
def snmp_auth()
Get list of dicts of SNMP information in configuration file.
Arguments:
None
Returns:
snmp_data- List of SNMP objects.
username
def username()
Get username.
Arguments:
None
Returns:
result- result
zones
def zones()
Get list of dicts of polling zone information in configuration file.
Arguments:
None
Returns:
result- List of ZONE objects.
poll
Switchmap-NG poll modulre.
Updates the database with device SNMP data.
devices
def devices(multiprocessing=False)
Poll all devices for data using subprocesses and create YAML files.
Arguments:
multiprocessing- Run multiprocessing when True
Returns:
None
device
def device(poll, post=True)
Poll single device for data and create YAML files.
Arguments:
poll- _META objectpost- Post the data if True, else just print it.
Returns:
None
cli_device
def cli_device(hostname)
Poll single device for data and create YAML files.
Arguments:
hostname- Host to poll
Returns:
None
__init__
Define the switchmap.poller package.
Arguments:
None
Returns:
None
snmp
Switchmap-NG snmp package.
get_queries
def get_queries(layer)
Get mib queries which gather information related to a specific OSI layer.
Arguments:
layer- The layer of queries needed
Returns:
queries- List of queries tagged the given layer
snmp.iana_enterprise
Vendor queries.
Query Objects
class Query()
Class interacts with devices to get vendor information.
Arguments:
None
Returns:
None
Methods:
All methods rely on this document to determine vendors https://www.iana.org/assignments/ enterprise-numbers/enterprise-numbers
__init__
def __init__(enterprise=None, sysobjectid=None)
Instantiate the class.
Arguments:
enterprise- The enterprise number of the manufacturersysobjectid- The sysobjectid of the device
Returns:
None
enterprise
def enterprise()
Get enterprise number.
Arguments:
None
Returns:
self.enterprise_id- Enterprise number
is_cisco
def is_cisco()
Verify whether device is a Cisco device.
Arguments:
None
Returns:
value- True if matches vendor
is_juniper
def is_juniper()
Verify whether device is a Juniper device.
Arguments:
None
Returns:
value- True if matches vendor
snmp.mib.juniper.mib_junipervlan
Module for JUNIPER-VLAN-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
JuniperVlanQuery- Query class for JUNIPER-VLAN-MIB
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMPInteract object
Returns:
JuniperVlanQuery- Query class for JUNIPER-VLAN-MIB
JuniperVlanQuery Objects
class JuniperVlanQuery(Query)
Class interacts with JUNIPER-VLAN-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
layer2
def layer2()
Get layer 2 data from device.
Arguments:
None
Returns:
final- Final results
jnxexvlanportaccessmode
def jnxexvlanportaccessmode()
Return dict of JUNIPER-VLAN-MIB jnxExVlanPortAccessMode per port.
Arguments:
None
Returns:
data_dict- Dict of jnxExVlanPortAccessMode using ifIndex as key
jnxexvlantag
def jnxexvlantag()
Return dict of JUNIPER-VLAN-MIB jnxExVlanTag per port.
Arguments:
None
Returns:
data_dict- Dict of jnxExVlanTag using ifIndex as key
jnxexvlanname
def jnxexvlanname()
Return dict of JUNIPER-VLAN-MIB jnxExVlanName for each VLAN tag.
Arguments:
None
Returns:
data_dict- Dict of jnxExVlanName using the VLAN tag as key
snmp.mib.juniper.mib_juniperdevice
Module for JUNIPER device-specific MIBs (CPU, Memory).
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
JuniperDeviceQuery- Query class for JUNIPER device MIBs
init_query
def init_query(snmp_object)
Initialize and return this module's Query class.
Arguments:
snmp_objectSNMP - SNMP object
Returns:
JuniperDeviceQuery- Initialized Query class
JuniperDeviceQuery Objects
class JuniperDeviceQuery(Query)
Class interacts with device-level MIBs for Juniper.
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_objectSNMP - SNMP object
Returns:
None
system
def system()
Return system info (CPU + memory) in aggregator format.
Arguments:
None
Returns:
dict- System info in aggregator format
supported
def supported()
Return True if this module can query the device.
Arguments:
None
Returns:
bool- True if supported, False otherwise
snmp.mib.juniper
Juniper class imports.
snmp.mib.generic.mib_entity
Class interacts with devices supporting ENTITY-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
EntityQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
EntityQuery- Query class object
EntityQuery Objects
class EntityQuery(Query)
Class interacts with devices supporting ENTITY-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
system- Returns all relevant system information from the device. In some cases a system will have multiple subsystems that are covered by an OID. (eg. module / circuit board serial numbers). It will therefore be impossible to have a consistent key format for data values returned. Data returned by this method will therefore be keyed by :- MIB name (primary key)
- OID name in the MIB, (secondary key),
- Leaf value, or zero (0) if there are no leaves.
__init__
def __init__(snmp_object)
Intialize the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
system
def system()
Get system data from device.
Arguments:
None
Returns:
final- Final results
entphysicaldescr
def entphysicaldescr()
Return dict of ENTITY-MIB entPhysicalDescr for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalDescr using the oid's last node as key
entphysicalclass
def entphysicalclass()
Return dict of ENTITY-MIB entPhysicalClass for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalClass using the oid's last node as key
entphysicalsoftwarerev
def entphysicalsoftwarerev()
Return dict of ENTITY-MIB entPhysicalSoftwareRev for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalSoftwareRev using the oid's last node as key
entphysicalserialnum
def entphysicalserialnum()
Return dict of ENTITY-MIB entPhysicalSerialNum for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalSerialNum using the oid's last node as key
entphysicalmodelname
def entphysicalmodelname()
Return dict of ENTITY-MIB entPhysicalModelName for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalModelName using the oid's last node as key
entphysicalname
def entphysicalname()
Return dict of ENTITY-MIB entPhysicalName for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalName using the oid's last node as key
entphysicalhardwarerev
def entphysicalhardwarerev()
Return dict of ENTITY-MIB entPhysicalHardwareRev for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalHardwareRev using the oid's last node as key
entphysicalfirmwarerev
def entphysicalfirmwarerev()
Return dict of ENTITY-MIB entPhysicalFirmwareRev for device.
Arguments:
None
Returns:
data_dict- Dict of entPhysicalFirmwareRev using the oid's last node as key
snmp.mib.generic.mib_if
Class interacts with devices supporting IfMIB. (32 Bit Counters).
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
IfQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
IfQuery- Query class object
IfQuery Objects
class IfQuery(Query)
Class interacts with devices supporting IfMIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
system
def system()
Get system data from device.
Arguments:
None
Returns:
final- Final results
layer1
def layer1()
Get layer 1 data from device using Layer 1 OIDs.
Arguments:
None
Returns:
final- Final results
iflastchange
def iflastchange(oidonly=False)
Return dict of IFMIB ifLastChange for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifLastChange using the oid's last node as key
ifinoctets
def ifinoctets(safe=False, oidonly=False)
Return dict of IFMIB ifInOctets for each ifIndex for device.
Arguments:
safe- Do a failsafe walk if Trueoidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifInOctets using the oid's last node as key
ifoutoctets
def ifoutoctets(safe=False, oidonly=False)
Return dict of IFMIB ifOutOctets for each ifIndex for device.
Arguments:
safe- Do a failsafe walk if Trueoidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifOutOctets using the oid's last node as key
ifdescr
def ifdescr(safe=False, oidonly=False)
Return dict of IFMIB ifDescr for each ifIndex for device.
Arguments:
safe- Do a failsafe walk if Trueoidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifDescr using the oid's last node as key
iftype
def iftype(oidonly=False)
Return dict of IFMIB ifType for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifType using the oid's last node as key
ifspeed
def ifspeed(oidonly=False)
Return dict of IFMIB ifSpeed for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifSpeed using the oid's last node as key
ifadminstatus
def ifadminstatus(oidonly=False)
Return dict of IFMIB ifAdminStatus for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifAdminStatus using the oid's last node as key
ifoperstatus
def ifoperstatus(oidonly=False)
Return dict of IFMIB ifOperStatus for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifOperStatus using the oid's last node as key
ifalias
def ifalias(oidonly=False)
Return dict of IFMIB ifAlias for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifAlias using the oid's last node as key
ifname
def ifname(oidonly=False)
Return dict of IFMIB ifName for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifName using the oid's last node as key
ifindex
def ifindex(oidonly=False)
Return dict of IFMIB ifindex for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifindex using the oid's last node as key
ifphysaddress
def ifphysaddress(oidonly=False)
Return dict of IFMIB ifPhysAddress for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifPhysAddress using the oid's last node as key
ifinmulticastpkts
def ifinmulticastpkts(oidonly=False)
Return dict of IFMIB ifInMulticastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifInMulticastPkts. Key = OID's last node.
ifoutmulticastpkts
def ifoutmulticastpkts(oidonly=False)
Return dict of IFMIB ifOutMulticastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifOutMulticastPkts. Key = OID's last node.
ifinbroadcastpkts
def ifinbroadcastpkts(oidonly=False)
Return dict of IFMIB ifInBroadcastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifInBroadcastPkts. Key = OID's last node.
ifoutbroadcastpkts
def ifoutbroadcastpkts(oidonly=False)
Return dict of IFMIB ifOutBroadcastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifOutBroadcastPkts. Key = OID's last node.
ifstackstatus
def ifstackstatus(oidonly=False)
Return dict of IFMIB ifStackStatus for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
-
final- Dict of ifStackStatus keyed by the ifIndex of the ifstacklowerlayer as primary, and ifstackhigherlayer as secondary.Summary: According to the official IF-MIB file. ifStackStatus is a "table containing information on the relationships between the multiple sub-layers of network interfaces. In particular, it contains information on which sub-layers run 'on top of' which other sub-layers, where each sub-layer corresponds to a conceptual row in the ifTable. For example, when the sub-layer with ifIndex value x runs over the sub-layer with ifIndex value y, then this table contains:
ifStackStatus.x.y=active
For each ifIndex value, I, which identifies an active interface, there are always at least two instantiated rows in this table associated with I. For one of these rows, I is the value of ifStackHigherLayer; for the other, I is the value of ifStackLowerLayer. (If I is not involved in multiplexing, then these are the only two rows associated with I.)
For example, two rows exist even for an interface which has no others stacked on top or below it:
ifStackStatus.0.x=active ifStackStatus.x.0=active"
In the case of Juniper equipment, VLAN information is only visible on subinterfaces of the main interface. For example interface ge-0/0/0 won't have VLAN information assigned to it directly.
When a VLAN is assigned to this interface, a subinterface ge-0/0/0.0 is automatically created with a non-Ethernet ifType. VLAN related OIDs are only maintained for this new subinterface only. This makes determining an interface's VLAN based on Ethernet ifType more difficult. ifStackStatus maps the ifIndex of the primary interface (ge-0/0/0) to the ifIndex of the secondary interface (ge-0/0/0.0) which manages higher level protocols and data structures such as VLANs and LLDP.
The primary interface is referred to as the ifStackLowerLayer and the secondary subinterface is referred to as the ifStackHigherLayer.
snmp.mib.generic.mib_etherlike
Module for ETHERLIKE-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
EtherlikeQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
EtherlikeQuery- Query class object
EtherlikeQuery Objects
class EtherlikeQuery(Query)
Class interacts with ETHERLIKE-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
dot3statsduplexstatus
def dot3statsduplexstatus(oidonly=False)
Return dict of ETHERLIKE-MIB dot3StatsDuplexStatus for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of dot3StatsDuplexStatus using ifIndex as key
snmp.mib.generic.mib_ip
Class interacts with devices supporting IP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
IpQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
IpQuery- Query class object
IpQuery Objects
class IpQuery(Query)
Class interacts with devices supporting IP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer3- Returns all needed layer 3 MIB information from the device. Keyed by OID's MIB name (primary key), IP address (secondary key).
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
supported
def supported()
Return device's support for the MIB.
Arguments:
None
Returns:
validity- True if supported
layer3
def layer3()
Get layer 3 data from device.
Arguments:
None
Returns:
final- Final results
ipnettomediatable
def ipnettomediatable(oidonly=False)
Return dict of ipNetToMediaTable, the device's ARP table.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of MAC addresses keyed by IPv4 address
ipnettophysicalphysaddress
def ipnettophysicalphysaddress(oidonly=False)
Return dict of the device's ipNetToPhysicalPhysAddress ARP table.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of MAC addresses keyed by IPv6 Address
snmp.mib.generic.mib_bridge
Class interacts with devices supporting BRIDGE-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
BridgeQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
BridgeQuery- Query class object
BridgeQuery Objects
class BridgeQuery(Query)
Class interacts with devices supporting BRIDGE-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
dot1dbaseport_2_ifindex
def dot1dbaseport_2_ifindex(context_names=None)
Return dict of BRIDGE-MIB dot1dBasePortIfIndex data.
Arguments:
context_names- List of context names
Returns:
data_dict- Dict of dot1dBasePortIfIndex with dot1dBasePort as key.
snmp.mib.generic.mib_snmpv2
Class interacts with devices supporting SNMPv2-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
Snmpv2Query- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
Snmpv2Query- Query class object
Snmpv2Query Objects
class Snmpv2Query(Query)
Class interacts with devices supporting SNMPv2-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
system- Returns all relevant system information from the device. In some cases a system will have multiple subsystems that are covered by an OID. (eg. module / circuit board serial numbers). It will therefore be impossible to have a consistent key format for data values returned. Data returned by this method will therefore be keyed by :- MIB name (primary key)
- OID name in the MIB, (secondary key),
- Leaf value, or zero (0) if there are no leaves.
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
system
def system()
Get system data from device.
Arguments:
None
Returns:
final- Final results
snmp.mib.generic.mib_essswitch
Module for MIB-ESSWITCH.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
EssSwitchQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
EssSwitchQuery- Query class object
EssSwitchQuery Objects
class EssSwitchQuery(Query)
Class interacts with MIB-ESSWITCH.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
swportduplexstatus
def swportduplexstatus(oidonly=False)
Return dict of MIB-ESSWITCH swPortDuplexStatus for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of swPortDuplexStatus using ifIndex as key
snmp.mib.generic.mib_lldp
Module for LLDP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
LldpQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
LldpQuery- Query class object
LldpQuery Objects
class LldpQuery(Query)
Class interacts with LLDP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
lldpremsysname
def lldpremsysname(oidonly=False)
Return dict of LLDP-MIB lldpRemSysName for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of lldpRemSysName using ifIndex as key
lldpremsyscapenabled
def lldpremsyscapenabled(oidonly=False)
Return dict of LLDP-MIB lldpRemSysCapEnabled for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of lldpRemSysCapEnabled using ifIndex as key
lldpremsysdesc
def lldpremsysdesc(oidonly=False)
Return dict of LLDP-MIB lldpRemSysDesc for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of lldpRemSysDesc using ifIndex as key
lldpremportdesc
def lldpremportdesc(oidonly=False)
Return dict of LLDP-MIB lldpRemPortDesc for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of lldpRemPortDesc using ifIndex as key
lldplocportdesc
def lldplocportdesc(oidonly=False)
Return dict of LLDP-MIB lldpLocPortDesc for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of lldpLocPortDesc using ifIndex as key
snmp.mib.generic.mib_ipv6
Class interacts with CISCO-IETF-IP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
Ipv6Query- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
Ipv6Query- Query class object
Ipv6Query Objects
class Ipv6Query(Query)
Class interacts with CISCO-IETF-IP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer3- Returns all needed layer 3 MIB information from the device. Keyed by OID's MIB name (primary key), IP address (secondary key).
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer3
def layer3()
Get layer 3 data from device.
Arguments:
None
Returns:
final- Final results
ipv6nettomediaphysaddress
def ipv6nettomediaphysaddress()
Return dict of the device's ipv6NetToMediaPhysAddress ARP table.
Arguments:
None
Returns:
data_dict- Dict of MAC addresses keyed by IPv6 Address
snmp.mib.generic.mib_if_64
Class interacts with devices supporting IfMIB. (64 Bit Counters).
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
If64Query- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
If64Query- Query class object
If64Query Objects
class If64Query(Query)
Class interacts with devices supporting IfMIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
system
def system()
Get system data from device.
Arguments:
None
Returns:
final- Final results
layer1
def layer1()
Get layer 1 data from device using Layer 1 OIDs.
Arguments:
None
Returns:
final- Final results
ifhighspeed
def ifhighspeed(oidonly=False)
Return dict of IFMIB ifHighSpeed for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHighSpeed using the oid's last node as key
ifhcinucastpkts
def ifhcinucastpkts(oidonly=False)
Return dict of IFMIB ifHCInUcastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCInUcastPkts using the oid's last node as key
ifhcoutucastpkts
def ifhcoutucastpkts(oidonly=False)
Return dict of IFMIB ifHCOutUcastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCOutUcastPkts. Key = OID's last node.
ifhcinmulticastpkts
def ifhcinmulticastpkts(oidonly=False)
Return dict of IFMIB ifHCInMulticastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCInMulticastPkts. Key = OID's last node.
ifhcoutmulticastpkts
def ifhcoutmulticastpkts(oidonly=False)
Return dict of IFMIB ifHCOutMulticastPkts.
Keyed by ifIndex for the device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCOutMulticastPkts. Key = OID's last node.
ifhcinbroadcastpkts
def ifhcinbroadcastpkts(oidonly=False)
Return dict of IFMIB ifHCInBroadcastPkts for each ifIndex for device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCInBroadcastPkts. Key = OID's last node.
ifhcoutbroadcastpkts
def ifhcoutbroadcastpkts(oidonly=False)
Return dict of IFMIB ifHCOutBroadcastPkts.
Keyed by ifIndex for the device.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCOutBroadcastPkts. Key = OID's last node.
ifhcinoctets
def ifhcinoctets(safe=False, oidonly=False)
Return dict of IFMIB ifHCInOctets for each ifIndex for device.
Arguments:
safe- Do a failsafe walk if Trueoidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCInOctets. Key = OID's last node.
ifhcoutoctets
def ifhcoutoctets(safe=False, oidonly=False)
Return dict of IFMIB ifHCOutOctets for each ifIndex for device.
Arguments:
safe- Do a failsafe walk if Trueoidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of ifHCOutOctets. Key = OID's last node.
snmp.mib.generic
Define the switchmap.poller.snmp.mib.generic package.
Arguments:
None
Returns:
None
snmp.mib.generic.mib_qbridge
Module for Q-BRIDGE-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
QbridgeQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
QbridgeQuery- Query class object
QbridgeQuery Objects
class QbridgeQuery(Query)
Class interacts with Q-BRIDGE-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
layer2
def layer2()
Get layer 2 data from device.
Arguments:
None
Returns:
final- Final results
dot1qpvid
def dot1qpvid(oidonly=False)
Return dict of Q-BRIDGE-MIB dot1qPvid per port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of dot1qPvid using ifIndex as key
dot1qvlanstaticname
def dot1qvlanstaticname(oidonly=False)
Return dict of Q-BRIDGE-MIB dot1qVlanStaticName per port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of dot1qVlanStaticName using ifIndex as key
snmp.mib.cisco.mib_ciscovlaniftablerelationship
Module for CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoVlanIftableRelationshipQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoVlanIftableRelationshipQuery- Query class object
CiscoVlanIftableRelationshipQuery Objects
class CiscoVlanIftableRelationshipQuery(Query)
Class interacts with CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
cviroutedvlanifindex
def cviroutedvlanifindex(oidonly=False)
Return dictionary of CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB.
Keyed by OID cviRoutedVlanIfIndex for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of cviRoutedVlanIfIndex using the oid's last node as key
snmp.mib.cisco.mib_ciscovlanmembership
Module for CISCO-VLAN-MEMBERSHIP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoVlanMembershipQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoVlanMembershipQuery- Query class object
CiscoVlanMembershipQuery Objects
class CiscoVlanMembershipQuery(Query)
Class interacts with CISCO-VLAN-MEMBERSHIP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
vmvlan
def vmvlan(oidonly=False)
Return dict of CISCO-VLAN-MEMBERSHIP-MIB vmVlan for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vmVlan using the oid's last node as key
vmportstatus
def vmportstatus(oidonly=False)
Return dict of CISCO-VLAN-MEMBERSHIP-MIB vmPortStatus for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vmPortStatus using the oid's last node as key
snmp.mib.cisco.mib_ciscovtp
Class interacts with CISCO-VTP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoVtpQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoVtpQuery- Query class object
CiscoVtpQuery Objects
class CiscoVtpQuery(Query)
Class interacts with CISCO-VTP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key) -
layer2- Returns all needed layer 2 MIB information from the device. Keyed by OID's MIB name (primary key), VLAN number (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer2
def layer2()
Get layer 2 data from device.
Arguments:
None
Returns:
final- Final results
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
vlantrunkportencapsulationtype
def vlantrunkportencapsulationtype(oidonly=False)
Return CISCO-VTP-MIB vlanTrunkPortEncapsulationType per ifIndex.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vlanTrunkPortEncapsulationType using the oid's last node as key
vlantrunkportnativevlan
def vlantrunkportnativevlan(oidonly=False)
Return dict of CISCO-VTP-MIB vlanTrunkPortNativeVlan per ifIndex.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vlanTrunkPortNativeVlan using the oid's last node as key
vlantrunkportdynamicstatus
def vlantrunkportdynamicstatus(oidonly=False)
Return dict of CISCO-VTP-MIB vlanTrunkPortDynamicStatus per ifIndex.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vlanTrunkPortDynamicStatus using the oid's last node as key
vlantrunkportdynamicstate
def vlantrunkportdynamicstate(oidonly=False)
Return dict of CISCO-VTP-MIB vlanTrunkPortDynamicState per ifIndex.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vlanTrunkPortDynamicState using the oid's last node as key
vtpvlanname
def vtpvlanname(oidonly=False)
Return dict of CISCO-VTP-MIB vtpVlanName for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vtpVlanName using the oid's last node as key
vtpvlantype
def vtpvlantype(oidonly=False)
Return dict of CISCO-VTP-MIB vtpVlanType for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vtpVlanType using the oid's last node as key
vtpvlanstate
def vtpvlanstate(oidonly=False)
Return dict of CISCO-VTP-MIB vtpVlanState for each VLAN.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vtpVlanState using the oid's last node as key
vlantrunkportvlansenabled
def vlantrunkportvlansenabled(oidonly=False)
Return CISCO-VTP-MIB vlanTrunkPortVlansEnabled data per ifIndex.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of vlanTrunkPortVlansEnabled keyed by ifIndex with values being lists of enabled VLAN tags.
snmp.mib.cisco.mib_ciscostack
Module for CISCO-STACK-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoStackQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoStackQuery- Query class object
CiscoStackQuery Objects
class CiscoStackQuery(Query)
Class interacts with CISCO-STACK-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
portduplex
def portduplex(oidonly=False)
Return dict of CISCO-STACK-MIB portDuplex for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of portDuplex using ifIndex as key
snmp.mib.cisco.mib_ciscoietfip
Class interacts with CISCO-IETF-IP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoIetfIpQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoIetfIpQuery- Query class object
CiscoIetfIpQuery Objects
class CiscoIetfIpQuery(Query)
Class interacts with CISCO-IETF-IP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer3- Returns all needed layer 3 MIB information from the device. Keyed by OID's MIB name (primary key), IP address (secondary key).
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer3
def layer3()
Get layer 3 data from device.
Arguments:
None
Returns:
final- Final results
cinetnettomediaphysaddress
def cinetnettomediaphysaddress()
Return dict of the device's ARP table.
Arguments:
None
Returns:
data_dict- Dict of MAC addresses keyed by IPv6 Address
snmp.mib.cisco.mib_ciscocdp
Module for CISCO-CDP-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoCdpQuery- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoCdpQuery- Query class object
CiscoCdpQuery Objects
class CiscoCdpQuery(Query)
Class interacts with CISCO-CDP-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
cdpcachedeviceid
def cdpcachedeviceid(oidonly=False)
Return dict of CISCO-CDP-MIB cdpCacheDeviceId for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of cdpCacheDeviceId using ifIndex as key
cdpcacheplatform
def cdpcacheplatform(oidonly=False)
Return dict of CISCO-CDP-MIB cdpCachePlatform for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of cdpCachePlatform using ifIndex as key
cdpcachedeviceport
def cdpcachedeviceport(oidonly=False)
Return dict of CISCO-CDP-MIB cdpCacheDevicePort for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of cdpCacheDevicePort using ifIndex as key
snmp.mib.cisco
Cisco class imports.
snmp.mib.cisco.mib_ciscoc2900
Module for CISCO-C2900-MIB.
get_query
def get_query()
Return this module's Query class.
Arguments:
None
Returns:
CiscoC2900Query- Query class object
init_query
def init_query(snmp_object)
Return initialize and return this module's Query class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
CiscoC2900Query- Query class object
CiscoC2900Query Objects
class CiscoC2900Query(Query)
Class interacts with CISCO-C2900-MIB.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
layer1
def layer1()
Get layer 1 data from device.
Arguments:
None
Returns:
final- Final results
c2900portlinkbeatstatus
def c2900portlinkbeatstatus(oidonly=False)
Return dict of CISCO-C2900-MIB c2900PortLinkbeatStatus per port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of c2900PortLinkbeatStatus using ifIndex as key
c2900portduplexstatus
def c2900portduplexstatus(oidonly=False)
Return dict of CISCO-C2900-MIB c2900PortDuplexStatus for each port.
Arguments:
oidonly- Return OID's value, not results, if True
Returns:
data_dict- Dict of c2900PortDuplexStatus using ifIndex as key
system
def system(oidonly=False)
Return dict of system CPU and memory stats for Cisco 2900 series.
Arguments:
oidonly- Return OID values only if True
Returns:
final- Nested dict with CPU and memory information
snmp.mib
Define the switchmap.poller.snmp.mib package.
Arguments:
None
Returns:
None
snmp.poller
SNMP Poller module.
Poll Objects
class Poll()
Switchmap-NG agent that gathers data.
Arguments:
None
Returns:
None
Functions: init: populate: post:
__init__
def __init__(hostname)
Initialize the class.
Arguments:
hostname- Hostname to poll
Returns:
None
query
def query()
Query all remote hosts for data.
Arguments:
None
Returns:
None
snmp.snmp_manager
SNMP manager class.
Validate Objects
class Validate()
Class Verify SNMP data.
__init__
def __init__(options)
Initialize the Validate class.
Arguments:
options- POLLING_OPTIONS object containing SNMP configuration
Returns:
None
credentials
def credentials()
Determine valid SNMP credentials for a host.
Arguments:
None
Returns:
authentication- SNMP authorization object containing valid credentials, or None if no valid credentials found
validation
def validation(group=None)
Determine valid SNMP authorization for a host.
Arguments:
group- String containing SNMP group name to try, or None to try all groups
Returns:
result- SNMP authorization object if valid credentials found, None otherwise
Interact Objects
class Interact()
Class Gets SNMP data.
__init__
def __init__(_poll)
Initialize the Interact class.
Arguments:
_poll- POLL object containing SNMP configuration and target info
Returns:
None
enterprise_number
def enterprise_number()
Get SNMP enterprise number for the device.
Arguments:
None
Returns:
int- SNMP enterprise number identifying the device vendor
hostname
def hostname()
Get SNMP hostname for the interaction.
Arguments:
None
Returns:
str- Hostname of the target device
contactable
def contactable()
Check if device is reachable via SNMP.
Arguments:
None
Returns:
bool- True if device responds to SNMP queries, False otherwise
sysobjectid
def sysobjectid(check_reachability=False)
Get the sysObjectID of the device.
Arguments:
check_reachability- Boolean indicating whether to test connectivity. Some session errors are ignored to return null result.
Returns:
str- sysObjectID value as string, or None if not available
oid_exists
def oid_exists(oid_to_get, context_name="")
Determine if an OID exists on the device.
Arguments:
oid_to_get- String containing OID to checkcontext_name- String containing SNMPv3 context name. Default is empty string.
Returns:
bool- True if OID exists, False otherwise
swalk
def swalk(oid_to_get, normalized=False, context_name="")
Perform a safe SNMPwalk that handles errors gracefully.
Arguments:
oid_to_get- OID to getnormalized- If True, then return results as a dict keyed by only the last node of an OID, otherwise return results keyed by the entire OID string. Normalization is useful when trying to create multidimensional dicts where the primary key is a universal value such as IF-MIB::ifIndex or BRIDGE-MIB::dot1dBasePortcontext_name- Set the contextName used for SNMPv3 messages. The default contextName is the empty string "". Overrides the defContext token in the snmp.conf file.
Returns:
dict- Results of SNMP walk as OID-value pairs
walk
def walk(oid_to_get,
normalized=False,
check_reachability=False,
check_existence=False,
context_name="",
safe=False)
Do an SNMPwalk.
Arguments:
oid_to_get- OID to walknormalized- If True, then return results as a dict keyed by only the last node of an OID, otherwise return results keyed by the entire OID string. Normalization is useful when trying to create multidimensional dicts where the primary key is a universal value such as IF-MIB::ifIndex or BRIDGE-MIB::dot1dBasePort check_reachability: Set if testing for connectivity. Some session errors are ignored so that a null result is returned check_existence: Set if checking for the existence of the OIDcontext_name- Set the contextName used for SNMPv3 messages. The default contextName is the empty string "". Overrides the defContext token in the snmp.conf file.safe- Safe query if true. If there is an exception, then return blank values.
Returns:
result- Dictionary of tuples (OID, value)
get
def get(oid_to_get,
check_reachability=False,
check_existence=False,
normalized=False,
context_name="")
Do an SNMPget.
Arguments:
oid_to_get- OID to getcheck_reachability- Set if testing for connectivity. Some session errors are ignored so that a null result is returnedcheck_existence- Set if checking for the existence of the OIDnormalized- If True, then return results as a dict keyed by only the last node of an OID, otherwise return results keyed by the entire OID string. Normalization is useful when trying to create multidimensional dicts where the primary key is a universal value such as IF-MIB::ifIndex or BRIDGE-MIB::dot1dBasePortcontext_name- Set the contextName used for SNMPv3 messages. The default contextName is the empty string "". Overrides the defContext token in the snmp.conf file.
Returns:
result- Dictionary of tuples (OID, value)
query
def query(oid_to_get,
get=False,
check_reachability=False,
check_existence=False,
normalized=False,
context_name="",
safe=False)
Do an SNMP query.
Arguments:
oid_to_get- OID to walkget- Flag determining whether to do a GET or WALKcheck_reachability- Set if testing for connectivity. Some session errors are ignored so that a null result is returnedcheck_existence- Set if checking for the existence of the OIDnormalized- If True, then return results as a dict keyed by only the last node of an OID, otherwise return results keyed by the entire OID string. Normalization is useful when trying to create multidimensional dicts where the primary key is a universal value such as IF-MIB::ifIndex or BRIDGE-MIB::dot1dBasePortcontext_name- Set the contextName used for SNMPv3 messages. The default contextName is the empty string "". Overrides the defContext token in the snmp.conf file.safe- Safe query if true. If there is an exception, then return blank values.
Returns:
return_value- List of tuples (_contactable, exists, values)
_Session Objects
class _Session()
Class to create an SNMP session with a device.
__init__
def __init__(_poll, context_name="")
Initialize the _Session class.
Arguments:
_poll- POLL object containing SNMP configurationcontext_name- String containing SNMPv3 context name. Default is empty string.
Returns:
session- SNMP session
snmp.base_query
Base Query Class for interacting with devices.
Query Objects
class Query()
Base snmp query object.
Arguments:
None
Returns:
None
Key Methods:
-
supported- Queries the device to determine whether the MIB is supported using a known OID defined in the MIB. Returns True if the device returns a response to the OID, False if not. -
layer1- Returns all needed layer 1 MIB information from the device. Keyed by OID's MIB name (primary key), ifIndex (secondary key)
__init__
def __init__(snmp_object, test_oid, tags)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.pytest_oid- Oid that is used to check if the mib is supportedtags- List of the layers for which this query gathers information
Returns:
None
supported
def supported()
Return device's support for the MIB.
Arguments:
None
Returns:
validity- True if supported
snmp.snmp_info
Module to aggregate query results.
Query Objects
class Query()
Class interacts with IfMIB devices.
Arguments:
None
Returns:
None
__init__
def __init__(snmp_object)
Instantiate the class.
Arguments:
snmp_object- SNMP Interact class object from snmp_manager.py
Returns:
None
everything
def everything()
Get all information from device.
Arguments:
None
Returns:
data- Aggregated data
misc
def misc()
Provide miscellaneous information about device and the poll.
Arguments:
None
Returns:
data- Aggregated data
system
def system()
Get all system information from device.
Arguments:
None
Returns:
data- Aggregated data
layer1
def layer1()
Get all layer1 information from device.
Arguments:
None
Returns:
data- Aggregated data
layer2
def layer2()
Get all layer2 information from device.
Arguments:
None
Returns:
data- Aggregated data
layer3
def layer3()
Get all layer3 information from device.
Arguments:
None
Returns:
data- Aggregated data
update
Define the switchmap.poller.update package.
Arguments:
None
Returns:
None
update.device
Module for preparing polled device data for the database.
Device Objects
class Device()
Process data for a device.
The aim of this class is to process the YAML file consistently across multiple manufacturers and present it to other classes consistently. That way manufacturer specific code for processing YAML data is in one place.
For example, there isn't a standard way of reporting ethernet duplex values with different manufacturers exposing this data to different MIBs. This class file attempts to determine the true duplex value of the device by testing the presence of one or more OID values in the data. It adds a 'duplex' data key to self.ports to act as the canonical key for duplex across all devices.
__init__
def __init__(data)
Initialize class.
Arguments:
data- Dict of device data
Returns:
None
process
def process()
Initialize class.
Arguments:
None
Returns:
None
Summary:
IF-MIB
A significant portion of this code relies on ifIndex IF-MIB::ifStackStatus information. This is stored under the 'system' key of the device YAML files.
According to the official IF-MIB file. ifStackStatus is a "table containing information on the relationships between the multiple sub-layers of network interfaces. In particular, it contains information on which sub-layers run 'on top of' which other sub-layers, where each sub-layer corresponds to a conceptual row in the ifTable. For example, when the sub-layer with ifIndex value x runs over the sub-layer with ifIndex value y, then this table contains:
ifStackStatus.x.y=active
For each ifIndex value, I, which identifies an active interface, there are always at least two instantiated rows in this table associated with I. For one of these rows, I is the value of ifStackHigherLayer; for the other, I is the value of ifStackLowerLayer. (If I is not involved in multiplexing, then these are the only two rows associated with I.)
For example, two rows exist even for an interface which has no others stacked on top or below it:
ifStackStatus.0.x=active ifStackStatus.x.0=active"
In the case of Juniper equipment, VLAN information is only visible on subinterfaces of the main interface. For example interface ge-0/0/0 won't have VLAN information assigned to it directly.
When a VLAN is assigned to this interface, a subinterface ge-0/0/0.0 is automatically created with a non-Ethernet ifType. VLAN related OIDs are only maintained for this new subinterface only. This makes determining an interface's VLAN based on Ethernet ifType more difficult. ifStackStatus maps the ifIndex of the primary interface (ge-0/0/0) to the ifIndex of the secondary interface (ge-0/0/0.0) which manages higher level protocols and data structures such as VLANs and LLDP.
The primary interface is referred to as the ifStackLowerLayer and the secondary subinterface is referred to as the ifStackHigherLayer.
=================================================================
Layer1 Keys
The following Layer1 keys are presented by the ethernet_data method due to this instantiation:
l1_nativevlan- A vendor agnostic Native VLANl1_vlans- A list of vendor agnostic VLANsl1_trunk- A vendor agnostic flag of "True" if the port is a Trunkl1_duplex- A vendor agnostic status code for the duplex setting