#NEWLINE# def check( self , instance ) : #NEWLINE# #INDENT# if ( 'url' not in instance ) : #NEWLINE# #INDENT# raise Exception ( 'Marathon instance missing "url" value.' ) #NEWLINE# #UNINDENT# url = instance [ 'url' ] #NEWLINE# user = instance . get ( 'user' ) #NEWLINE# password = instance . get ( 'password' ) #NEWLINE# if ( ( user is not None ) and ( password is not None ) ) : #NEWLINE# #INDENT# auth = ( user , password ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# auth = None #NEWLINE# #UNINDENT# instance_tags = instance . get ( 'tags' , [ ] ) #NEWLINE# default_timeout = self . init_config . get ( 'default_timeout' , self . DEFAULT_TIMEOUT ) #NEWLINE# timeout = float ( instance . get ( 'timeout' , default_timeout ) ) #NEWLINE# response = self . get_json ( urljoin ( url , '/v2/apps' ) , timeout , auth ) #NEWLINE# if ( response is not None ) : #NEWLINE# #INDENT# self . gauge ( 'marathon.apps' , len ( response [ 'apps' ] ) , tags = instance_tags ) #NEWLINE# for app in response [ 'apps' ] : #NEWLINE# #INDENT# tags = ( [ ( 'app_id:' + app [ 'id' ] ) , ( 'version:' + app [ 'version' ] ) ] + instance_tags ) #NEWLINE# for attr in self . APP_METRICS : #NEWLINE# #INDENT# if ( attr in app ) : #NEWLINE# #INDENT# self . gauge ( ( 'marathon.' + attr ) , app [ attr ] , tags = tags ) #NEWLINE# #UNINDENT# #UNINDENT# query_url = urljoin ( url , '/v2/apps/{0}/versions' . format ( app [ 'id' ] ) ) #NEWLINE# versions_reply = self . get_json ( query_url , timeout , auth ) #NEWLINE# if ( versions_reply is not None ) : #NEWLINE# #INDENT# self . gauge ( 'marathon.versions' , len ( versions_reply [ 'versions' ] ) , tags = tags )