Nice to hear that this is not hard to implement
where can I add this feature request?
Regards,
Christoph
Nice to hear that this is not hard to implement
where can I add this feature request?
Regards,
Christoph
Hi,
is it possible to add the content of a container to a map and keep it up to date? (for example if a node gets removed/added to the container it should get removed/added to the map)
Regards,
Christoph
Thanks for this easy solution 
Hi,
I am monitoring many wireless sectors - with many pppoe interfaces. The problem is: once a client disconnects the pppoe interface gets deleted and if he reconnects the interface has a new id. So there are many false alerts on interface down as the "expected interface state" gets always reset to "up".
So my question is: is there a way to either set the default interface expected state of newly created interfaces to ignore, or change the way that netxms detects ppp interfaces?
Regards,
Christoph
Hi Heimo,
thank you for the tip. I have changed all interfaces now and it looks good at the moment.
Here is the script I used for changing the interfaces:
from org.netxms.client.objects import GenericObject, Node, Interface, AbstractObject
# START CONFIG
###############################################################################
rootID = 108 #objects.GenericObject.SERVICEROOT # Infrastructure Services Node
##############################################################################
# END CONFIG
rootNode = s.findObjectById(rootID) # the root node object
print 'Changing items from node %s' % ( rootNode.getObjectName() )
def getSubItems(parent, depth):
for node in parent.getChildsAsArray():
nodeClass = node.getObjectClass()
nodeName = node.getObjectName()
if nodeClass == AbstractObject.OBJECT_CONTAINER:
#print 'Checking subnode...'
getSubItems(node, depth + 1)
else:
for interface in node.getAllChilds(GenericObject.OBJECT_INTERFACE): # 3 == interface
name = interface.getObjectName()
if name.startswith('unknown'):
data = NXCObjectModificationData(interface.getObjectId())
#data.setExpectedState(2) # 2 := ignore interface state
newFlags = interface.getFlags() | Interface.IF_EXCLUDE_FROM_TOPOLOGY # set exclude flag
data.setObjectFlags(newFlags)
session.modifyObject(data)
print 'Changed interface of %s' % (nodeName)
#session.applyTemplate(4754, node.getObjectId()) # add node to new template
#print 'Added node to new polling template'
# main
getSubItems(rootNode, 1)
print 'Done changing interfaces!'
Hi,
I am getting the message Invalid network mask /24 on interface "unknown", should be /26. The monitored node does not use SNMP or Agent. (so netxms does not know anything about interfaces). The ip of the node should be x.x.x.x/26 but I cannot change the primary hostname/ip of the node to include the subnet mask.
This is a wireless client. The Access Point uses SNMP - so NetXMS knows that the IP of the client should have a /26 netmask. Is there a way to disable the check for "unknown" interfaces?
Regards,
Christoph
Hi,
I want to post a small example script for importing/exporting. Maybe someone can improve this script - it is kinda usefull if you want to migrate to a new server without copying the old database.
EXPORT
export_nodes.py:
from org.netxms.client.objects import GenericObject, Node, Interface, AbstractObject
import sys
import pickle
import codecs
# START CONFIG
###############################################################################
printTree = True
exportFilename = "exported_nodes.nxe"
rootID = objects.GenericObject.SERVICEROOT # Infrastructure Services Node
##############################################################################
# END CONFIG
rootNode = s.findObjectById(rootID) # the root node object
exportHandle = codecs.open(exportFilename, 'w', 'utf-8')
print 'Exporting items from node %s' % ( rootNode.getObjectName() )
def getSubItems(parent, depth):
for node in parent.getChildsAsArray():
name = node.getObjectName()
nodeId = node.getObjectId()
nodeClass = node.getObjectClass()
#print 'Found object: %s (%d) - class: %d' % (name, nodeId, nodeClass)
if nodeClass == AbstractObject.OBJECT_CONTAINER:
#print 'Checking subnode...'
if printTree == True:
print str(nodeClass) * (depth + 2) + ";" + name
exportHandle.write(str(nodeClass) * (depth) + ";" + name + "\n")
getSubItems(node, depth + 1)
else:
if printTree == True:
print str(nodeClass) * (depth) + ";" + name + ";" + node.getPrimaryIP().getHostAddress()
loc = node.getGeolocation()
ip = node.getPrimaryIP().getHostAddress()
attrs = node.getCustomAttributes()
comment = node.getComments()
hassnmp = node.hasSnmpAgent()
hasnx = node.hasAgent()
# generate custom attribute string
attrstr = ''
for key in attrs: # in python 2.x it is iteritems()
if attrstr != '':
attrstr = attrstr + ':#:'
attrstr = attrstr + key + '=-=' + attrs.get(key)
exportHandle.write( str(nodeClass) * (depth) + ";" + name + ";" + ip + ";" + \
loc.getLatitudeAsString() + ";" + loc.getLongitudeAsString() + ";" + attrstr + ";" + \
str(hassnmp) + ";" + str(hasnx) + ";" + comment + "\n" )
#print 'Found device: %s' % (name)
# main
getSubItems(rootNode, 1)
print 'Done! (Exported file: %s)' % ( exportFilename )
Export nodes with this command:
java -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar nxshell-2.0-M4.jar export_nodes.py
IMPORT
import_nodes.py:
from org.netxms.client.objects import GenericObject, Node, Interface, AbstractObject
import sys
import java
import codecs
# START CONFIG
###############################################################################
printTree = True
importFilename = "exported_nodes.nxe"
rootID = objects.GenericObject.SERVICEROOT # Infrastructure Services Node
##############################################################################
# END CONFIG
rootNode = s.findObjectById(rootID) # the root node object
print 'Importing items from node %s' % ( importFilename )
parentId = rootID
parentTree = [rootID]
with codecs.open(importFilename, 'r', 'utf-8') as f:
for line in f:
arr = line.split(';')
# first element specifies type and depth
depth = len(arr[0])
nodetype = int(arr[0][0])
print 'found item: type = %d, depth = %d' % (nodetype, depth)
# all fields mapped to variable names
name = arr[1].strip()
if nodetype == AbstractObject.OBJECT_NODE:
ip = arr[2]
ipaddress = java.net.InetAddress.getByName(ip)
ipnetmask = java.net.InetAddress.getByName("255.255.255.0")
lat = arr[3]
lng = arr[4]
attrs = arr[5]
hassnmp = bool(arr[6])
hasnx = bool(arr[7])
comment = arr[8].strip()
flags = 0
if hasnx == False:
flags |= NXCObjectCreationData.CF_DISABLE_NXCP
if hassnmp == False:
flags |= NXCObjectCreationData.CF_DISABLE_SNMP
if nodetype == AbstractObject.OBJECT_CONTAINER:
# create a new container and set it as current root
print 'Creating Folder: %s in parent: %d' % (name, parentId)
cd = NXCObjectCreationData(objects.GenericObject.OBJECT_CONTAINER, name, parentTree[depth-1]);
folderId = session.createObject(cd) # createObject return ID of newly created object
if (len(parentTree)-1) > depth:
parentTree[depth] = folderId
else:
parentTree.insert(depth, folderId)
else:
# create a new node in the current container
print 'Creating Node: %s - %s' % (name, ip)
cd = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, name, parentTree[depth-1]);
cd.setCreationFlags(flags);
cd.setComments(comment);
#cd.setIpAddress(ipaddress);
#cd.setIpNetMask(ipnetmask);
cd.setPrimaryName(ip) # Create node with IP address
nodeId = session.createObject(cd)
#print 'Line: %s' % (line)
print 'Done!'
Import nodes with this command:
java -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar nxshell-2.0-M4.jar import_nodes.py
Especially the import script might need some improvement to allow importing of custom attributes and so on.
I hope this is helpful!
Thank you very much 
Hi Victor,
thank you for your answer 
I was trying to set the ip and netmask manually for an object because if i create a node in GUI, the netmask of the generated node is wrong. But as i see now, the API seems to be really outdated ('org.netxms.client.NXCObjectCreationData' object has no attribute 'setIpNetMask') is there a new documentation somewhere?
Thanks for your help,
Christoph
Hi,
i am getting the same error in my script. Are there any solutions?
Also using 2.0-M4
Regards,
Christoph