Returns health information on transport & Redis connections.
970649
def get_health(self, consumers=2, messages=100):
        
        data = {'consumers': consumers, 'messages': messages}

        try:
            self._request('GET', '/health', data=json.dumps(data))
            return True
        except SensuAPIException:
            return False
832731
def _get_redis_connection():
    
    url = current_app.config.get('REDIS_URL', 'redis://localhost:6379')
    return redis.from_url(url, decode_responses=True)
745572
def get_connection(self, host, port, db):
        
        return redis.StrictRedis(
            host=host,
            port=port,
            db=db,
            decode_responses=True
        )
707425
def get_redis_info():
    """"""
    from kombu.utils.url import _parse_url as parse_redis_url
    from redis import (
        StrictRedis,
        ConnectionError as RedisConnectionError,
        ResponseError as RedisResponseError,
    )
    for conf_name in ('REDIS_URL', 'BROKER_URL', 'CELERY_BROKER_URL'):
        if hasattr(settings, conf_name):
            url = getattr(settings, conf_name)
            if url.startswith('redis://'):
                break
    else:
        log.error("No redis connection info found in settings.")
        return {"status": NO_CONFIG}
    _, host, port, _, password, database, _ = parse_redis_url(url)

    start = datetime.now()
    try:
        rdb = StrictRedis(
            host=host, port=port, db=database,
            password=password, socket_timeout=TIMEOUT_SECONDS,
        )
        info = rdb.info()
    except (RedisConnectionError, TypeError) as ex:
        log.error("Error making Redis connection: %s", ex.args)
        return {"status": DOWN}
    except RedisResponseError as ex:
        log.error("Bad Redis response: %s", ex.args)
        return {"status": DOWN, "message": "auth error"}
    micro = (datetime.now() - start).microseconds
    del rdb  # the redis package does not support Redis's QUIT.
    ret = {
        "status": UP, "response_microseconds": micro,
    }
    fields = ("uptime_in_seconds", "used_memory", "used_memory_peak")
    ret.update({x: info[x] for x in fields})
    return ret
269442
def get_connection(name='default', use_strict_redis=False):
    
    from .settings import QUEUES
    return get_redis_connection(QUEUES[name], use_strict_redis)
897778
def connection_made(self, transport):
        """"""
        self._transport = transport
        self._raw_transport = transport
        if isinstance(transport, asyncio.SubprocessTransport):
            self._transport = transport.get_pipe_transport(0)
60093
def get_service_health(service_id: str) -> str:
        
        # Check if the current and actual replica levels are the same
        if DC.get_replicas(service_id) != DC.get_actual_replica(service_id):
            health_status = "Unhealthy"
        else:
            health_status = "Healthy"

        return health_status
816799
def get_transports():
        
        LOGGER.debug("TransportService.get_transports")
        params = SessionService.complete_transactional_req(None)
        if params is None:
            if MappingService.driver_type != DriverFactory.DRIVER_REST:
                params = {'OPERATION': 'getTransports'}
                args = {'properties': params}
            else:
                args = {'http_operation': 'GET', 'operation_path': ''}
        else:
            if MappingService.driver_type != DriverFactory.DRIVER_REST:
                params['OPERATION'] = 'getTransports'
                args = {'properties': params}
            else:
                args = {'http_operation': 'GET', 'operation_path': '', 'parameters': params}

        response = TransportService.requester.call(args)

        if MappingService.driver_type != DriverFactory.DRIVER_REST:
            response = response.get()

        ret = None
        if response.rc == 0:
            ret = []
            for transport in response.response_content['transports']:
                ret.append(Transport.json_2_transport(transport))
        elif response.rc != 404:
            err_msg = 'TransportService.get_transports - Problem while getting transports. ' \
                      'Reason: ' + str(response.response_content) + ' - ' + str(response.error_message) + \
                      " (" + str(response.rc) + ")"
            LOGGER.warning(err_msg)
            if response.rc == 500 and ArianeMappingOverloadError.ERROR_MSG in response.error_message:
                raise ArianeMappingOverloadError("Transport.get_transports",
                                                 ArianeMappingOverloadError.ERROR_MSG)
            # traceback.print_stack()
        return ret
1190430
def get_transport(name):
    '''
    
    '''
    try:
        log.debug('Using %s as transport', name)
        return TRANSPORT_LOOKUP[name]
    except KeyError:
        msg = 'Transport {} is not available. Are the dependencies installed?'.format(name)
        log.error(msg, exc_info=True)
        raise InvalidTransportException(msg)
1282647
def get_known_transports():
    """"""
    if not hasattr(get_known_transports, "cache"):
        setattr(
            get_known_transports,
            "cache",
            {
                e.name: e.load()
                for e in pkg_resources.iter_entry_points("workflows.transport")
            },
        )
    return get_known_transports.cache.copy()
886707
def get_services_health(self) -> dict:
        
        # Initialise
        services_health = {}

        # Get Service IDs
        services_ids = self._get_services()

        for service_id in services_ids:
            service_name = DC.get_service_name(service_id)

            # Check if the current and actual replica levels are the same
            if DC.get_replicas(service_id) != \
                    DC.get_actual_replica(service_id):
                services_health[service_name] = "Unhealthy"
            else:
                services_health[service_name] = "Healthy"

        return services_health
382644
def to_dict(self):
        
        # evaluate checks
        checks = {
            key: HealthResult.evaluate(func, self.graph)
            for key, func in self.checks.items()
        }
        dct = dict(
            # return the service name helps for routing debugging
            name=self.name,
            ok=all(checks.values()),
        )
        if checks:
            dct["checks"] = {
                key: checks[key].to_dict()
                for key in sorted(checks.keys())
            }
        return dct
511231
def get_trips(self, authentication_info, start, end):
        """"""
        import requests

        if (authentication_info is None or
            not authentication_info.is_valid()):
            return []

        data_url = "https://api.ritassist.nl/api/trips/GetTrips"
        query = f"?equipmentId={self.identifier}&from={start}&to={end}&extendedInfo=True"
        header = authentication_info.create_header()
        response = requests.get(data_url + query, headers=header)
        trips = response.json()

        result = []
        for trip_json in trips:
            trip = Trip(trip_json)
            result.append(trip)
        return result
1326137
def health_check(self):
        """"""
        logger.debug('Health Check on file for: {namespace}'.format(
            namespace=self.namespace
        ))

        return os.path.isfile(self.data_file)
411405
def health_check(self):
        
        # check as Troubleshooting & Support Tools Plugin
        response = self.get('rest/troubleshooting/1.0/check/')
        if not response:
            # check as support tools
            response = self.get('rest/supportHealthCheck/1.0/check/')
        return response
677650
def connected_svcports(self):
        '''

        '''
        return [p for p in self.ports \
                if p.__class__.__name__ == 'CorbaPort' and p.is_connected]
619655
def get_health_check(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    retries = 30

    while True:
        try:
            lb = conn.get_all_load_balancers(load_balancer_names=[name])
            lb = lb[0]
            ret = odict.OrderedDict()
            hc = lb.health_check
            ret['interval'] = hc.interval
            ret['target'] = hc.target
            ret['healthy_threshold'] = hc.healthy_threshold
            ret['timeout'] = hc.timeout
            ret['unhealthy_threshold'] = hc.unhealthy_threshold
            return ret
        except boto.exception.BotoServerError as e:
            if retries and e.code == 'Throttling':
                log.debug('Throttled by AWS API, will retry in 5 seconds.')
                time.sleep(5)
                retries -= 1
                continue
            log.error('ELB %s not found.', name,
                      exc_info_on_logleve=logging.DEBUG)
            return {}