Import List of IP Addresses
-
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.
-
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 -
@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,
VictorHello Victor thank you for replying. Actually I know nothing about Python. Any assistance would be great.
-
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" passCreate file with ip list, delimited by newline (without whitespaces).
rename it to discover.txtput all in one folder. (/home/nxuser/nxShell/)
Create folder "FromFile" via nxmc. New objects will be added there.
Runjava -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.pyScript 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 -
@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" passCreate file with ip list, delimited by newline (without whitespaces).
rename it to discover.txtput all in one folder. (/home/nxuser/nxShell/)
Create folder "FromFile" via nxmc. New objects will be added there.
Runjava -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.pyScript 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" passThank 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?
-
-
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 -
@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?
-
See indentation example on wiki:
http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Indentation
-
@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.
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