(self, url, service_check_tags, run_check=False)
return r.json()
Hit a given URL and return the parsed json
Hit a given URL and return the parsed json
Hit a given URL and return the parsed json
def get(self, url, service_check_tags, run_check=False):
        """Hit a given URL and return the parsed json"""
        self.log.debug('Fetching CouchDB stats at url: %s', url)

        # Override Accept request header so that failures are not redirected to the Futon web-ui
        request_headers = headers(self.agentConfig)
        request_headers['Accept'] = 'text/json'

        try:
            r = self.http.get(url, headers=request_headers)
            r.raise_for_status()
            if run_check:
                self.service_check(
                    self.SERVICE_CHECK_NAME,
                    AgentCheck.OK,
                    tags=service_check_tags,
                )
        except requests.exceptions.Timeout as e:
            self.service_check(
                self.SERVICE_CHECK_NAME,
                AgentCheck.CRITICAL,
                tags=service_check_tags,
                message="Request timeout: {0}, {1}".format(url, e),
            )
            raise
        except requests.exceptions.HTTPError as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
            raise
        except Exception as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
            raise
        return r.json()
def get ( self , url , service_check_tags , run_check = False ) : self . log . debug ( 'Fetching CouchDB stats at url: %s' , url ) # Override Accept request header so that failures are not redirected to the Futon web-ui request_headers = headers ( self . agentConfig ) request_headers [ 'Accept' ] = 'text/json' try : r = self . http . get ( url , headers = request_headers ) r . raise_for_status ( ) if run_check : self . service_check ( self . SERVICE_CHECK_NAME , AgentCheck . OK , tags = service_check_tags , ) except requests . exceptions . Timeout as e : self . service_check ( self . SERVICE_CHECK_NAME , AgentCheck . CRITICAL , tags = service_check_tags , message = "Request timeout: {0}, {1}" . format ( url , e ) , ) raise except requests . exceptions . HTTPError as e : self . service_check ( self . SERVICE_CHECK_NAME , AgentCheck . CRITICAL , tags = service_check_tags , message = str ( e ) ) raise except Exception as e : self . service_check ( self . SERVICE_CHECK_NAME , AgentCheck . CRITICAL , tags = service_check_tags , message = str ( e ) ) raise return r . json ( )