Esempio n. 1
0
def collectAgentsConfig(config, conn):
    cursor = conn.cursor()
    agents = masterdao.findAgentsEnabled(cursor)
    for agent in agents:
        client = agentclient.LogMapperAgentClient(agent['ip'], agent['port'])
        client.open()
        collectDataConfig(config, conn, client)
        client.close()
Esempio n. 2
0
def executeAgentsCommand(conn, command):
    cursor = conn.cursor()
    agents = masterdao.findAgentsEnabled(cursor)
    for agent in agents:
        client = agentclient.LogMapperAgentClient(agent['ip'], agent['port'])
        try: 
            print("Execute in "+str(agent))
            client.open()
            r = client.executeCommand(command)
            #print(r)
            client.close()               
        except Exception as exc:
            print("Exception collecting data from "+str(exc))
Esempio n. 3
0
def collectReadersTraceData(config, conn):
    cursor = conn.cursor()
    agents = masterdao.findAgentsEnabled(cursor)
    for agent in agents:
        client = agentclient.LogMapperAgentClient(agent['ip'], agent['port'])
        client.open()

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_READER)
        for source in sources:
            try:
                collectDataTrace(config, conn, client, source)
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(source))

        client.close()
Esempio n. 4
0
def collectLogRecordsData(config, conn, start, end, interval=5):
    cursor = conn.cursor()
    agents = masterdao.findAgentsEnabled(cursor)
    for agent in agents:
        client = agentclient.LogMapperAgentClient(agent['ip'], agent['port'])
        client.open()

        readers = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_READER)
        for reader in readers:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectLogRecords(config, conn, client, reader, startLoop,
                                      endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(reader))

        client.close()
Esempio n. 5
0
def collectSourcesData(config, conn, start, end, interval=5):
    cursor = conn.cursor()
    agents = masterdao.findAgentsEnabled(cursor)
    for agent in agents:
        client = agentclient.LogMapperAgentClient(agent['ip'], agent['port'])
        client.open()

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_READER)
        for reader in sources:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectDataReader(config, conn, client, reader['name'],
                                      reader['hostId'], reader['componentId'],
                                      startLoop, endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(reader))

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_HOST)
        for source in sources:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectDataMonitor(config, conn, client, source, startLoop,
                                       endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(source))

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_SPRINGMICROSERVICE)
        for source in sources:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectDataMonitor(config, conn, client, source, startLoop,
                                       endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(source))

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_TOMCAT)
        for source in sources:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectDataMonitor(config, conn, client, source, startLoop,
                                       endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(source))

        sources = masterdao.findSourcesByAgentIdAndType(
            cursor, agent['id'], lmkey.SOURCE_TYPE_POSTGRES)
        for source in sources:
            try:
                startLoop = start
                while startLoop < end:
                    endLoop = startLoop + datetime.timedelta(minutes=interval)
                    collectDataMonitor(config, conn, client, source, startLoop,
                                       endLoop)
                    startLoop = endLoop
            except Exception as exc:
                logger.exception("Exception collecting data from " +
                                 str(source))

        client.close()