def check(auth_ref, args):
    GLANCE_ENDPOINT = ('http://{ip}:9292/v1'.format(ip=args.ip))

    try:
        if args.ip:
            glance = get_glance_client(endpoint=GLANCE_ENDPOINT)
        else:
            glance = get_glance_client()

        is_up = True
    except exc.HTTPException:
        is_up = False
    # Any other exception presumably isn't an API error
    except Exception as e:
        status_err(str(e))
    else:
        # time something arbitrary
        start = time.time()
        glance.images.list(search_opts={'all_tenants': 1})
        end = time.time()
        milliseconds = (end - start) * 1000
        # gather some metrics
        images = glance.images.list(search_opts={'all_tenants': 1})
        status_count = collections.Counter([s.status for s in images])

    status_ok()
    metric_bool('glance_api_local_status', is_up)

    # only want to send other metrics if api is up
    if is_up:
        metric('glance_api_local_response_time', 'double',
               '%.3f' % milliseconds, 'ms')
        for status in IMAGE_STATUSES:
            metric('glance_%s_images' % status, 'uint32', status_count[status],
                   'images')
示例#2
0
def check():
    try:
        GLANCE_ENDPOINT = ('http://{ip}:9292/v1'.format(ip=CONFIGS['ip']))

        try:
            if CONFIGS['ip']:
                glance = get_glance_client(endpoint=GLANCE_ENDPOINT)
            else:
                glance = get_glance_client()

            is_up = True
        except exc.HTTPException:
            is_up = False
        # Any other exception presumably isn't an API error
        except Exception as e:
            status_err(str(e))
        else:
            # time something arbitrary
            start = time.time()
            glance.images.list(search_opts={'all_tenants': 1})
            end = time.time()
            milliseconds = (end - start) * 1000
            # gather some metrics
            images = glance.images.list(search_opts={'all_tenants': 1})
            status_count = collections.Counter([s.status for s in images])

        status_ok()
        metric_bool(PLUGIN,
                    'glance_api_local_status',
                    is_up,
                    graphite_host=CONFIGS['graphite_host'],
                    graphite_port=CONFIGS['graphite_port'])

        # only want to send other metrics if api is up
        if is_up:
            metric(PLUGIN,
                   'glance_api_local_response_time',
                   '%.3f' % milliseconds,
                   graphite_host=CONFIGS['graphite_host'],
                   graphite_port=CONFIGS['graphite_port'])
            for status in IMAGE_STATUSES:
                metric(PLUGIN,
                       'glance_%s_images' % status,
                       status_count[status],
                       graphite_host=CONFIGS['graphite_host'],
                       graphite_port=CONFIGS['graphite_port'])
    except:
        metric_bool(PLUGIN,
                    'glance_api_local_status',
                    False,
                    graphite_host=CONFIGS['graphite_host'],
                    graphite_port=CONFIGS['graphite_port'])
        raise
def check(auth_ref, args):
    glance_api_version = get_glance_api_version()
    glance_endpoint = (
        '{protocol}://{ip}:{port}/v{version}'.format(
            ip=args.ip,
            protocol=args.protocol,
            port=args.port,
            version=glance_api_version
        )
    )

    try:
        if args.ip:
            glance = get_glance_client(endpoint=glance_endpoint,
                                       glance_api_version=glance_api_version)
        else:
            glance = get_glance_client(glance_api_version=glance_api_version)

        is_up = True
    except exc.HTTPException:
        is_up = False
        metric_bool('client_success', False, m_name='maas_glance')
    # Any other exception presumably isn't an API error
    except Exception as e:
        metric_bool('client_success', False, m_name='maas_glance')
        status_err(str(e), m_name='maas_glance')
    else:
        metric_bool('client_success', True, m_name='maas_glance')
        # time something arbitrary
        start = time.time()
        glance.images.list(search_opts={'all_tenants': 1})
        end = time.time()
        milliseconds = (end - start) * 1000
        # gather some metrics
        images = glance.images.list(search_opts={'all_tenants': 1})
        status_count = collections.Counter([s.status for s in images])

    status_ok(m_name='maas_glance')
    metric_bool('glance_api_local_status', is_up, m_name='maas_glance')

    # only want to send other metrics if api is up
    if is_up:
        metric('glance_api_local_response_time',
               'double',
               '%.3f' % milliseconds,
               'ms')
        for status in IMAGE_STATUSES:
            metric('glance_%s_images' % status,
                   'uint32',
                   status_count[status],
                   'images')
示例#4
0
def check(auth_ref, args):
    glance_api_version = get_glance_api_version()
    glance_endpoint = (
        '{protocol}://{ip}:{port}/v{version}'.format(
            ip=args.ip,
            protocol=args.protocol,
            port=args.port,
            version=glance_api_version
        )
    )

    try:
        if args.ip:
            glance = get_glance_client(endpoint=glance_endpoint)
        else:
            glance = get_glance_client()

        is_up = True
    except exc.HTTPException:
        is_up = False
        metric_bool('client_success', False, m_name='maas_glance')
    # Any other exception presumably isn't an API error
    except Exception as e:
        metric_bool('client_success', False, m_name='maas_glance')
        status_err(str(e), m_name='maas_glance')
    else:
        metric_bool('client_success', True, m_name='maas_glance')
        # time something arbitrary
        start = time.time()
        glance.images.list(search_opts={'all_tenants': 1})
        end = time.time()
        milliseconds = (end - start) * 1000
        # gather some metrics
        images = glance.images.list(search_opts={'all_tenants': 1})
        status_count = collections.Counter([s.status for s in images])

    status_ok(m_name='maas_glance')
    metric_bool('glance_api_local_status', is_up, m_name='maas_glance')

    # only want to send other metrics if api is up
    if is_up:
        metric('glance_api_local_response_time',
               'double',
               '%.3f' % milliseconds,
               'ms')
        for status in IMAGE_STATUSES:
            metric('glance_%s_images' % status,
                   'uint32',
                   status_count[status],
                   'images')
def check(auth_ref, args):
    GLANCE_ENDPOINT = (
        'http://{ip}:9292/v1'.format(ip=args.ip)
    )

    try:
        if args.ip:
            glance = get_glance_client(endpoint=GLANCE_ENDPOINT)
        else:
            glance = get_glance_client()

        is_up = True
    except exc.HTTPException:
        is_up = False
    # Any other exception presumably isn't an API error
    except Exception as e:
        status_err(str(e))
    else:
        # time something arbitrary
        start = time.time()
        glance.images.list(search_opts={'all_tenants': 1})
        end = time.time()
        milliseconds = (end - start) * 1000
        # gather some metrics
        images = glance.images.list(search_opts={'all_tenants': 1})
        status_count = collections.Counter([s.status for s in images])

    status_ok()
    metric_bool('glance_api_local_status', is_up)

    # only want to send other metrics if api is up
    if is_up:
        metric('glance_api_local_response_time',
               'double',
               '%.3f' % milliseconds,
               'ms')
        for status in IMAGE_STATUSES:
            metric('glance_%s_images' % status,
                   'uint32',
                   status_count[status],
                   'images')