#NEWLINE# def check( auth_ref , args ) : #NEWLINE# #INDENT# keystone = get_keystone_client ( auth_ref ) #NEWLINE# auth_token = keystone . auth_token #NEWLINE# VOLUME_ENDPOINT = 'http://{ip}:8776/v1/{tenant}' . format ( ip = args . ip , tenant = keystone . tenant_id ) #NEWLINE# s = requests . Session ( ) #NEWLINE# s . headers . update ( { #NEWLINE# #INDENT# 'Content-type' : 'application/json' , #NEWLINE# 'x-auth-token' : auth_token , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# vol = s . get ( ( '%s/volumes/detail' % VOLUME_ENDPOINT ) , verify = False , timeout = 10 ) #NEWLINE# milliseconds = ( vol . elapsed . total_seconds ( ) * 1000 ) #NEWLINE# snap = s . get ( ( '%s/snapshots/detail' % VOLUME_ENDPOINT ) , verify = False , timeout = 10 ) #NEWLINE# is_up = ( vol . ok and snap . ok ) #NEWLINE# #UNINDENT# except ( exc . ConnectionError , exc . HTTPError , exc . Timeout ) as e : #NEWLINE# #INDENT# is_up = False #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# status_err ( str ( e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# vol_statuses = [ v [ 'status' ] for v in vol . json ( ) [ 'volumes' ] ] #NEWLINE# vol_status_count = collections . Counter ( vol_statuses ) #NEWLINE# total_vols = len ( vol . json ( ) [ 'volumes' ] ) #NEWLINE# snap_statuses = [ v [ 'status' ] for v in snap . json ( ) [ 'snapshots' ] ] #NEWLINE# snap_status_count = collections . Counter ( snap_statuses ) #NEWLINE# total_snaps = len ( snap . json ( ) [ 'snapshots' ] ) #NEWLINE# #UNINDENT# status_ok ( ) #NEWLINE# metric_bool ( 'cinder_api_local_status' , is_up ) #NEWLINE# if is_up : #NEWLINE# #INDENT# metric ( 'cinder_api_local_response_time' , 'double' , ( '%.3f' % milliseconds ) , 'ms' ) #NEWLINE# metric ( 'total_cinder_volumes' , 'uint32' , total_vols , 'volumes' ) #NEWLINE# for status in VOLUME_STATUSES : #NEWLINE# #INDENT# metric ( ( 'cinder_%s_volumes' % status ) , 'uint32' , vol_status_count [ status ] , 'volumes' ) #NEWLINE# #UNINDENT# metric ( 'total_cinder_snapshots' , 'uint32' , total_snaps , 'snapshots' ) #NEWLINE# for status in VOLUME_STATUSES : #NEWLINE# #INDENT# metric ( ( 'cinder_%s_snaps' % status ) , 'uint32' , snap_status_count [ status ] , 'snapshots' )