nova_api_metadata_local_check.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:rca-evaluation 作者: sieve-microservices 项目源码 文件源码
def check(args):
    metadata_endpoint = ('http://{ip}:8775'.format(ip=args.ip))
    is_up = True

    s = requests.Session()

    try:
        # looks like we can only get / (ec2 versions) without specifying
        # an instance ID and other headers
        versions = s.get('%s/' % metadata_endpoint,
                         verify=False,
                         timeout=10)
        milliseconds = versions.elapsed.total_seconds() * 1000
        if not versions.ok or '1.0' not in versions.content.splitlines():
            is_up = False
    except (exc.ConnectionError, exc.HTTPError, exc.Timeout) as e:
        is_up = False
    except Exception as e:
        status_err(str(e))

    metric_values = dict()

    status_ok()
    metric_bool('nova_api_metadata_local_status', is_up)
    # only want to send other metrics if api is up
    if is_up:
        metric('nova_api_metadata_local_response_time',
               'double',
               '%.3f' % milliseconds,
               'ms')

        metric_values['nova_api_metadata_local_response_time'] = ('%.3f' % milliseconds)
        metric_influx(INFLUX_MEASUREMENT_NAME, metric_values)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号