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.