Poll the current state of all services.

        Returns:
            dict: A dictionary mapping service name to service status
488399
async def sync_services(self):
        

        services = {}
        servs = await self.list_services()

        for i, serv in enumerate(servs):
            info = await self.service_info(serv)
            status = await self.service_status(serv)
            messages = await self.get_messages(serv)
            headline = await self.get_headline(serv)

            services[serv] = states.ServiceState(info['short_name'], info['long_name'], info['preregistered'], i)
            services[serv].state = status['numeric_status']

            for message in messages:
                services[serv].post_message(message.level, message.message, message.count, message.created)
            if headline is not None:
                services[serv].set_headline(headline.level, headline.message, headline.created)

        return services
1096392
def state(self):
        """"""
        if self._proto.HasField('state'):
            return yamcsManagement_pb2.ServiceState.Name(self._proto.state)
        return None
256315
def available_services():
    
    all_datas = ()
    data = ()

    for class_path in settings.TH_SERVICES:
        class_name = class_path.rsplit('.', 1)[1]
        # 2nd array position contains the name of the service
        data = (class_name, class_name.rsplit('Service', 1)[1])
        all_datas = (data,) + all_datas
    return all_datas
162564
def _connected(service):
    '''
    
    '''
    state = pyconnman.ConnService(os.path.join(SERVICE_PATH, service)).get_property('State')
    return state == 'online' or state == 'ready'
1069803
def get():
    
    livestatus = mk_livestatus()
    hosts = livestatus.get_hosts()
    services = livestatus.get_services()
    result = {}
    result['hosts'] = hosts
    result['services'] = services
    return result
995070
def all_status(self):
        
        laundry_rooms = {}
        for room in self.hall_to_link:
            laundry_rooms[room] = self.parse_a_hall(room)

        return laundry_rooms
507326
def do_status(self):
        
        
        # Get the PID of the service
        pid    = self.pid.get()
        
        # Status color / attributes
        status_color  = 'green' if pid else 'red'
        status_dot    = self._colorize(UNICODE['dot'], status_color, encode=True)
        
        # Active text
        active_txt    = {
            'active':   '{} since {}'.format(self._colorize('active (running)', 'green'), self.pid.birthday()[1]),
            'inactive': 'inactive (dead)'
        }
        
        # Print the status message
        print(status_dot, end=' ')
        print('{}.service - LSB: {}'.format(self.name, self.desc))
        print('   Loaded: loaded (/etc/init.d/{})'.format(self.name))
        print('   Active: {}'.format(active_txt['active' if pid else 'inactive']))
        
        # Extra information if running
        if pid:
            ps = self.pid.ps()
            print('  Process: {}; [{}]'.format(pid, ps[0]))
            if ps[1]:
                for c in ps[1]:
                    print('    Child: {}'.format(c))
        print('')
65355
def get_state_all(self):
        """"""
        state_dict = {}
        for device in self.get_device_names().keys():
            state_dict[device] = self.get_state(device)
        return state_dict
251580
def _remote_status(session, service_id, uuid, url, interval=3):
    """"""
    _LOGGER.info('polling for status')
    resp = session.get(url, params={
        'remoteServiceRequestID':service_id,
        'uuid':uuid
    }).json()
    if resp['status'] == 'SUCCESS':
        return 'completed'
    time.sleep(interval)
    return _remote_status(session, service_id, uuid, url)
13183
def statuses(self):
        
        r_json = self._get_json('status')
        statuses = [Status(self._options, self._session, raw_stat_json)
                    for raw_stat_json in r_json]
        return statuses
78556
def _tot_services_by_state(self, services, state):
        
        return str(sum(1 for s in self.services
                       if services[s].state_id == state))
1344672
def status(ctx, services, show_all):
    """"""
    logger.debug("running command %s (%s)", ctx.command.name, ctx.params,
                 extra={"command": ctx.command.name, "params": ctx.params})

    home = ctx.obj["HOME"]
    services_path = os.path.join(home, SERVICES)

    def print_status(service):
        service_dir = os.path.join(services_path, service)
        if os.path.exists(service_dir):
            pidfile = service_dir + ".pid"
            if os.path.exists(pidfile):
                try:
                    with open(pidfile) as fh:
                        pid = int(fh.read().strip())
                    os.kill(pid, 0)
                    status = "running (pid: {})".format(pid)
                except OSError:
                    status = "not running (stale pidfile)"
            else:
                status = "not running"
        else:
            status = "no such service"
        click.secho("{} - {}".format(service, status))

    if show_all:
        for service in next(os.walk(services_path))[1]:
            print_status(service)
    elif services:
        for service in services:
            print_status(service)
    else:
        raise click.UsageError("You must specify a service name or use --show-all")
361002
def getProcessStatus(self):
        
        info_dict = {}
        cur = self._conn.cursor()
        cur.execute("""SHOW FULL PROCESSLIST;""")
        rows = cur.fetchall()
        if rows:
            for row in rows:
                if row[6] == '':
                    state = 'idle'
                elif row[6] is None:
                    state = 'other'
                else:
                    state = str(row[6]).replace(' ', '_').lower()
                info_dict[state] = info_dict.get(state, 0) + 1
        return info_dict
1049583
def poll(self):
        
        self.set_state(self.STATE_ACTIVE)

        # If we don't have any active consumers, spawn new ones
        if not self.total_process_count:
            LOGGER.debug('Did not find any active consumers in poll')
            return self.check_process_counts()

        # Start our data collection dict
        self.poll_data = {'timestamp': time.time(), 'processes': list()}

        # Iterate through all of the consumers
        for proc in list(self.active_processes()):
            if proc == multiprocessing.current_process():
                continue

            # Send the profile signal
            os.kill(int(proc.pid), signal.SIGPROF)
            self.poll_data['processes'].append(proc.name)

        # Check if we need to start more processes
        self.check_process_counts()
1142982
def get_state(self, hosts, services):
        
        # If we are a host or a service, we just got the host/service
        # hard state
        if self.operand == 'host':
            host = hosts[self.sons[0]]
            return self.get_host_node_state(host.last_hard_state_id,
                                            host.problem_has_been_acknowledged,
                                            host.in_scheduled_downtime)
        if self.operand == 'service':
            service = services[self.sons[0]]
            return self.get_service_node_state(service.last_hard_state_id,
                                               service.problem_has_been_acknowledged,
                                               service.in_scheduled_downtime)
        if self.operand == '|':
            return self.get_complex_or_node_state(hosts, services)

        if self.operand == '&':
            return self.get_complex_and_node_state(hosts, services)

        #  It's an Xof rule
        if self.operand == 'of:':
            return self.get_complex_xof_node_state(hosts, services)

        # We have an unknown node. Code is not reachable because we validate operands
        return 4
689349
def status(self):
        
        status = _HTTP_STATUS_LINES.get(self._status_code)
        return str(status or ('{} Unknown'.format(self._status_code)))
1318506
def status(self, name=''):
        
        logger.warn(
            'Note that `status` is currently not so robust and may break on '
            'different systems')
        init = self._get_implementation(name)
        if name:
            self._assert_service_installed(init, name)
        logger.info('Retrieving status...')
        return init.status(name)