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. Import List of IP Addresses

Import List of IP Addresses

Scheduled Pinned Locked Moved Support
10 Posts 3 Posters 19.2k 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.
  • M
    M
    m1975Michael
    wrote on last edited by
    #1

    Hello Everyone,

    I am new to NetXMS.  I would like to import a list of IP addresses.  The devices are on different networks and I only want to add that specific device to NetXMS.  We have about 600 networks connected through VPN connections.  Any assistance would be greatly appreciated.  Thank you.

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

      Hi!

      Your best bet is to create simply script with nxshell (http://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations) to read list of addresses and create node objects. If you are not good at Python - just ask, I'm quite sure that somebody will create such script.

      Best regards,
      Victor

      1 Reply Last reply
      0
      • M
        M
        m1975Michael
        wrote on last edited by
        #3

        @victor said in Import List of IP Addresses:

        Hi!

        Your best bet is to create simply script with nxshell (http://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations) to read list of addresses and create node objects. If you are not good at Python - just ask, I'm quite sure that somebody will create such script.

        Best regards,
        Victor

        Hello Victor thank you for replying.  Actually I know nothing about Python.  Any assistance would be great.

        1 Reply Last reply
        0
        • A
          A
          andrey--k
          wrote on last edited by
          #4

          I have ready script for similar purpose.

          from org.netxms.client.objects import GenericObject, Node, Template
          
          rootObject = session.findObjectByName("FromFile")
          #print rootObject
          #print "\n"
          if rootObject:
          	for nodeIP in open("discover.txt").readlines():
          		test = s.findObjectByName(nodeIP.strip())
          		if test:
          			print "Object exists\n"
          		else:
          			name = "IP%s" % nodeIP.strip()
          			newNode = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, name, rootObject.getObjectId());
          			newNode.setPrimaryName(nodeIP.strip())
          			try:
          				nodeId = session.createObject(newNode)
          			except:
          				print "exception create node\n"
          				pass
          			else:
          				if nodeId:
          					try:
          						s.pollNode(nodeId,2,None)
          					except:
          						print "exception make pool\n"
          						pass
          

          Create file with ip list, delimited by newline (without whitespaces).
          rename it to discover.txt

          put all in one folder. (/home/nxuser/nxShell/)

          Create folder "FromFile" via nxmc. New objects will be added there.
          Run

          java -Djava.io.tmpdir=/tmp/ -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar /home/nxuser/nxShell/nxshell-1.2.14.jar nodesRemoveSoftwareScan.py
          

          Script work slowly. For 600 ip it will take 3-5 hours but all nodes will be polled.
          If you want to do it faster - comment or delete next lines from script:

          				if nodeId:
          					try:
          						s.pollNode(nodeId,2,None)
          					except:
          						print "exception make pool\n"
          						pass
          
          1 Reply Last reply
          0
          • M
            M
            m1975Michael
            wrote on last edited by
            #5

            @andrey-k said in Import List of IP Addresses:

            I have ready script for similar purpose.

            from org.netxms.client.objects import GenericObject, Node, Template
            
            rootObject = session.findObjectByName("FromFile")
            #print rootObject
            #print "\n"
            if rootObject:
            	for nodeIP in open("discover.txt").readlines():
            		test = s.findObjectByName(nodeIP.strip())
            		if test:
            			print "Object exists\n"
            		else:
            			name = "IP%s" % nodeIP.strip()
            			newNode = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, name, rootObject.getObjectId());
            			newNode.setPrimaryName(nodeIP.strip())
            			try:
            				nodeId = session.createObject(newNode)
            			except:
            				print "exception create node\n"
            				pass
            			else:
            				if nodeId:
            					try:
            						s.pollNode(nodeId,2,None)
            					except:
            						print "exception make pool\n"
            						pass
            

            Create file with ip list, delimited by newline (without whitespaces).
            rename it to discover.txt

            put all in one folder. (/home/nxuser/nxShell/)

            Create folder "FromFile" via nxmc. New objects will be added there.
            Run

            java -Djava.io.tmpdir=/tmp/ -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar /home/nxuser/nxShell/nxshell-1.2.14.jar nodesRemoveSoftwareScan.py
            

            Script work slowly. For 600 ip it will take 3-5 hours but all nodes will be polled.
            If you want to do it faster - comment or delete next lines from script:

            				if nodeId:
            					try:
            						s.pollNode(nodeId,2,None)
            					except:
            						print "exception make pool\n"
            						pass
            

            Thank you for the script.  I am running the windows version of NetXMS anything I need to change in the script?  How do you run the script?

            1 Reply Last reply
            0
            • A
              A
              andrey--k
              wrote on last edited by
              #6

              Sorry, but am running linux-only versions.

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

                Script should be run in a same manner on Windows, just omit -Djava.io.tmpdir=/tmp/ and use \ instaed of / in path separators.

                Best regards,
                Victor

                1 Reply Last reply
                0
                • M
                  M
                  m1975Michael
                  wrote on last edited by
                  #8

                  @andrey-k said in Import List of IP Addresses:

                  Sorry, but am running linux-only versions.

                  Hello, did some of the script get cut off.  Do you need closing statements for IF and For?

                  1 Reply Last reply
                  0
                  • A
                    A
                    andrey--k
                    wrote on last edited by
                    #9

                    See indentation example on wiki:

                    http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Indentation

                    1 Reply Last reply
                    0
                    • M
                      M
                      m1975Michael
                      wrote on last edited by
                      #10

                      @andrey-k said in Import List of IP Addresses:

                      See indentation example on wiki:

                      http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Indentation

                      Thank you Andrey I understand now.  I was able to get your script to work.  It is much appreciated.

                      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