def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{ip}:8774/v2/{tenant_id}'.format(ip=args.ip, tenant_id=tenant_id) ) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: status_err(str(e)) else: # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): cloud_stats[metric_name]['value'] = \ getattr(stats, vals['stat_name']) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] status_ok() for metric_name in cloud_stats.iterkeys(): metric('cloud_resource_%s' % metric_name, cloud_stats[metric_name]['type'], cloud_stats[metric_name]['value'], cloud_stats[metric_name]['unit'])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ('http://{ip}:8774/v2/{tenant_id}'.format( ip=args.ip, tenant_id=tenant_id)) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: status_err(str(e)) else: # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): cloud_stats[metric_name]['value'] = \ getattr(stats, vals['stat_name']) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] status_ok() for metric_name in cloud_stats.iterkeys(): metric('cloud_resource_%s' % metric_name, cloud_stats[metric_name]['type'], cloud_stats[metric_name]['value'], cloud_stats[metric_name]['unit'])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id nova_version = '.'.join( map(str, get_os_component_major_api_version('nova'))) compute_endpoint = ( '{protocol}://{ip}:{port}/v{api_version}/{tenant_id}'.format( ip=args.ip, tenant_id=tenant_id, protocol=args.protocol, port=args.port, api_version=nova_version ) ) try: if args.ip: nova = get_nova_client(bypass_url=compute_endpoint) else: nova = get_nova_client() is_up = True except exc.ClientException: is_up = False metric_bool('client_success', False, m_name='maas_nova') # Any other exception presumably isn't an API error except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # time something arbitrary start = time.time() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) status_ok(m_name='maas_nova') metric_bool('nova_api_local_status', is_up, m_name='maas_nova') # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_instances_in_state_%s' % status, 'uint32', status_count[status], 'instances')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id compute_endpoint = ( '{protocol}://{ip}:{port}/v2.1/{tenant_id}'.format( ip=args.ip, tenant_id=tenant_id, protocol=args.protocol, port=args.port ) ) try: if args.ip: nova = get_nova_client(bypass_url=compute_endpoint) else: nova = get_nova_client() is_up = True except exc.ClientException: is_up = False metric_bool('client_success', False, m_name='maas_nova') # Any other exception presumably isn't an API error except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # time something arbitrary start = time.time() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) status_ok(m_name='maas_nova') metric_bool('nova_api_local_status', is_up, m_name='maas_nova') # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_instances_in_state_%s' % status, 'uint32', status_count[status], 'instances')
def check(): try: keystone = get_keystone_client(CONFIGS['auth_ref']) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ('http://{ip}:8774/v2/{tenant_id}'.format( ip=CONFIGS['ip'], tenant_id=tenant_id)) try: if CONFIGS['ip']: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: status_err(str(e)) else: # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): cloud_stats[metric_name]['value'] = \ getattr(stats, vals['stat_name']) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] status_ok() for metric_name in cloud_stats.iterkeys(): metric(PLUGIN, 'cloud_resource_%s' % metric_name, cloud_stats[metric_name]['value'], interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) metric_bool(PLUGIN, 'nova_cloud_stats', True, interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) except: metric_bool(PLUGIN, 'nova_cloud_stats', False, interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) raise
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list") # return all the things status_ok() for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric_bool(name, service_is_up)
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) is_up = True except exc.ClientException: 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() nova.services.list() end = time() milliseconds = (end - start) * 1000 # gather some metrics status_count = collections.Counter( [s.status for s in nova.servers.list()]) status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_servers_in_state_%s' % status, 'uint32', status_count[status])
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) is_up = True except exc.ClientException: 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() nova.services.list() end = time() milliseconds = (end - start) * 1000 status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'uint32', '%.3f' % milliseconds, 'ms')
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list") # return all the things status_ok() for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric_bool(name, service_is_up)
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id nova_version = '.'.join( map(str, get_os_component_major_api_version('nova'))) COMPUTE_ENDPOINT = ( '{protocol}://{hostname}:8774/v{version}/{tenant_id}'.format( protocol=args.protocol, hostname=args.hostname, version=nova_version, tenant_id=tenant_id)) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') for nova_service_type in NOVA_SERVICE_TYPE_LIST: metric('%s_status' % nova_service_type, 'string', '%s cannot reach API' % nova_service_type, m_name='maas_nova') status_err_no_exit(str(e), m_name='maas_nova') return else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = "Yes" if service.status.lower() == 'enabled': if service.state.lower() == 'down': service_is_up = "No" elif service.status.lower() == 'disabled': if service.disabled_reason: if 'auto' in service.disabled_reason.lower(): service_is_up = "No" if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric(name, 'string', service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id nova_version = '.'.join( map(str, get_os_component_major_api_version('nova'))) COMPUTE_ENDPOINT = ('{protocol}://{ip}:8774/v{version}/{tenant_id}'.format( ip=args.ip, version=nova_version, tenant_id=tenant_id, protocol=args.protocol)) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): multiplier = 1 if metric_name == 'total_vcpus': multiplier = args.cpu_allocation_ratio elif metric_name == 'total_memory': multiplier = args.mem_allocation_ratio cloud_stats[metric_name]['value'] = \ (getattr(stats, vals['stat_name']) * multiplier) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] status_ok(m_name='maas_nova') for metric_name in cloud_stats.iterkeys(): metric('cloud_resource_%s' % metric_name, cloud_stats[metric_name]['type'], cloud_stats[metric_name]['value'], cloud_stats[metric_name]['unit'])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{ip}:8774/v2/{tenant_id}'.format(ip=args.ip, tenant_id=tenant_id) ) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() is_up = True except exc.ClientException: 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() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_instances_in_state_%s' % status, 'uint32', status_count[status], 'instances')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ('http://{ip}:8774/v2/{tenant_id}'.format( ip=args.ip, tenant_id=tenant_id)) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: status_err(str(e)) else: # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): multiplier = 1 if metric_name == 'total_vcpus': multiplier = args.cpu_allocation_ratio elif metric_name == 'total_memory': multiplier = args.mem_allocation_ratio cloud_stats[metric_name]['value'] = \ (getattr(stats, vals['stat_name']) * multiplier) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] metric_values = dict() status_ok() for metric_name in cloud_stats.iterkeys(): metric('cloud_resource_%s' % metric_name, cloud_stats[metric_name]['type'], cloud_stats[metric_name]['value'], cloud_stats[metric_name]['unit']) metric_values['cloud_resource_%s' % metric_name] = cloud_stats[metric_name]['value'] metric_influx(INFLUX_MEASUREMENT_NAME, metric_values)
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id nova_version = '.'.join( map(str, get_os_component_major_api_version('nova'))) compute_endpoint = ( '{protocol}://{hostname}:{port}/v{version}/{tenant_id}'.format( hostname=args.hostname, tenant_id=tenant_id, protocol=args.protocol, port=args.port, version=nova_version)) try: nova = get_nova_client(auth_token=auth_token, bypass_url=compute_endpoint) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) # replace the first 'nova' so the metric name would be like: # 'ironic-compute_status' # notice 'ironic-conductor' is different than 'nova-conductor' # on ironic-compute box, so we preserve nova-conductor metric if 'conductor' not in name: name = name.replace('nova', 'ironic', 1) metric_bool(name, service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( '{protocol}://{ip}:8774/v2.1/{tenant_id}' .format(ip=args.ip, tenant_id=tenant_id, protocol=args.protocol) ) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # get some cloud stats stats = nova.hypervisor_stats.statistics() cloud_stats = collections.defaultdict(dict) for metric_name, vals in stats_mapping.iteritems(): multiplier = 1 if metric_name == 'total_vcpus': multiplier = args.cpu_allocation_ratio elif metric_name == 'total_memory': multiplier = args.mem_allocation_ratio cloud_stats[metric_name]['value'] = \ (getattr(stats, vals['stat_name']) * multiplier) cloud_stats[metric_name]['unit'] = \ vals['unit'] cloud_stats[metric_name]['type'] = \ vals['type'] status_ok(m_name='maas_nova') for metric_name in cloud_stats.iterkeys(): metric('cloud_resource_%s' % metric_name, cloud_stats[metric_name]['type'], cloud_stats[metric_name]['value'], cloud_stats[metric_name]['unit'])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id compute_endpoint = ( '{protocol}://{hostname}:{port}/v2.1/{tenant_id}'.format( hostname=args.hostname, tenant_id=tenant_id, protocol=args.protocol, port=args.port ) ) try: nova = get_nova_client(auth_token=auth_token, bypass_url=compute_endpoint) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) # replace the first 'nova' so the metric name would be like: # 'ironic-compute_status' # notice 'ironic-conductor' is different than 'nova-conductor' # on ironic-compute box, so we preserve nova-conductor metric if 'conductor' not in name: name = name.replace('nova', 'ironic', 1) metric_bool(name, service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{ip}:8774/v2.1/{tenant_id}' .format(ip=args.ip, tenant_id=tenant_id) ) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() is_up = True except exc.ClientException: 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() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) metric('nova_api', 'nova_api_local_status', str(int(is_up))) # only want to send other metrics if api is up if is_up: metric('nova_api', 'nova_api_local_response_time', '%.3f' % milliseconds) for status in SERVER_STATUSES: metric('nova_api', 'nova_instances_in_state_%s' % status, status_count[status])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( '{protocol}://{hostname}:8774/v2.1/{tenant_id}' .format(protocol=args.protocol, hostname=args.hostname, tenant_id=tenant_id) ) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') for nova_service_type in NOVA_SERVICE_TYPE_LIST: metric('%s_status' % nova_service_type, 'string', '%s cannot reach API' % nova_service_type, m_name='maas_nova') status_err_no_exit(str(e), m_name='maas_nova') return else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = "Yes" if service.status == 'enabled' and service.state == 'down': service_is_up = "No" if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric(name, 'string', service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ('http://{hostname}:8774/v2.1/{tenant_id}'.format( hostname=args.hostname, tenant_id=tenant_id)) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) # replace the first 'nova' so the metric name would be like: # 'ironic-compute_status' # notice 'ironic-conductor' is different than 'nova-conductor' # on ironic-compute box, so we preserve nova-conductor metric if 'conductor' not in name: name = name.replace('nova', 'ironic', 1) metric_bool(name, service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{hostname}:8774/v2.1/{tenant_id}' .format(hostname=args.hostname, tenant_id=tenant_id) ) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: metric_bool('client_success', False, m_name='maas_nova') status_err(str(e), m_name='maas_nova') else: metric_bool('client_success', True, m_name='maas_nova') # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list", m_name='maas_nova') # return all the things status_ok(m_name='maas_nova') for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric_bool(name, service_is_up, m_name='maas_nova')
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) auth_token = keystone.auth_token tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{hostname}:8774/v2/{tenant_id}'.format(hostname=args.hostname, tenant_id=tenant_id) ) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list") # return all the things status_ok() for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) metric_bool(name, service_is_up)
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states services = nova.services.list() # return all the things status_ok() for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False metric_bool('%s_on_host_%s' % (service.binary, service.host), service_is_up)
def check(args): auth_ref = get_auth_ref() auth_token = auth_ref['token']['id'] tenant_id = auth_ref['token']['tenant']['id'] COMPUTE_ENDPOINT = 'http://{hostname}:8774/v2/{tenant_id}' \ .format(hostname=args.hostname, tenant_id=tenant_id) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list") # return all the things status_ok() for service in services: service_is_up = True if service.status == 'enabled' and service.state == 'down': service_is_up = False if args.host: name = '%s_status' % service.binary else: name = '%s_on_host_%s_status' % (service.binary, service.host) name = name.replace(".", "_") metric_bool(name, service_is_up)
def check(args): auth_ref = get_auth_ref() auth_token = auth_ref['token']['id'] tenant_id = auth_ref['token']['tenant']['id'] COMPUTE_ENDPOINT = 'http://{ip}:8774/v2/{tenant_id}' \ .format(ip=args.ip, tenant_id=tenant_id) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) is_up = True except exc.ClientException: 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() nova.services.list() end = time() milliseconds = (end - start) * 1000 # gather some metrics status_count = collections.Counter([ s.status for s in nova.servers.list(search_opts={'all_tenants': 1}) ]) status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_instances_in_state_%s' % status, 'uint32', status_count[status], 'instances')
def check(args): auth_ref = get_auth_ref() auth_token = auth_ref["token"]["id"] tenant_id = auth_ref["token"]["tenant"]["id"] COMPUTE_ENDPOINT = "http://{hostname}:8774/v2/{tenant_id}".format(hostname=args.hostname, tenant_id=tenant_id) try: nova = get_nova_client(auth_token=auth_token, bypass_url=COMPUTE_ENDPOINT) # not gathering api status metric here so catch any exception except Exception as e: status_err(str(e)) # gather nova service states if args.host: services = nova.services.list(host=args.host) else: services = nova.services.list() if len(services) == 0: status_err("No host(s) found in the service list") # return all the things status_ok() for service in services: service_is_up = True if service.status == "enabled" and service.state == "down": service_is_up = False if args.host: name = "%s_status" % service.binary else: name = "%s_on_host_%s_status" % (service.binary, service.host) metric_bool(name, service_is_up)
def check(args): COMPUTE_ENDPOINT = 'http://{ip}:8774/v3'.format(ip=args.ip) try: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) is_up = True except exc.ClientException: 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() nova.services.list() end = time() milliseconds = (end - start) * 1000 # gather some metrics status_count = collections.Counter( [s.status for s in nova.servers.list()] ) status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') for status in SERVER_STATUSES: metric('nova_servers_in_state_%s' % status, 'uint32', status_count[status])
def check(auth_ref, args): keystone = get_keystone_client(auth_ref) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ( 'http://{ip}:8774/v2/{tenant_id}'.format(ip=args.ip, tenant_id=tenant_id) ) try: if args.ip: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) ceilometer = get_ceilometer_client() else: nova = get_nova_client() ceilometer = get_ceilometer_client() is_up = True except exc.ClientException: 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() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 metric_values = dict() servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) for meter_name, fields in NOVA_METERS.iteritems(): # gather ceilometer stats stats = ceilometer.statistics.list(meter_name) # 'trim' the meter name a bit metric_name = "nova_instances_" if "instance" != meter_name: metric_name = metric_name + meter_name.replace(".","_") + "_" for stat in stats: for field in fields: value = getattr(stat, field) metric_values[metric_name + field] = value status_ok() metric_bool('nova_api_local_status', is_up) # only want to send other metrics if api is up if is_up: metric('nova_api_local_response_time', 'double', '%.3f' % milliseconds, 'ms') metric_values['nova_api_local_response_time'] = ("%.3f" % (milliseconds)) for status in SERVER_STATUSES: metric('nova_instances_in_state_%s' % status, 'uint32', status_count[status], 'instances') metric_values[("nova_instances_in_state_%s" % (status))] = status_count[status] metric_influx(INFLUX_MEASUREMENT_NAME, metric_values)
def check(): try: keystone = get_keystone_client(CONFIGS['auth_ref']) tenant_id = keystone.tenant_id COMPUTE_ENDPOINT = ('http://{ip}:8774/v2/{tenant_id}'.format( ip=CONFIGS['ip'], tenant_id=tenant_id)) try: if CONFIGS['ip']: nova = get_nova_client(bypass_url=COMPUTE_ENDPOINT) else: nova = get_nova_client() is_up = True except exc.ClientException: 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() nova.services.list() end = time.time() milliseconds = (end - start) * 1000 servers = nova.servers.list(search_opts={'all_tenants': 1}) # gather some metrics status_count = collections.Counter([s.status for s in servers]) status_ok() metric_bool(PLUGIN, 'nova_api_local_status', is_up, interval=CONFIGS['interval'], 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, 'nova_api_local_response_time', '%.3f' % milliseconds, interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) for status in SERVER_STATUSES: metric(PLUGIN, 'nova_instances_in_state_%s' % status, status_count[status], interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) except: metric_bool(PLUGIN, 'nova_api_local_status', False, interval=CONFIGS['interval'], graphite_host=CONFIGS['graphite_host'], graphite_port=CONFIGS['graphite_port']) raise