temboardagent/plugins/monitoring/__init__.py
def monitoring_collector_worker(config):
    """
    Run probes and push collected metrics in a queue.
    """
    signal.signal(signal.SIGTERM, monitoring_worker_sigterm_handler)
    # convert config dict to namedtuple
    config = collections.namedtuple('__config', ['temboard', 'plugins',
                                                 'postgresql', 'logging'])(
                    temboard=config['temboard'],
                    plugins=config['plugins'],
                    postgresql=config['postgresql'],
                    logging=config['logging']
                )

    logger.debug("Starting collector")

    try:
        system_info = host_info(config.temboard['hostname'])
    except (ValueError, Exception) as e:
        logger.exception(e)
        logger.debug("Failed")
        sys.exit(1)

    # Load the probes to run
    try:
        probes = load_probes(config.plugins['monitoring'],
                             config.temboard['home'])
        config.plugins['monitoring']['conninfo'] = [{
            'host': config.postgresql['host'],
            'port': config.postgresql['port'],
            'user': config.postgresql['user'],
            'database': config.postgresql['dbname'],
            'password': config.postgresql['password'],
            'dbnames': config.plugins['monitoring']['dbnames'],
            'instance': config.postgresql['instance']
        }]

        # Validate connection information from the config, and ensure
        # the instance is available
        instances = []
        for conninfo in config.plugins['monitoring']['conninfo']:
            instances.append(instance_info(conninfo, system_info['hostname']))

        logger.debug("Running probes")
        # Gather the data from probes
        data = run_probes(probes, instances)

        # Prepare and send output
        output = {
            'datetime': now(),
            'hostinfo': system_info,
            'instances': remove_passwords(instances),
            'data': data,
            'version': __VERSION__
        }
        logger.debug(output)
        q = Queue('%s/metrics.q' % (config.temboard['home']),
                  max_size=1024 * 1024 * 10, overflow_mode='slide')
        q.push(Message(content=json.dumps(output)))
        logger.debug("Done")
    except Exception as e:
        logger.exception(e)
        logger.error("Could not collect data")
        sys.exit(1)

    Run probes and push collected metrics in a queue.
    
Run probes and push collected metrics in a queue.
Run probes and push collected metrics in a queue .
def monitoring_collector_worker(config):
    signal.signal(signal.SIGTERM, monitoring_worker_sigterm_handler)
    config = collections.namedtuple('__config', ['temboard', 'plugins',
                                                 'postgresql', 'logging'])(
                    temboard=config['temboard'],
                    plugins=config['plugins'],
                    postgresql=config['postgresql'],
                    logging=config['logging']
                )
    logger.debug("Starting collector")
    try:
        system_info = host_info(config.temboard['hostname'])
    except (ValueError, Exception) as e:
        logger.exception(e)
        logger.debug("Failed")
        sys.exit(1)
    try:
        probes = load_probes(config.plugins['monitoring'],
                             config.temboard['home'])
        config.plugins['monitoring']['conninfo'] = [{
            'host': config.postgresql['host'],
            'port': config.postgresql['port'],
            'user': config.postgresql['user'],
            'database': config.postgresql['dbname'],
            'password': config.postgresql['password'],
            'dbnames': config.plugins['monitoring']['dbnames'],
            'instance': config.postgresql['instance']
        }]
        instances = []
        for conninfo in config.plugins['monitoring']['conninfo']:
            instances.append(instance_info(conninfo, system_info['hostname']))
        logger.debug("Running probes")
        data = run_probes(probes, instances)
        output = {
            'datetime': now(),
            'hostinfo': system_info,
            'instances': remove_passwords(instances),
            'data': data,
            'version': __VERSION__
        }
        logger.debug(output)
        q = Queue('%s/metrics.q' % (config.temboard['home']),
                  max_size=1024 * 1024 * 10, overflow_mode='slide')
        q.push(Message(content=json.dumps(output)))
        logger.debug("Done")
    except Exception as e:
        logger.exception(e)
        logger.error("Could not collect data")
        sys.exit(1)
def monitoring_collector_worker ( config ) : signal . signal ( signal . SIGTERM , monitoring_worker_sigterm_handler ) config = collections . namedtuple ( '__config' , [ 'temboard' , 'plugins' , 'postgresql' , 'logging' ] ) ( temboard = config [ 'temboard' ] , plugins = config [ 'plugins' ] , postgresql = config [ 'postgresql' ] , logging = config [ 'logging' ] ) logger . debug ( "Starting collector" ) try : system_info = host_info ( config . temboard [ 'hostname' ] ) except ( ValueError , Exception ) as e : logger . exception ( e ) logger . debug ( "Failed" ) sys . exit ( 1 ) try : probes = load_probes ( config . plugins [ 'monitoring' ] , config . temboard [ 'home' ] ) config . plugins [ 'monitoring' ] [ 'conninfo' ] = [ { 'host' : config . postgresql [ 'host' ] , 'port' : config . postgresql [ 'port' ] , 'user' : config . postgresql [ 'user' ] , 'database' : config . postgresql [ 'dbname' ] , 'password' : config . postgresql [ 'password' ] , 'dbnames' : config . plugins [ 'monitoring' ] [ 'dbnames' ] , 'instance' : config . postgresql [ 'instance' ] } ] instances = [ ] for conninfo in config . plugins [ 'monitoring' ] [ 'conninfo' ] : instances . append ( instance_info ( conninfo , system_info [ 'hostname' ] ) ) logger . debug ( "Running probes" ) data = run_probes ( probes , instances ) output = { 'datetime' : now ( ) , 'hostinfo' : system_info , 'instances' : remove_passwords ( instances ) , 'data' : data , 'version' : __VERSION__ } logger . debug ( output ) q = Queue ( '%s/metrics.q' % ( config . temboard [ 'home' ] ) , max_size = 1024 * 1024 * 10 , overflow_mode = 'slide' ) q . push ( Message ( content = json . dumps ( output ) ) ) logger . debug ( "Done" ) except Exception as e : logger . exception ( e ) logger . error ( "Could not collect data" ) sys . exit ( 1 )
Run probes and push collected metrics in a queue.
Run probes and push collected metrics in a queue .
"""
    Run probes and push collected metrics in a queue.
    """ # convert config dict to namedtuple # Load the probes to run # Validate connection information from the config, and ensure # the instance is available # Gather the data from probes # Prepare and send output
config