#NEWLINE# def check( args , auth_details ) : #NEWLINE# #INDENT# if ( auth_details [ 'OS_AUTH_VERSION' ] == '2' ) : #NEWLINE# #INDENT# IDENTITY_ENDPOINT = 'http://{ip}:35357/v2.0' . format ( ip = args . ip ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# IDENTITY_ENDPOINT = 'http://{ip}:35357/v3' . format ( ip = args . ip ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if args . ip : #NEWLINE# #INDENT# keystone = get_keystone_client ( endpoint = IDENTITY_ENDPOINT ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# keystone = get_keystone_client ( ) #NEWLINE# #UNINDENT# is_up = True #NEWLINE# #UNINDENT# except ( exc . HttpServerError , exc . ClientException ) : #NEWLINE# #INDENT# is_up = False #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# status_err ( str ( e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start = time . time ( ) #NEWLINE# keystone . services . list ( ) #NEWLINE# end = time . time ( ) #NEWLINE# milliseconds = ( ( end - start ) * 1000 ) #NEWLINE# if ( auth_details [ 'OS_AUTH_VERSION' ] == '2' ) : #NEWLINE# #INDENT# project_count = len ( keystone . tenants . list ( ) ) #NEWLINE# user_count = len ( keystone . users . list ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# project_count = len ( keystone . projects . list ( ) ) #NEWLINE# user_count = len ( keystone . users . list ( domain = 'Default' ) ) #NEWLINE# #UNINDENT# #UNINDENT# status_ok ( ) #NEWLINE# metric_bool ( 'keystone_api_local_status' , is_up ) #NEWLINE# if is_up : #NEWLINE# #INDENT# metric ( 'keystone_api_local_response_time' , 'double' , ( '%.3f' % milliseconds ) , 'ms' ) #NEWLINE# metric ( 'keystone_user_count' , 'uint32' , project_count , 'users' ) #NEWLINE# metric ( 'keystone_tenant_count' , 'uint32' , project_count , 'tenants' )