Ejemplo n.º 1
0
    
if len(sys.argv)>2:
    port=int(sys.argv[2])
else:
    port=config().getint("Network","startServerPort")

if len(sys.argv)>3:
    length=int(sys.argv[3])
else:
    length=config().getint("Network","nrServerPorts")


addreses=machines.split(',')

for a in addreses:
    for host in IP(a):
        try:
            name,alias,rest =socket.gethostbyaddr(str(host))
        except socket.herror,reason:
            # no name for the host
            name="unknown" 
             

        print str(host),name,
        
        result=checkFoamServers(str(host),port,length)
        if result!=None:
            print result
        else:
            print
    def run(self):
        self.parent.startupLock.acquire()
        foamLogger("server").info("Collector starting")

        if DO_WEBSYNC:
            foamLogger("server").info("Get Processes from Webserver")
            try:
                webserver = ServerProxy(WEBSERVER_RPCURL)
                for ip,port,pid in webserver.running_processes():
                    port = int(port)
                    try:
                        server=getServerProxy(ip,port)
                        pid=server.pid()  # occasional errors with 'Connection refused'
                        self.parent._registerServer(ip,pid,port,sync=False)
                    except:
                        foamLogger("server").error("Unknown exception "+str(sys.exc_info()[0])+" while registering %s:%s" % (ip, port))
                        foamLogger("server").error("Reason:"+str(sys.exc_info()[1]))
                        foamLogger("server").error("Trace:"+str(extract_tb(sys.exc_info()[2])))
            except:
                foamLogger("server").warning("Unknown exception "+str(sys.exc_info()[0])+" while syncing with webserver %s" % (WEBSERVER_RPCURL))

        port=config().getint("Network","startServerPort")
        length=config().getint("Network","nrServerPorts")

        machines=config().get("Metaserver","searchservers")

        addreses=machines.split(',')
        if self.additional!=None:
            addreses=self.additional.split(',')+addreses

        for a in addreses:
            foamLogger("server").info("Collecting in subnet "+a)
            for host in IP(a):
                try:
                    name,alias,rest =socket.gethostbyaddr(str(host))
                except socket.herror as reason:
                    # no name for the host
                    name="unknown"

                foamLogger("server").debug("Collector Checking:"+str(host)+" "+name)

                result=None
                try:
                    result=checkFoamServers(str(host),port,length)
                except:
                    foamLogger("server").error("Unknown exception "+str(sys.exc_info()[0])+" while checking for new servers"+str((str(host),port,length)))
                    foamLogger("server").error("Reason:"+str(sys.exc_info()[1]))
                    foamLogger("server").error("Trace:"+str(extract_tb(sys.exc_info()[2])))

                if result!=None:
                    foamLogger("server").debug("Collector Found "+str(result)+" for "+name)
                    for p in result:
                        try:
                            server=getServerProxy(str(host),p)
                            ip=server.ip()
                            pid=server.pid()
                            self.parent._registerServer(ip,pid,p)
                        except:
                            foamLogger("server").error("Unknown exception "+str(sys.exc_info()[0])+" while registering "+name)
                            foamLogger("server").error("Reason:"+str(sys.exc_info()[1]))
                            foamLogger("server").error("Trace:"+str(extract_tb(sys.exc_info()[2])))
                else:
                    foamLogger("server").debug("Collector Found "+str(result)+" for "+name)

        self.parent.startupLock.release()

        foamLogger("server").info("Collector finished")
Ejemplo n.º 3
0
else:
    machines = config().get("Network", "searchservers")

if len(sys.argv) > 2:
    port = int(sys.argv[2])
else:
    port = config().getint("Network", "startServerPort")

if len(sys.argv) > 3:
    length = int(sys.argv[3])
else:
    length = config().getint("Network", "nrServerPorts")

addreses = machines.split(',')

for a in addreses:
    for host in IP(a):
        try:
            name, alias, rest = socket.gethostbyaddr(str(host))
        except socket.herror, reason:
            # no name for the host
            name = "unknown"

        print str(host), name,

        result = checkFoamServers(str(host), port, length)
        if result != None:
            print result
        else:
            print