コード例 #1
0
def getLogPaths(readerConfig):
    """
    Get paths
    """
    logger.info('getLogPaths')
    connDbBase = db.connectDbOnlyRead(readerConfig.dbBasePath)
    cursor = connDbBase.cursor()

    cursor.execute("""
    SELECT  id, node1_id, node2_id
    FROM lmp_logPathsT  
    """)
    rows = cursor.fetchall()

    #agrega una columna con el key+el id
    #    rows2 = list(map(lambda row: row + ( (readerKey+'_'+str(row[0])), (readerKey+'_'+str(row[1])), (readerKey+'_'+str(row[2])) ), rows))
    #elimina la primeras 2 columnas
    #    rows3 = list(map(lambda row: row[3:], rows2))

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'logPaths': rows
    }

    connDbBase.close()
    return data
コード例 #2
0
def getLogEventsWithRemoteCall(readerConfig, start, end):
    """
    Get event count 
    """
    logger.info('getLogEventsWithRemoteCall: ' + str(start) + " - " + str(end))

    connDbEvents = db.connectDbOnlyRead(readerConfig.dbEventsPath)
    cursor = connDbEvents.cursor()

    cursor.execute(
        """
    SELECT exectime, logNode_id, remoteCallKey, userKey
    FROM lmp_logEventsT 
    WHERE remoteCallKey IS NOT NULL AND path_id IS NOT NULL
    AND exectime  BETWEEN ? AND ?
    """, (start, end))
    rows = cursor.fetchall()

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'logRecords': rows
    }
    cursor.close()
    connDbEvents.close()
    return data
コード例 #3
0
def getMonitorTomcatMeasures(monitorConfig, start, end):
    """
    Get paths
    """
    logger.info('getMonitorTomcatMeasures: ' + str(start) + " - " + str(end))
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()

    measures = []
    while start < end:
        endLoop = start + datetime.timedelta(minutes=lmutil.PERIOD)
        cursor.execute(
            """
           SELECT 
           MAX(memused), MAX(threads), MAX(threadsBusy), MAX(workers),
           COUNT(fail)                 
           FROM lmp_monitor_tomcat_dataT 
           WHERE exectime  BETWEEN ? AND ?
        """, (start, endLoop))
        measure = cursor.fetchone()
        if measure[0]:
            measures.append((str(start), ) + measure)
        start = endLoop
    connDbMonitor.close()
    return measures
コード例 #4
0
def getMonitorHostMeasures(monitorConfig, start, end):
    """
    Get paths
    """
    logger.info('getMonitorHostMeasures: ' + str(start) + " - " + str(end))
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()

    measures = []
    while start < end:
        endLoop = start + datetime.timedelta(minutes=lmutil.PERIOD)
        cursor.execute(
            """
           SELECT MAX(cpu), max(cpu_user), MAX(cpu_sys), MIN(cpu_idle), 
           MAX(mem), MAX(swap), MAX(diskusage), MAX(pids), MAX(cnxs), MAX(users),
           MAX(disk_io_rate_w), MAX(disk_io_rate_r), 
           MAX(net_io_rate_r), MAX(net_io_rate_s),
           MAX(openfiles), max(openfiles_rate),
           SUM(net_err_rate_in), SUM(net_err_rate_out),
           SUM(net_drop_rate_in), SUM(net_drop_rate_out)                  
           FROM lmp_monitor_host_dataT 
           WHERE exectime  BETWEEN ? AND ?
        """, (start, endLoop))
        measure = cursor.fetchone()
        if measure[0]:
            measures.append((str(start), ) + measure)
        start = endLoop
    connDbMonitor.close()
    return measures
コード例 #5
0
def getLogNodesByCategory(readerConfig, category):
    """
    Get logNodes
    """
    logger.info('getLogNodesByCategory:' + str(category))
    connDbBase = db.connectDbOnlyRead(readerConfig.dbBasePath)
    cursor = connDbBase.cursor()

    cursor.execute(
        """
    SELECT 
    id, key, component, className, method, lineNumber, logLevel, text, category
    FROM lmp_logNodesT 
    WHERE
    category = ?   
    """, (category.value, ))
    rows = cursor.fetchall()

    #agrega una columna con el key+el id
    #    rows2 = list(map(lambda row: row + ( (readerKey+'_'+str(row[0])), ), rows))
    #elimina la primera columna
    #    rows3 = list(map(lambda row: row[1:], rows2))

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'logNodes': rows
    }

    connDbBase.close()
    return data
コード例 #6
0
def getLogNodesByCategoryTrace(readerConfig):
    """
    Get logNodes
    """
    logger.info('getLogNodesByCategory')
    connDbBase = db.connectDbOnlyRead(readerConfig.dbBasePath)
    cursor = connDbBase.cursor()

    cat1 = cat.LogEventCategories.TRACE_MAIN_NODE

    cursor.execute(
        """
    SELECT 
    id, replace( key, '>>', '' ) as key, 
	component, className, method, lineNumber, logLevel, 
    replace( text, '>>', '' ) as text, 
    category
    FROM lmp_logNodesT 
    WHERE
    category = ?
    """, (cat1.value, ))
    rows = cursor.fetchall()

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'logItems': rows
    }

    connDbBase.close()
    return data
コード例 #7
0
def getMonitorPostgresColnames(monitorConfig):
    """
    Get paths
    """
    logger.info('getMonitorPostgresColnames: ')
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()

    cursor.execute("""
       SELECT MAX(conns), MAX(locks), 
       COUNT(fail)                 
       FROM lmp_monitor_postgres_dataT 
       LIMIT 1
    """)
    colnames = formatColnames(list(map(lambda x: x[0], cursor.description)), 1)
    connDbMonitor.close()
    return colnames
コード例 #8
0
def getMonitorTomcatColnames(monitorConfig):
    """
    Get paths
    """
    logger.info('getMonitorTomcatColnames:')
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()

    cursor.execute("""
       SELECT 
       MAX(memused), MAX(threads), MAX(threadsBusy), MAX(workers),
       COUNT(fail)                 
       FROM lmp_monitor_tomcat_dataT 
       LIMIT 1
    """)
    colnames = formatColnames(list(map(lambda x: x[0], cursor.description)), 1)
    connDbMonitor.close()
    return colnames
コード例 #9
0
def getMonitorMicroserviceColnames(monitorConfig):
    """
    Get paths
    """
    logger.info('getMonitorMicroserviceColnames:')
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()

    cursor.execute("""
       SELECT MAX(memused), MAX(heapused), MAX(nonheapused), 
       MAX(threads), MAX(classes), MAX(sessions), MAX(dsconn),
       COUNT(fail)                 
       FROM lmp_monitor_microservice_dataT 
       LIMIT 1
    """)
    colnames = formatColnames(list(map(lambda x: x[0], cursor.description)), 1)
    connDbMonitor.close()
    return colnames
コード例 #10
0
def getMonitorHostColnames(monitorConfig):
    """
    Get paths
    """
    logger.info('getMonitorHostColnames:')
    connDbMonitor = db.connectDbOnlyRead(monitorConfig.dbMonitorPath)
    cursor = connDbMonitor.cursor()
    cursor.execute("""
       SELECT MAX(cpu), max(cpu_user), MAX(cpu_sys), MIN(cpu_idle), 
       MAX(mem), MAX(swap), MAX(diskusage), MAX(pids), MAX(cnxs), MAX(users),
       MAX(disk_io_rate_w), MAX(disk_io_rate_r), 
       MAX(net_io_rate_r), MAX(net_io_rate_s),
       MAX(openfiles), max(openfiles_rate),
       SUM(net_err_rate_in), SUM(net_err_rate_out),
       SUM(net_drop_rate_in), SUM(net_drop_rate_out)                  
       FROM lmp_monitor_host_dataT 
       LIMIT 1
    """)
    colnames = formatColnames(list(map(lambda x: x[0], cursor.description)), 1)
    connDbMonitor.close()
    return colnames
コード例 #11
0
def getJsonLogMetrics(readerConfig, start, end):
    """
    Get event count 
    """
    logger.info('getJsonLogMetrics: ' + str(start) + " - " + str(end))

    connDbData = db.connectDbOnlyRead(readerConfig.dbDataPath)
    cursor = connDbData.cursor()
    cursor.execute("SELECT * from lmp_logmetricsT WHERE date BETWEEN ? AND ?",
                   (start, end))
    metrics = cursor.fetchall()
    connDbData.close()

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'datatype': lmkey.DATATYPE_LOG_METRICS,
        'metrics': metrics
    }
    return data
コード例 #12
0
def getJsonPathMeasures(readerConfig, start, end):
    """
    Get paths measurements
    """
    logger.info('getJsonPathMeasures: ' + str(start) + " - " + str(end))

    connDbData = db.connectDbOnlyRead(readerConfig.dbDataPath)
    cursor = connDbData.cursor()
    cursor.execute(
        "SELECT * from lmp_paths_measuresT WHERE date BETWEEN ? AND ?",
        (start, end))
    measures = cursor.fetchall()
    connDbData.close()

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'pathMeasures': measures
    }
    return data
コード例 #13
0
def getJsonLogColnames(readerConfig):
    """
    Get event count 
    """
    logger.info('getJsonLogColnames: ')

    connDbData = db.connectDbOnlyRead(readerConfig.dbDataPath)
    cursor = connDbData.cursor()
    cursor.execute("SELECT * from lmp_logmetricsT LIMIT 1")
    colnames = formatColnames(list(map(lambda x: x[0], cursor.description)), 0)
    colnames = colnames[2:]  # drop colums 1 y 2: id and date

    connDbData.close()

    data = {
        'readerKey': readerConfig.key,
        'component': readerConfig.component,
        'host': readerConfig.hostname,
        'datatype': lmkey.DATATYPE_LOG_METRICS,
        'colnames': colnames
    }
    return data