Get received / dropped statistics
357684
def get_stats(self):
        """"""

        try:
            ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
            return struct.unpack("2I", ret)
        except IOError:
            warning("Unable to get stats from BPF !")
            return (None, None)
683525
def record_received(self, msg):
        """"""
        release_lock = False
        userdata = msg.userdata
        rec = ALDBRecord.create_from_userdata(userdata)
        self._records[rec.mem_addr] = rec

        _LOGGER.debug('ALDB Record: %s', rec)

        rec_count = self._load_action.rec_count
        if rec_count == 1 or self._have_all_records():
            release_lock = True

        if self._is_first_record(rec):
            self._mem_addr = rec.mem_addr

        if release_lock and self._rec_mgr_lock.locked():
            _LOGGER.debug('Releasing lock because record received')
            self._rec_mgr_lock.release()
926605
def GetIcmpStatistics():
    """"""
    statistics = MIB_ICMP()
    _GetIcmpStatistics(byref(statistics))
    results = _struct_to_dict(statistics)
    del(statistics)
    return results
263933
async def getStats(self):
        
        self.__stats.add(RTCOutboundRtpStreamStats(
            # RTCStats
            timestamp=clock.current_datetime(),
            type='outbound-rtp',
            id='outbound-rtp_' + str(id(self)),
            # RTCStreamStats
            ssrc=self._ssrc,
            kind=self.__kind,
            transportId=self.transport._stats_id,
            # RTCSentRtpStreamStats
            packetsSent=self.__packet_count,
            bytesSent=self.__octet_count,
            # RTCOutboundRtpStreamStats
            trackId=str(id(self.track)),
        ))
        self.__stats.update(self.transport._get_stats())

        return self.__stats
246023
def retrieveVals(self):
        """"""
        if self._stats is None:
            serverInfo = MemcachedInfo(self._host,  self._port, self._socket_file)
            stats = serverInfo.getStats()
        else:
            stats = self._stats
        if stats is None:
            raise Exception("Undetermined error accesing stats.")        
        stats['set_hits'] = stats.get('total_items')
        if stats.has_key('cmd_set') and stats.has_key('total_items'): 
            stats['set_misses'] = stats['cmd_set'] - stats['total_items']
        self.saveState(stats)
        if self.hasGraph('memcached_connections'):
            self.setGraphVal('memcached_connections', 'conn', 
                             stats.get('curr_connections'))
        if self.hasGraph('memcached_items'):
            self.setGraphVal('memcached_items', 'items', 
                             stats.get('curr_items'))
        if self.hasGraph('memcached_memory'):
            self.setGraphVal('memcached_memory', 'bytes', 
                             stats.get('bytes'))
        if self.hasGraph('memcached_connrate'):
            self.setGraphVal('memcached_connrate', 'conn', 
                             stats.get('total_connections'))
        if self.hasGraph('memcached_traffic'):
            self.setGraphVal('memcached_traffic', 'rxbytes', 
                             stats.get('bytes_read'))
            self.setGraphVal('memcached_traffic', 'txbytes', 
                             stats.get('bytes_written'))
        if self.hasGraph('memcached_reqrate'):
            self.setGraphVal('memcached_reqrate', 'set', 
                             stats.get('cmd_set'))
            self.setGraphVal('memcached_reqrate', 'get', 
                             stats.get('cmd_get'))
            if self.graphHasField('memcached_reqrate', 'del'):
                self.setGraphVal('memcached_reqrate', 'del',
                                 safe_sum([stats.get('delete_hits'), 
                                           stats.get('delete_misses')]))
            if self.graphHasField('memcached_reqrate', 'cas'):
                self.setGraphVal('memcached_reqrate', 'cas',
                                 safe_sum([stats.get('cas_hits'), 
                                           stats.get('cas_misses'), 
                                           stats.get('cas_badval')]))
            if self.graphHasField('memcached_reqrate', 'incr'):
                self.setGraphVal('memcached_reqrate', 'incr',
                                 safe_sum([stats.get('incr_hits'), 
                                           stats.get('incr_misses')]))
            if self.graphHasField('memcached_reqrate', 'decr'):
                self.setGraphVal('memcached_reqrate', 'decr',
                                 safe_sum([stats.get('decr_hits'), 
                                           stats.get('decr_misses')]))
        if self.hasGraph('memcached_statget'):
            self.setGraphVal('memcached_statget', 'hit', 
                             stats.get('get_hits'))
            self.setGraphVal('memcached_statget', 'miss', 
                             stats.get('get_misses'))
            self.setGraphVal('memcached_statget', 'total', 
                             safe_sum([stats.get('get_hits'),
                                       stats.get('get_misses')]))
        if self.hasGraph('memcached_statset'):
            self.setGraphVal('memcached_statset', 'hit', 
                             stats.get('set_hits'))
            self.setGraphVal('memcached_statset', 'miss', 
                             stats.get('set_misses'))
            self.setGraphVal('memcached_statset', 'total', 
                             safe_sum([stats.get('set_hits'),
                                       stats.get('set_misses')]))
        if self.hasGraph('memcached_statdel'):
            self.setGraphVal('memcached_statdel', 'hit', 
                             stats.get('delete_hits'))
            self.setGraphVal('memcached_statdel', 'miss', 
                             stats.get('delete_misses'))
            self.setGraphVal('memcached_statdel', 'total', 
                             safe_sum([stats.get('delete_hits'),
                                       stats.get('delete_misses')]))
        if self.hasGraph('memcached_statcas'):
            self.setGraphVal('memcached_statcas', 'hit', 
                             stats.get('cas_hits'))
            self.setGraphVal('memcached_statcas', 'miss', 
                             stats.get('cas_misses'))
            self.setGraphVal('memcached_statcas', 'badval', 
                             stats.get('cas_badval'))
            self.setGraphVal('memcached_statcas', 'total', 
                             safe_sum([stats.get('cas_hits'),
                                       stats.get('cas_misses'),
                                       stats.get('cas_badval')]))
        if self.hasGraph('memcached_statincrdecr'):
            self.setGraphVal('memcached_statincrdecr', 'incr_hit', 
                             stats.get('incr_hits'))
            self.setGraphVal('memcached_statincrdecr', 'decr_hit', 
                             stats.get('decr_hits'))
            self.setGraphVal('memcached_statincrdecr', 'incr_miss', 
                             stats.get('incr_misses'))
            self.setGraphVal('memcached_statincrdecr', 'decr_miss', 
                             stats.get('decr_misses'))
            self.setGraphVal('memcached_statincrdecr', 'total', 
                             safe_sum([stats.get('incr_hits'),
                                       stats.get('decr_hits'),
                                       stats.get('incr_misses'),
                                       stats.get('decr_misses')]))
        if self.hasGraph('memcached_statevict'):
            self.setGraphVal('memcached_statevict', 'evict', 
                             stats.get('evictions'))
            if self.graphHasField('memcached_statevict', 'reclaim'):
                self.setGraphVal('memcached_statevict', 'reclaim', 
                                 stats.get('reclaimed'))
        if self.hasGraph('memcached_statauth'):
            self.setGraphVal('memcached_statauth', 'reqs', 
                             stats.get('auth_cmds'))
            self.setGraphVal('memcached_statauth', 'errors', 
                             stats.get('auth_errors'))
        if self.hasGraph('memcached_hitpct'):
            prev_stats = self._prev_stats
            for (field_name,  field_hits,  field_misses) in (
                    ('set',  'set_hits',  'set_misses'),
                    ('get',  'get_hits',  'get_misses'), 
                    ('del',  'delete_hits',  'delete_misses'), 
                    ('cas',  'cas_hits',  'cas_misses'), 
                    ('incr',  'incr_hits',  'incr_misses'), 
                    ('decr',  'decr_hits',  'decr_misses')
                ):
                if prev_stats:
                    if (stats.has_key(field_hits) 
                        and prev_stats.has_key(field_hits)
                        and stats.has_key(field_misses) 
                        and prev_stats.has_key(field_misses)):
                        hits = stats[field_hits] - prev_stats[field_hits]
                        misses = stats[field_misses] - prev_stats[field_misses]
                        total = hits + misses
                        if total > 0:
                            val = 100.0 * hits / total
                        else:
                            val = 0
                        self.setGraphVal('memcached_hitpct',  field_name, 
                                         round(val,  2))
328170
def retrieveVals(self):
        """"""
        ntpinfo = NTPinfo()
        ntpstats = ntpinfo.getHostOffsets(self._remoteHosts)
        if ntpstats:
            for host in self._remoteHosts:
                hostkey = re.sub('\.', '_', host)
                hoststats = ntpstats.get(host)
                if hoststats:
                    if self.hasGraph('ntp_host_stratums'):
                        self.setGraphVal('ntp_host_stratums', hostkey, 
                                         hoststats.get('stratum'))
                    if self.hasGraph('ntp_host_offsets'):
                        self.setGraphVal('ntp_host_offsets', hostkey, 
                                         hoststats.get('offset'))
                    if self.hasGraph('ntp_host_delays'):
                        self.setGraphVal('ntp_host_delays', hostkey, 
                                         hoststats.get('delay'))
124428
def get_status(self):
        """"""
        headers = {
            "X-AppName": "MusicCast/0.1(python)",
            "X-AppPort": str(self._udp_port)
        }
        req_url = ENDPOINTS["getStatus"].format(self.ip_address, 'main')
        return request(req_url, headers=headers)
232615
function getStats() {
  var procMem = process.memoryUsage();
  var stats = {
    mem: {
      total: os.totalmem(),
      free: os.freemem(),
      heap: procMem.rss
    },
    cpu: os.loadavg()
  };
  for(var i=0; i < stats.cpu.length; i++) {
    stats.cpu[i] = stats.cpu[i].toFixed(3);
  }
  stats.cpu = stats.cpu.join(",");
  // We convert from bytes to mb
  stats.mem.total = Math.ceil(stats.mem.total / 1000000) + "MB";
  stats.mem.free = Math.ceil(stats.mem.free / 1000000) + "MB";
  stats.mem.heap = (stats.mem.heap / 1000000).toFixed(3) + "MB";
  return stats;
}
899741
def receiveds_parsing(receiveds):
    

    parsed = []
    receiveds = [re.sub(JUNK_PATTERN, " ", i).strip() for i in receiveds]
    n = len(receiveds)
    log.debug("Nr. of receiveds. {}".format(n))

    for idx, received in enumerate(receiveds):
        log.debug("Parsing received {}/{}".format(idx + 1, n))
        log.debug("Try to parse {!r}".format(received))
        try:
            # try to parse the current received header...
            values_by_clause = parse_received(received)
        except MailParserReceivedParsingError:
            # if we can't, let's append the raw
            parsed.append({'raw': received})
        else:
            # otherwise append the full values_by_clause dict
            parsed.append(values_by_clause)

    log.debug("len(receiveds) %s, len(parsed) %s" % (
        len(receiveds), len(parsed)))

    if len(receiveds) != len(parsed):
        # something really bad happened,
        # so just return raw receiveds with hop indices
        log.error("len(receiveds): %s, len(parsed): %s, receiveds: %s, \
            parsed: %s" % (len(receiveds), len(parsed), receiveds, parsed))
        return receiveds_not_parsed(receiveds)

    else:
        # all's good! we have parsed or raw receiveds for each received header
        return receiveds_format(parsed)
170137
def total_msg_recv(self):
        
        return (self.get_count(PeerCounterNames.RECV_UPDATES) +
                self.get_count(PeerCounterNames.RECV_REFRESH) +
                self.get_count(PeerCounterNames.RECV_NOTIFICATION))
650081
function getStatsAdapter() {

    ///
  // Get Stats using the older API. Used by all current versions
  // of Chrome.
  //
    function getStatsOldAPI(peerConnection, completion) {

      peerConnection.getStats(function(rtcStatsReport) {

        var stats = [];
        rtcStatsReport.result().forEach(function(rtcStat) {

          var stat = {};

          rtcStat.names().forEach(function(name) {
            stat[name] = rtcStat.stat(name);
          });

          // fake the structure of the "new" RTC stat object
          stat.id = rtcStat.id;
          stat.type = rtcStat.type;
          stat.timestamp = rtcStat.timestamp;
          stats.push(stat);
        });

        completion(null, stats);
      });
    }

  ///
  // Get Stats using the newer API.
  //
    function getStatsNewAPI(peerConnection, completion) {

      peerConnection.getStats(null, function(rtcStatsReport) {

        var stats = [];
        rtcStatsReport.forEach(function(rtcStats) {
          stats.push(rtcStats);
        });

        completion(null, stats);
      }, completion);
    }

    if (OT.$.browserVersion().name === 'Firefox' || OTPlugin.isInstalled()) {
      return getStatsNewAPI;
    } else {
      return getStatsOldAPI;
    }
  }
1102833
def get_icinga_stats(self, app_stats):
        
        stats = {}
        stats = dict(stats.items() + self._get_active_stats(app_stats).items())
        stats = dict(stats.items() + self._get_cached_stats(app_stats).items())
        stats = dict(
            stats.items() + self._get_command_execution(app_stats).items())
        stats = dict(
            stats.items() + self._get_externalcmd_stats(app_stats).items())
        stats["uptime"] = self._get_uptime(app_stats)
        return stats
700334
def data_received(self, data):
        """"""
        self.tokenizer.feed(data)
        while self.tokenizer.has_tokens():
            raw = self.tokenizer.get_next_token()
            frame = frame_from_raw(raw)
            if frame is not None:
                self.frame_received_cb(frame)
157868
def recv(self):
        """"""
        LOGGER.debug('Receiving')
        try:
            message_length = struct.unpack('>i', self._socket.recv(4))[0]
            message_length -= Connection.COMM_LENGTH
            LOGGER.debug('Length: %i', message_length)
        except socket.timeout:
            return None
        
        comm_status = struct.unpack('>i', self._socket.recv(4))[0]
        LOGGER.debug('Status: %i', comm_status)
        bytes_received = 0
        message = b""
        
        while bytes_received < message_length:
            if message_length - bytes_received >= 1024:
                recv_len = 1024
            else:
                recv_len = message_length - bytes_received
            bytes_received += recv_len
            LOGGER.debug('Received %i', bytes_received)
            message += self._socket.recv(recv_len)
        
        if comm_status == 0:
            message = self._crypt.decrypt(message)
        else:
            return Message(len(message), Connection.COMM_ERROR, message)
        
        msg = Message(message_length, comm_status, message)

        return msg
68439
def get_stats(self, request, context):
        """"""
        _log_request(request, context)
        m = self.listener.memory
        return clearly_pb2.StatsMessage(
            task_count=m.task_count,
            event_count=m.event_count,
            len_tasks=len(m.tasks),
            len_workers=len(m.workers)
        )
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
810956
def get_statistics(self):
        
        return {
            'cumulative_elapsed_time': self.get_cumulative_elapsed_time(),
            'percentage': self.get_percentage(),
            'n_splits': self.get_n_splits(),
            'mean_per_split': self.get_mean_per_split(),
        }