<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[nxshell gives Request timed out]]></title><description><![CDATA[<p dir="auto">I have a nxshell script that takes linux formated hosts (/etc/hosts) list and adds it as nodes.<br />
When after running it ok 2 times i get "Request timed out" on 3th run.<br />
Then i need to wait xx minutes before i get it to work again.</p>
<p dir="auto">Do the script open a connection and then not closing it proper so i need to wait for some timeout?</p>
<p dir="auto">Script:</p>
<pre><code>#!/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) &lt; 2:
    print &gt;&gt;sys.stderr, 'Usage: ' + sys.argv[0] + ' &lt;file/host&gt; [&lt;containerId&gt;]'
    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 &lt;= int(n) &lt;= 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());
</code></pre>
]]></description><link>https://forum.netxms.org/topic/3898/nxshell-gives-request-timed-out</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 17:14:01 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/3898.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Jul 2015 06:45:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to nxshell gives Request timed out on Wed, 05 Aug 2015 14:49:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">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?</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/17469</link><guid isPermaLink="true">https://forum.netxms.org/post/17469</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Wed, 05 Aug 2015 14:49:48 GMT</pubDate></item></channel></rss>