ezsnmp.ez module
- ezsnmp.ez.snmp_bulkwalk(oids: List[str | Tuple[str, str]] | str | Tuple[str, str] = '.1.3.6.1.2.1', non_repeaters: int = 0, max_repetitions: int = 10, **session_kargs: dict) List[SNMPVariable]
Uses SNMP GETBULK operation using the prepared session to automatically retrieve multiple pieces of information in an OID
- Parameters:
oids – you may pass in a single item * string representing the entire OID (e.g. ‘sysDescr.0’) * tuple (name, index) (e.g. (‘sysDescr’, 0)) * list of OIDs
non_repeaters – the number of objects that are only expected to return a single GETNEXT instance, not multiple instances
max_repetitions – the number of objects that should be returned for all the repeating OIDs
- Returns:
a list of SNMPVariable objects containing the values that were retrieved via SNMP
- ezsnmp.ez.snmp_get(oids: List[str | Tuple[str, str]], **session_kargs: dict) List[SNMPVariable]
- ezsnmp.ez.snmp_get(oids: str | Tuple[str, str], **session_kargs: dict) SNMPVariable
Perform an SNMP GET operation to retrieve a particular piece of information.
- Parameters:
oids – you may pass in a list of OIDs or single item; each item may be a string representing the entire OID (e.g. ‘sysDescr.0’) or may be a tuple containing the name as its first item and index as its second (e.g. (‘sysDescr’, 0))
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
an SNMPVariable object containing the value that was retrieved or a list of objects when you send in a list of OIDs
- ezsnmp.ez.snmp_get_bulk(oids: List[str | Tuple[str, str]] | str | Tuple[str, str], non_repeaters: int = 0, max_repetitions: int = 10, **session_kargs: dict) List[SNMPVariable]
Performs a bulk SNMP GET operation to retrieve multiple pieces of information in a single packet.
- Parameters:
oids – you may pass in a list of OIDs or single item; each item may be a string representing the entire OID (e.g. ‘sysDescr.0’) or may be a tuple containing the name as its first item and index as its second (e.g. (‘sysDescr’, 0))
non_repeaters – the number of objects that are only expected to return a single GETNEXT instance, not multiple instances
max_repetitions – the number of objects that should be returned for all the repeating OIDs
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
a list of SNMPVariable objects containing the values that were retrieved via SNMP
- ezsnmp.ez.snmp_get_next(oids: List[str | Tuple[str, str]], **session_kargs: dict) List[SNMPVariable]
- ezsnmp.ez.snmp_get_next(oids: str | Tuple[str, str], **session_kwargs: Any) SNMPVariable
Uses an SNMP GETNEXT operation to retrieve the next variable after the chosen item.
- Parameters:
oids – you may pass in a list of OIDs or single item; each item may be a string representing the entire OID (e.g. ‘sysDescr.0’) or may be a tuple containing the name as its first item and index as its second (e.g. (‘sysDescr’, 0))
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
an SNMPVariable object containing the value that was retrieved or a list of objects when you send in a list of OIDs
- ezsnmp.ez.snmp_set(oid: str | Tuple[str, str], value: Any, type: str | None = None, **session_kargs: dict) bool
Perform an SNMP SET operation to update a particular piece of information.
- Parameters:
oid – the OID that you wish to set which may be a string representing the entire OID (e.g. ‘sysDescr.0’) or may be a tuple containing the name as its first item and index as its second (e.g. (‘sysDescr’, 0))
value – the value to set the OID to
snmp_type – if a numeric OID is used and the object is not in the parsed MIB, a type must be explicitly supplied
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
bool value indicated that if snmp_set was successed
- ezsnmp.ez.snmp_set_multiple(oid_values: List[Tuple[str, Any] | Tuple[str, Any, str]], **session_kargs: dict) bool
Perform multiple SNMP SET operations to update various pieces of information at the same time.
- Parameters:
oid_values – a list of tuples whereby each tuple contains a (oid, value) or an (oid, value, snmp_type)
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
bool value indicated that if snmp_set was successed
- ezsnmp.ez.snmp_walk(oids: List[str | Tuple[str, str]] | str | Tuple[str, str] = '.1.3.6.1.2.1', **session_kargs: dict) List[SNMPVariable]
Uses SNMP GETNEXT operation to automatically retrieve multiple pieces of information in an OID for you.
- Parameters:
oids – you may pass in a single item (multiple values currently experimental) which may be a string representing the entire OID (e.g. ‘sysDescr.0’) or may be a tuple containing the name as its first item and index as its second (e.g. (‘sysDescr’, 0))
session_kargs – keyword arguments which will be sent used when constructing the session for this operation; all parameters in the Session class are supported
- Returns:
a list of SNMPVariable objects containing the values that were retrieved via SNMP