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. nxshell gives Request timed out

nxshell gives Request timed out

Scheduled Pinned Locked Moved Support
2 Posts 2 Posters 34.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.
  • B
    B
    Borgso
    wrote on last edited by
    #1

    I have a nxshell script that takes linux formated hosts (/etc/hosts) list and adds it as nodes.
    When after running it ok 2 times i get "Request timed out" on 3th run.
    Then i need to wait xx minutes before i get it to work again.

    Do the script open a connection and then not closing it proper so i need to wait for some timeout?

    Script:

    #!/usr/bin/python
    #
    # 2015-07-29 - EspenGB - Working 1.2.17
    # Usage:
    # $0 hostname
    # * Ex: $0 node.netxms.tld
    
    # $0 hostfile(/etc/hostname)
    # * Ex: $0 /etc/hosts
    
    # $0 hostname/hostfile containerId
    # * Ex: $0 /etc/hosts 1234
    
    import sys, socket, os, string, re
    
    if len(sys.argv) < 2:
        print >>sys.stderr, 'Usage: ' + sys.argv[0] + ' <file/host> [<containerId>]'
        sys.exit(1)
    
    name = sys.argv[1]
    
    def addNode(name):
        try:
            test = socket.inet_aton(name)
            host_ip = name
        except socket.error:
            try:
                host_ip = socket.gethostbyname(name)
            except socket.error:
                host_ip = "0.0.0.0"
    
        if sys.argv[2]:
    	containerId = int(sys.argv[2])
        else:
            if sys.argv[0] == "nxshell_test":
                containerId = int(5636)
            else:
                containerId = int(5636)
        flags = NXCObjectCreationData.CF_DISABLE_NXCP | \
                NXCObjectCreationData.CF_DISABLE_SNMP
    
        cd = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, name, containerId);
        cd.setCreationFlags(flags);
        cd.setPrimaryName(host_ip) # Create node with IP address
        nodeId = session.createObject(cd)
        print " * Added {0} to containerID: {1}".format(name, containerId)
    
    def is_valid_ip(ip):
        m = re.match(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$", ip)
        return bool(m) and all(map(lambda n: 0 <= int(n) <= 255, m.groups()))
    
    if os.path.isfile(name):
        print "File found: "
        for names in open(name).readlines():
    	hostnames = re.split(r'\s+', names)
    	host_ip = hostnames[0].strip()
    	host_name = hostnames[1].strip()
    	if is_valid_ip(host_ip):
    	    print "Add: '" + host_ip + "' '" + host_name + "'"
                addNode(host_name.strip());
    else:
        print "Add: " + name.strip()
        addNode(name.strip());
    
    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      event if connection is not closed properly connection limit is way bigger than 2. What is in server log (on debug level 6 or higher) when you try to connect for 3rd time?

      Best regards,
      Victor

      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