Example #1
0
    def _http_check(self, process_name, port):

        self._log('Querying URL http://localips:%s%s for process %s',
                  port, self._config['url'],
                  process_name)

        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)
        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)
        username = self._config.get('username')
        password = self._config.get('password')

        with utils.retry_errors(num_retries, self._log).retry_context(
                self._make_http_request) as retry_http_request:
            res = retry_http_request(
                port, timeout, username=username, password=password)

        self._log('Status contacting URL http://localip:%s%s for process %s: '
                  '%s %s' % (port, self._config['url'], process_name,
                             res.status, res.reason))

        if res.status != httplib.OK:
            raise httplib.HTTPException(
                'Bad HTTP status code: %s' % (res.status,))

        return True
Example #2
0
    def _http_check(self, process_name, port):

        self._log('Querying URL http://%s:%s%s for process %s', LOCALHOST,
                  port, self._config['url'], process_name)

        host_port = '%s:%s' % (
            LOCALHOST,
            port,
        )
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)
        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)

        with utils.retry_errors(num_retries, self._log).retry_context(
                self._make_http_request) as retry_http_request:
            res = retry_http_request(host_port, timeout)

        self._log('Status contacting URL http://%s%s for process %s: '
                  '%s %s' % (host_port, self._config['url'], process_name,
                             res.status, res.reason))

        if res.status != httplib.OK:
            raise httplib.HTTPException('Bad HTTP status code: %s' %
                                        (res.status, ))

        return True
Example #3
0
    def __call__(self, process_spec):

        try:
            process_name = process_spec['name']
            retries_left = self._config.get('num_retries', DEFAULT_RETRIES)
            method_name = self._config.get('method', DEFAULT_METHOD)
            username = self._config.get('username')
            password = self._config.get('password')

            server_url = self._get_server_url(process_name)
            if not server_url:
                return True

            self._log(
                'Querying XML RPC server at %s, method %s for process %s',
                server_url, method_name, process_name)

            with utils.retry_errors(retries_left, self._log).retry_context(
                    self._xmlrpc_check) as retry_xmlrpc_check:

                return retry_xmlrpc_check(process_name,
                                          server_url,
                                          method_name,
                                          username=username,
                                          password=password)
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #4
0
    def __call__(self, process_spec):

        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            with utils.retry_errors(num_retries, self._log).retry_context(
                    self._tcp_check) as retry_tcp_check:
                return retry_tcp_check(process_spec['name'], port, timeout)
        except errors.InvalidPortSpec:
            self._log('ERROR: Could not extract the HTTP port for process '
                      'name %s using port specification %s.',
                      process_spec['name'], self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #5
0
    def __call__(self, process_spec):

        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            with utils.retry_errors(num_retries, self._log).retry_context(
                    self._tcp_check) as retry_tcp_check:
                return retry_tcp_check(process_spec['name'], port, timeout)
        except errors.InvalidPortSpec:
            self._log(
                'ERROR: Could not extract the TCP port for process '
                'name %s using port specification %s.', process_spec['name'],
                self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #6
0
    def __call__(self, process_spec):

        try:
            process_name = process_spec['name']
            retries_left = self._config.get('num_retries', DEFAULT_RETRIES)
            method_name = self._config.get('method', DEFAULT_METHOD)

            server_url = self._get_server_url(process_name)
            if not server_url:
                return True

            self._log('Querying XML RPC server at %s, method %s for process %s',
                      server_url, method_name, process_name)

            with utils.retry_errors(retries_left, self._log).retry_context(
                    self._xmlrpc_check) as retry_xmlrpc_check:

                return retry_xmlrpc_check(process_name, server_url, method_name)
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #7
0
    def _http_check(self, process_name, port):

        self._log('Querying URL http://%s:%s%s for process %s',
                  LOCALHOST, port, self._config['url'],
                  process_name)

        host_port = '%s:%s' % (LOCALHOST, port,)
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)
        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)

        with utils.retry_errors(num_retries, self._log).retry_context(
                self._make_http_request) as retry_http_request:
            res = retry_http_request(host_port, timeout)

        self._log('Status contacting URL http://%s%s for process %s: '
                  '%s %s' % (host_port, self._config['url'], process_name,
                             res.status, res.reason))

        if res.status != httplib.OK:
            raise httplib.HTTPException(
                'Bad HTTP status code: %s' % (res.status,))

        return True