Get stats from Glances server.

        Return the client/server connection status:
        - Connected: Connection OK
        - Disconnected: Connection NOK
345888
def update_glances(self):
        
        # Update the stats
        try:
            server_stats = json.loads(self.client.getAll())
        except socket.error:
            # Client cannot get server stats
            return "Disconnected"
        except Fault:
            # Client cannot get server stats (issue #375)
            return "Disconnected"
        else:
            # Put it in the internal dict
            self.stats.update(server_stats)
            return "Connected"
1081278
def poll(self):
        
        #print len(self.connections)
        ## Build a list of connections to test for receive data pending
        recv_list = [self.server_fileno]    # always add the server

        for client in self.clients.values():
            if client.active:
                recv_list.append(client.fileno)
            ## Delete inactive connections from the dictionary
            else:
                #print "-- Lost connection to %s" % client.addrport()
                #client.sock.close()
                self.on_disconnect(client)
                del self.clients[client.fileno]


        ## Build a list of connections that need to send data
        send_list = []
        for client in self.clients.values():
            if client.send_pending:
                send_list.append(client.fileno)

        ## Get active socket file descriptors from select.select()
        try:
            rlist, slist, elist = select.select(recv_list, send_list, [],
                self.timeout)

        except select.error, err:
            ## If we can't even use select(), game over man, game over
            print >> sys.stderr, ("!! FATAL SELECT error '%d:%s'!"
                % (err[0], err[1]))
            sys.exit(1)

        ## Process socket file descriptors with data to recieve
        for sock_fileno in rlist:

            ## If it's coming from the server's socket then this is a new
            ## connection request.
            if sock_fileno == self.server_fileno:

                try:
                    sock, addr_tup = self.server_socket.accept()

                except socket.error, err:
                    print >> sys.stderr, ("!! ACCEPT error '%d:%s'." %
                        (err[0], err[1]))
                    continue

                ## Check for maximum connections
                if self.client_count() >= MAX_CONNECTIONS:
                    print '?? Refusing new connection; maximum in use.'
                    sock.close()
                    continue

                new_client = TelnetClient(sock, addr_tup)
                #print "++ Opened connection to %s" % new_client.addrport()
                ## Add the connection to our dictionary and call handler
                self.clients[new_client.fileno] = new_client
                self.on_connect(new_client)

            else:
                ## Call the connection's recieve method
                try:
                    self.clients[sock_fileno].socket_recv()
                except BogConnectionLost:
                    self.clients[sock_fileno].deactivate()

        ## Process sockets with data to send
        for sock_fileno in slist:
            ## Call the connection's send method
            self.clients[sock_fileno].socket_send()
727932
def ping(self):
        
        status, _, body = self._request('GET', self.ping_path())
        return(status is not None) and (bytes_to_str(body) == 'OK')
58882
def getStats(self):
        
        info_dict = {}
        args = [varnishstatCmd, '-1']
        if self._instance is not None:
            args.extend(['-n', self._instance])
        output = util.exec_command(args)
        if self._descDict is None:
            self._descDict = {}
        for line in output.splitlines():
            mobj = re.match('(\S+)\s+(\d+)\s+(\d+\.\d+|\.)\s+(\S.*\S)\s*$', 
                            line)
            if mobj:
                fname = mobj.group(1).replace('.', '_')
                info_dict[fname] = util.parse_value(mobj.group(2))
                self._descDict[fname] = mobj.group(4)
        return info_dict
1077630
public void noteOpenConnection(ServerStats serverStats) {
        if (serverStats == null) {
            return;
        }
        try {
            serverStats.incrementActiveRequestsCount();
        } catch (Exception ex) {
            logger.error("Error noting stats for client {}", clientName, ex);
        }            
    }
1271434
def issues_stats(self):
        
        response = self.requester.get(
            '/{endpoint}/{id}/issues_stats',
            endpoint=self.endpoint, id=self.id
        )
        return response.json()
1175771
def server_info(self):
        
        response = self._post(self.apiurl + "/v2/server/info", data={'apikey': self.apikey})

        return self._raise_or_extract(response)
485791
async def get_status(self):
        
        cmd = OTGW_CMD_SUMMARY
        ret = await self._wait_for_cmd(cmd, 1)
        # Return to 'reporting' mode
        asyncio.ensure_future(self._wait_for_cmd(cmd, 0), loop=self.loop)
        if ret is None:
            return
        fields = ret[1].split(',')
        device_status = fields[0].split('/')
        master_status = device_status[0]
        slave_status = device_status[1]
        remote_params = fields[2].split('/')
        capmodlimits = fields[4].split('/')
        dhw_setp_bounds = fields[13].split('/')
        ch_setp_bounds = fields[14].split('/')
        status = {
            DATA_MASTER_CH_ENABLED: int(master_status[7]),
            DATA_MASTER_DHW_ENABLED: int(master_status[6]),
            DATA_MASTER_COOLING_ENABLED: int(master_status[5]),
            DATA_MASTER_OTC_ENABLED: int(master_status[4]),
            DATA_MASTER_CH2_ENABLED: int(master_status[3]),
            DATA_SLAVE_FAULT_IND: int(slave_status[7]),
            DATA_SLAVE_CH_ACTIVE: int(slave_status[6]),
            DATA_SLAVE_DHW_ACTIVE: int(slave_status[5]),
            DATA_SLAVE_FLAME_ON: int(slave_status[4]),
            DATA_SLAVE_COOLING_ACTIVE: int(slave_status[3]),
            DATA_SLAVE_CH2_ACTIVE: int(slave_status[2]),
            DATA_SLAVE_DIAG_IND: int(slave_status[1]),
            DATA_CONTROL_SETPOINT: float(fields[1]),
            DATA_REMOTE_TRANSFER_DHW: int(remote_params[0][7]),
            DATA_REMOTE_TRANSFER_MAX_CH: int(remote_params[0][6]),
            DATA_REMOTE_RW_DHW: int(remote_params[1][7]),
            DATA_REMOTE_RW_MAX_CH: int(remote_params[1][6]),
            DATA_SLAVE_MAX_RELATIVE_MOD: float(fields[3]),
            DATA_SLAVE_MAX_CAPACITY: int(capmodlimits[0]),
            DATA_SLAVE_MIN_MOD_LEVEL: int(capmodlimits[1]),
            DATA_ROOM_SETPOINT: float(fields[5]),
            DATA_REL_MOD_LEVEL: float(fields[6]),
            DATA_CH_WATER_PRESS: float(fields[7]),
            DATA_ROOM_TEMP: float(fields[8]),
            DATA_CH_WATER_TEMP: float(fields[9]),
            DATA_DHW_TEMP: float(fields[10]),
            DATA_OUTSIDE_TEMP: float(fields[11]),
            DATA_RETURN_WATER_TEMP: float(fields[12]),
            DATA_SLAVE_DHW_MAX_SETP: int(dhw_setp_bounds[0]),
            DATA_SLAVE_DHW_MIN_SETP: int(dhw_setp_bounds[1]),
            DATA_SLAVE_CH_MAX_SETP: int(ch_setp_bounds[0]),
            DATA_SLAVE_CH_MIN_SETP: int(ch_setp_bounds[1]),
            DATA_DHW_SETPOINT: float(fields[15]),
            DATA_MAX_CH_SETPOINT: float(fields[16]),
            DATA_TOTAL_BURNER_STARTS: int(fields[17]),
            DATA_CH_PUMP_STARTS: int(fields[18]),
            DATA_DHW_PUMP_STARTS: int(fields[19]),
            DATA_DHW_BURNER_STARTS: int(fields[20]),
            DATA_TOTAL_BURNER_HOURS: int(fields[21]),
            DATA_CH_PUMP_HOURS: int(fields[22]),
            DATA_DHW_PUMP_HOURS: int(fields[23]),
            DATA_DHW_BURNER_HOURS: int(fields[24])
        }
        self._update_status(status)
        return dict(self._protocol.status)
498532
def server_enabled(s_name, **connection_args):
    '''
    
    '''
    server = _server_get(s_name, **connection_args)
    return server is not None and server.get_state() == 'ENABLED'
124835
def check_status(self):
        
        log = logging.getLogger("%s.%s" % (self.log_name,
                                           inspect.stack()[0][3]))
        log.setLevel(self.log_level)

        if self.url:
            return True
        try:
            result = requests.get(self.ext_url)
            self.url = self.ext_url
            return True
        except requests.exceptions.ConnectionError:
            pass
        try:
            result = requests.get(self.local_url)
            log.warning("Url '%s' not connecting. Using local_url '%s'" % \
                     (self.ext_url, self.local_url))
            self.url = self.local_url
            return True
        except requests.exceptions.ConnectionError:
            self.url = None
            log.warning("Unable to connect using urls: %s" % set([self.ext_url,
                                                               self.local_url]))
            return False
366650
async def getStats(self):
        
        for ssrc, stream in self.__remote_streams.items():
            self.__stats.add(RTCInboundRtpStreamStats(
                # RTCStats
                timestamp=clock.current_datetime(),
                type='inbound-rtp',
                id='inbound-rtp_' + str(id(self)),
                # RTCStreamStats
                ssrc=ssrc,
                kind=self.__kind,
                transportId=self.transport._stats_id,
                # RTCReceivedRtpStreamStats
                packetsReceived=stream.packets_received,
                packetsLost=stream.packets_lost,
                jitter=stream.jitter,
                # RTPInboundRtpStreamStats
            ))
        self.__stats.update(self.transport._get_stats())

        return self.__stats
971684
def daemon_status(self):
        
        url = self._build_url(constants.DAEMON_STATUS_ENDPOINT)
        json = self.client.get(url, timeout=self.timeout)
        return json
803413
def status(self):
        
        if not self.created:
            return None
        self.inner().reload()
        return self.inner().status
1116673
def get_slab_stats(self):
        """"""
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((self.host, self.port))
        s.send("stats slabs\n")
        try:
            data = ""
            while True:
                data += s.recv(4096)
                if data.endswith('END\r\n'):
                    break
            return data
        finally:
            s.close()
969765
def _login_glances(self):
        """"""
        client_version = None
        try:
            client_version = self.client.init()
        except socket.error as err:
            # Fallback to SNMP
            self.client_mode = 'snmp'
            logger.error("Connection to Glances server failed ({} {})".format(err.errno, err.strerror))
            fallbackmsg = 'No Glances server found on {}. Trying fallback to SNMP...'.format(self.uri)
            if not self.return_to_browser:
                print(fallbackmsg)
            else:
                logger.info(fallbackmsg)
        except ProtocolError as err:
            # Other errors
            msg = "Connection to server {} failed".format(self.uri)
            if err.errcode == 401:
                msg += " (Bad username/password)"
            else:
                msg += " ({} {})".format(err.errcode, err.errmsg)
            self.log_and_exit(msg)
            return False

        if self.client_mode == 'glances':
            # Check that both client and server are in the same major version
            if __version__.split('.')[0] == client_version.split('.')[0]:
                # Init stats
                self.stats = GlancesStatsClient(config=self.config, args=self.args)
                self.stats.set_plugins(json.loads(self.client.getAllPlugins()))
                logger.debug("Client version: {} / Server version: {}".format(__version__, client_version))
            else:
                self.log_and_exit(('Client and server not compatible: '
                                   'Client version: {} / Server version: {}'.format(__version__, client_version)))
                return False

        return True
1317352
def get_stats(self):
        '''
        
        '''
        resp = requests.get('%s/api/stats.json' % self.url)
        assert(resp.status_code == 200)
        return resp.json()
912577
def read_stats(self):
        

        self.statistics = TgnObjectsDict()
        for port in self.session.ports.values():
            for tpld in port.tplds.values():
                self.statistics[tpld] = tpld.read_stats()
        return self.statistics