emit_snmp_attributes Function (Python)
Syntax
Python Syntax
jcs.emit_snmp_attributes(snmp_oid, snmp_oid_type, snmp_oid_value)
Description
Return the attributes for the requested MIB object from a Python SNMP script.
SNMP scripts provide the flexibility to support custom MIBs.
SNMP scripts are triggered automatically when the SNMP manager requests
information for an unsupported object identifier (OID) that is mapped
to an SNMP script. When the script is invoked, the jcs.emit_snmp_attributes()
function emits the data for the requested object. The script acts
like an SNMP subagent, and the system sends the return value from
the script to the network management system (NMS).
Parameters
snmp_oid |
String containing the OID about which the script is returning information. |
snmp_oid_type |
String that specifies the
type of the data being returned for the requested MIB object. Acceptable
values are |
snmp_oid_value |
Data to return for the requested MIB object. |
Usage Examples
The following example Python SNMP script processes unsupported
object identifiers (OIDs) that are mapped to the script in the Junos
OS configuration. The emit_snmp_attributes()
function returns the attributes for the requested OID.
import jcs def main(): snmp_action = jcs.get_snmp_action() snmp_oid = jcs.get_snmp_oid() jcs.syslog("8", "snmp_action = ", snmp_action, " snmp_oid = ", snmp_oid) if snmp_action == 'get': if snmp_oid == '.1.3.6.1.4.1.2636.13.61.1.9.1.1.1': jcs.emit_snmp_attributes(snmp_oid, "Integer32", "211") elif snmp_oid == '.1.3.6.1.4.1.2636.13.61.1.9.1.1.2': jcs.emit_snmp_attributes(snmp_oid, "Integer32", "429") elif snmp_action == 'get-next': if snmp_oid == '.1.3.6.1.4.1.2636.13.61.1.9.1.1': jcs.emit_snmp_attributes(".1.3.6.1.4.1.2636.13.61.1.9.1.1.1", "Integer32", "211") elif snmp_oid == '.1.3.6.1.4.1.2636.13.61.1.9.1.1.1': jcs.emit_snmp_attributes(".1.3.6.1.4.1.2636.13.61.1.9.1.1.2", "Integer32", "429") if __name__ == '__main__': main()
Release Information
Function introduced in Junos OS Release 16.1R1.