Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Strange behavior of method in API

Strange behavior of method in API

Scheduled Pinned Locked Moved Support
7 Posts 3 Posters 16.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    J
    jhuliagraziella
    wrote on last edited by
    #1

    I made a script in python to populate a network, in which I condigure the name, IP, snmp port, snmp community and so.

    In class org.netxms.client.NXCObjectModificationData, when using the method void setSnmpVersion(int snmpVersion), I noticed the following:

    • If I pass number 1 as a paramether to the method, it configures as version 2c;
    • If I pass number 2 as a paramether to the method, it configures as version 1.

    Is this supposed to happen? Because of that, in my script I wrote this to configure correctly:

        if objectSnmpVersion == "V1":
            objectSnmpVersion = 2
        elif objectSnmpVersion == "V2C":
            objectSnmpVersion = 1
        elif objectSnmpVersion == "V3":
            objectSnmpVersion = 3
        md.setSnmpVersion(objectSnmpVersion)
            
    but didnt' like it...  ???

    1 Reply Last reply
    0
    • J
      J
      joni
      wrote on last edited by
      #2

      can you show a full version of your script?

      1 Reply Last reply
      0
      • V
        V
        Victor Kirhenshtein
        wrote on last edited by
        #3

        Hi!

        SNMP version constants are a bit illogical (for historical reasons). They are following:

        0 = SNMP v1
        1 = SNMP v2
        3 = SNMP v3

        2 is an invalid value, so it falls back to v1 (as any invalid value will do). You can use constants from AbstractNode class:

        AbstractNode.SNMP_VERSION_1, AbstractNode.SNMP_VERSION_2C, AbstractNode.SNMP_VERSION_3

        Best regards,
        Victor

        1 Reply Last reply
        0
        • J
          J
          jhuliagraziella
          wrote on last edited by
          #4

          I have attached the script here.
          I'm sorry, but all my comments are written in portuguese so here goes a little explanation about the code:

          In the beggining of the script it's defined the name of the container in which the nodes will be created. It checks if there already is a container with that name and if there isn't we create it. In any case we get the ID of the container of that name.
          Then, it opens an archive named input.csv with reading option and mark its delimiter as ';'.
          This archive has the following format:

          NAMEORIP;10.106.7.252;COMMUNITY;0rqu1dea;SNMPPORT;161;SNMPVERSION;V2C;SEEDNAME;a-rg-fcc-arq-001-araraquara;ACCESSMODE;ICMPSNMP;ADDRESSFORMAT;AUTOADDRESS;
          NAMEORIP;10.11.133.170;COMMUNITY;0rqu1dea;SNMPPORT;161;SNMPVERSION;V2C;SEEDNAME;a-rg-fcc-ula-085-cadministrativo;ACCESSMODE;ICMPSNMP;ADDRESSFORMAT;AUTOADDRESS;
          NAMEORIP;10.224.0.110;SNMPPORT;161;SNMPVERSION;V2C;SEEDNAME;a-rg-fcc-ula-301-image-01;ACCESSMODE;ICMPONLY;ADDRESSFORMAT;AUTOADDRESS;;;
          NAMEORIP;10.5.1.132;COMMUNITY;0rqu1dea;SNMPPORT;161;SNMPVERSION;V2C;SEEDNAME;a-rg-fcc-bet-511-guaruja;ACCESSMODE;ICMPSNMP;ADDRESSFORMAT;AUTOADDRESS;
          NAMEORIP;10.5.1.134;SNMPPORT;161;SNMPVERSION;V2C;SEEDNAME;a-rg-fcc-bhe-010-liberdade;ACCESSMODE;ICMPONLY;ADDRESSFORMAT;AUTOADDRESS;;;

          Above there are some lines of the archive. It's in this format because this is how it was exported by our running network management system (yeah I know it looks ugly!). As you can see, not all collumns are filled for all lines, and the names in upercase letters represent what parameter comes next, so we "treat" this in the if-chain by reading 2 collumns at a time and checking what that collumn represents. We save the data collected in variables.

          Then it's the creation part:
          First it checks if an object with that name already exists. If so, it doesn't create it. If not, it calls the methods of classes NXCObjectCreationData and NXCObjectModificationData and create it with the parameters got from the archive.

          Sorry about my not-so-good english, hope I made it clear!  ;D
          If you have any questions about anything feel free to ask me, I'll be glad to explain!

          Regards,

          Jhúlia Graziella


          popular-formatoSmarts.py

          1 Reply Last reply
          0
          • J
            J
            jhuliagraziella
            wrote on last edited by
            #5

            @victor said in Strange behavior of method in API:

            Hi!

            SNMP version constants are a bit illogical (for historical reasons). They are following:

            0 = SNMP v1
            1 = SNMP v2
            3 = SNMP v3

            2 is an invalid value, so it falls back to v1 (as any invalid value will do). You can use constants from AbstractNode class:

            AbstractNode.SNMP_VERSION_1, AbstractNode.SNMP_VERSION_2C, AbstractNode.SNMP_VERSION_3

            Best regards,
            Victor

            Oh, okay! Thank you very much! 😄 I'll correct it.

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #6

              Btw, is it intended to create all nodes with SNMP access disabled?

              Best regards,
              Victor

              1 Reply Last reply
              0
              • J
                J
                jhuliagraziella
                wrote on last edited by
                #7

                In this situation yes, because we won't monitore this nodes using SNMP, but I made this way so the script can be reused to populate the rest of the nodes!

                Thank you,
                Jhúlia Graziella

                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                Powered by NodeBB Contributors
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups