Automation

 View Only
last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Question on SNMP on-box scripts

     
    Posted 08-10-2023 11:03

    Hi.

    Here is an example of the configuration needed to have my SNMP script sample.py be triggered by an incoming SNMP Request for unsupported OID 1.3.6.1.4.1.2636.13.61.1.9.1.1.

    system {
        scripts {
            snmp {
                file sample.py {
                    oid .1.3.6.1.4.1.2636.13.61.1.9.1.1;
                }
            }
        }
    }

    How do I choose an OID that is guaranteed to not be used by Juniper in future releases, which will then cause my script to not be triggered by that same OID?

    Thanks,

    Deepak



  • 2.  RE: Question on SNMP on-box scripts

    Posted 08-15-2023 12:04

    Hi Deepak,

         

                  The root OID for Juniper-SMI MIB is "1.3.6.1.4.1.2636", you can use any ids thats available after that. If Juniper needs additional OID, it would pick the next available sequential free id from the list in my opinion.

    You can always check the assigned ID's from the SNMP explorer site hosted on the Juniper support site.

    https://apps.juniper.net/mib-explorer/navigate?software=Junos%20OS&release=23.2R1&name=juniperMIB&oid=1.3.6.1.4.1.2636

    If you look at all the children links you can find the ID's that are currently used for the OID values that are used by Juniper Devices. 

    For example refer to the link below which is the last ID i.e. starting with 11

    https://apps.juniper.net/mib-explorer/navigate?software=Junos%20OS&release=23.2R1&name=jnxAgentCapability&oid=1.3.6.1.4.1.2636.11

    Here is an example I used in the lab to designate a higher value OID when querying using a SNMP script on the SRX device. I have used 1000 in the example below.

    scripts {
        language python3;
        snmp {
            file test.py {
                oid .1.3.6.1.4.1.2636.1000.61.1.9.1.1;
                oid .1.3.6.1.4.1.2636.1000.61.1.9.1.2;
                python-script-user lab;
            }
        }
    }

    root@srx> show snmp mib walk .1.3.6.1.4.1.2636.1000.61.1.9.1
    juniperMIB.1000.61.1.9.1.1.1 = 211
    juniperMIB.1000.61.1.9.1.1.2 = 429

    root@srx> show snmp mib get .1.3.6.1.4.1.2636.1000.61.1.9.1.1.1
    juniperMIB.1000.61.1.9.1.1.1 = 211

    root@srx> show snmp mib get .1.3.6.1.4.1.2636.1000.61.1.9.1.1.2
    juniperMIB.1000.61.1.9.1.1.2 = 429

    Here is the SNMP script I used:

    #!/usr/bin/python3

    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.1000.61.1.9.1.1.1':
                jcs.emit_snmp_attributes(snmp_oid, "Integer32", "211")
            elif snmp_oid == '.1.3.6.1.4.1.2636.1000.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.1000.61.1.9.1.1':
                jcs.emit_snmp_attributes(".1.3.6.1.4.1.2636.1000.61.1.9.1.1.1", "Integer32", "211")
            elif snmp_oid == '.1.3.6.1.4.1.2636.1000.61.1.9.1.1.1':
                jcs.emit_snmp_attributes(".1.3.6.1.4.1.2636.1000.61.1.9.1.1.2", "Integer32", "429")

    if __name__ == '__main__':
        main()



    ------------------------------
    Pradeep Hattiangadi
    ------------------------------



  • 3.  RE: Question on SNMP on-box scripts

    Posted 08-19-2023 11:07

     provides clear guidance on Juniper's MIB structure and OID assignments, with relevant links for further information. The example adds practical context, enhancing the understanding of how to use SNMP 



    ------------------------------
    Rock Jonn
    ------------------------------



  • 4.  RE: Question on SNMP on-box scripts

    Posted 08-19-2023 11:06

    Selecting a custom OID to ensure future compatibility requires careful consideration. Aim for an enterprise-specific OID under the "private.enterprises" subtree, like ".1.3.6.1.4.1.9999". This reduces the risk of conflicts with Juniper's OIDs, safeguarding your script's functionality over subsequent releases.



    ------------------------------
    Rock Jonn
    ------------------------------



  • 5.  RE: Question on SNMP on-box scripts
    Best Answer

     
    Posted 02-11-2024 13:27
    Edited by djadhav 02-12-2024 03:51

    My approach has always been to use the jnx-utility mib, that is its purpose.



    ------------------------------
    Andy Sharp
    ------------------------------



  • 6.  RE: Question on SNMP on-box scripts

     
    Posted 02-12-2024 03:53

    Thanks Andrew!