Difficulty using the CSV Importer

Started by twparker, April 27, 2023, 10:17:50 PM

Previous topic - Next topic

twparker

Hello all,

I am very new to netXMS (using ver 4.3.5) so please be patient.  Currently working on migrating network monitoring for a WISP off of the Dude to netXMS. I figured the best way to go about this would be to import a csv from the Dude device list. I got the list to pass all the checks, but I am getting the following error -

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Error: NXCException - Access denied.

I verified that my credentials and IP address for the netxms server are correct. I appreciate any suggestions.

gmonk63

What are you using to import  is it  https://github.com/tomaskir/NetXMS-csv-importer  if so im not sure it works with newer versions of Netxms

twparker

Yes, that is exactly what I am using. If that is the case, are there other options for mass device imports for newer versions of NetXMS? I have about 1500 devices that I am currently tracking with the Dude that I need to migrate.

Filipp Sudanov

Here's nxshell script that does the same job. nxshell is Jython implementation of Java API. You need to install nxshell to use this, on Linux this is included in netxms-client package

To execute the script:
nxshell -u admin -P password create_nodes.py

import csv

print("=========================================================================================================")

with open('nodes.csv') as csv_file:
    reader = csv.reader(csv_file, delimiter=',')
    data = [row for row in reader]

Infrastructure = session.findObjectByName("Infrastructure services")
if Infrastructure is None:
    print("Infrastructure services not found")
    quit()

flags = NXCObjectCreationData.CF_DISABLE_ETHERNET_IP

for i in range(1, len(data)):nxshell -u admin -P "" create_nodes.py
    node_name = data[i].strip()
    node_address = data[i][1].strip()
    node_container = data[i][2].strip()
    Container = session.findObjectByName(node_container)
    if Container is None:
        cd = NXCObjectCreationData(objects.GenericObject.OBJECT_CONTAINER, node_container, Infrastructure.objectId);
        node_container_id = session.createObject(cd)
        print('Container "{}" created, id={}'.format(node_container, node_container_id))
    else:
        print('Container "{}" already exists'.format(node_container))
        node_container_id = Container.objectId
    Node = session.findObjectByName(node_name)
    if Node is None:
        cd = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, node_name, node_container_id);
        cd.setCreationFlags(flags);
        cd.setPrimaryName(node_address)
        nodeId = session.createObject(cd)
        print('Node "%s" created, id=%d' % (node_name, nodeId))
    else:
        print('Node "%s" already exists' % (node_name))

Filipp Sudanov

Actually, can you attach an example of how export from the Dude looks like? We might be interested in adding some out-of-the box scripts for import as this might be useful for many people.

Is it only the list of nodes, or there is some other useful data from the Dude that can be exported (e.g. templates with OIDs for SNMP polling, etc...)