Returns I/O stats for swap partition.
        
        @param dev: Device name for swap partition.
        @return: Dict of stats.
966566
def getSwapStats(self, dev):
        
        if self._swapList is None:
            self._initSwapInfo()
        if dev in self._swapList:
            return self.getDevStats(dev)
        else:
            return None
434542
def _get_stats_from_socket(self, name):
        
        try:
            json_blob = subprocess.check_output(
                [self.config['ceph_binary'],
                 '--admin-daemon',
                 name,
                 'perf',
                 'dump',
                 ])
        except subprocess.CalledProcessError as err:
            self.log.info('Could not get stats from %s: %s',
                          name, err)
            self.log.exception('Could not get stats from %s' % name)
            return {}

        try:
            json_data = json.loads(json_blob)
        except Exception as err:
            self.log.info('Could not parse stats from %s: %s',
                          name, err)
            self.log.exception('Could not parse stats from %s' % name)
            return {}

        return json_data
997452
def _aix_memdata():
    '''
    
    '''
    grains = {'mem_total': 0, 'swap_total': 0}
    prtconf = salt.utils.path.which('prtconf')
    if prtconf:
        for line in __salt__['cmd.run'](prtconf, python_shell=True).splitlines():
            comps = [x for x in line.strip().split(' ') if x]
            if len(comps) > 2 and 'Memory' in comps[0] and 'Size' in comps[1]:
                grains['mem_total'] = int(comps[2])
                break
    else:
        log.error('The \'prtconf\' binary was not found in $PATH.')

    swap_cmd = salt.utils.path.which('swap')
    if swap_cmd:
        swap_data = __salt__['cmd.run']('{0} -s'.format(swap_cmd)).split()
        try:
            swap_total = (int(swap_data[-2]) + int(swap_data[-6])) * 4
        except ValueError:
            swap_total = None
        grains['swap_total'] = swap_total
    else:
        log.error('The \'swap\' binary was not found in $PATH.')
    return grains
641600
def _iostat_fbsd(interval, count, disks):
    '''
    
    '''
    if disks is None:
        iostat_cmd = 'iostat -xC -w {0} -c {1} '.format(interval, count)
    elif isinstance(disks, six.string_types):
        iostat_cmd = 'iostat -x -w {0} -c {1} {2}'.format(interval, count, disks)
    else:
        iostat_cmd = 'iostat -x -w {0} -c {1} {2}'.format(interval, count, ' '.join(disks))

    sys_stats = []
    dev_stats = collections.defaultdict(list)
    sys_header = []
    dev_header = []
    h_len = 1000  # randomly absurdly high

    ret = iter(__salt__['cmd.run_stdout'](iostat_cmd, output_loglevel='quiet').splitlines())
    for line in ret:
        if not line.startswith('device'):
            continue
        elif not dev_header:
            dev_header = line.split()[1:]
        while line is not False:
            line = next(ret, False)
            if not line or not line[0].isalnum():
                break
            line = line.split()
            disk = line[0]
            stats = [decimal.Decimal(x) for x in line[1:]]
            # h_len will become smallest number of fields in stat lines
            if len(stats) < h_len:
                h_len = len(stats)
            dev_stats[disk].append(stats)

    iostats = {}

    # The header was longer than the smallest number of fields
    # Therefore the sys stats are hidden in there
    if h_len < len(dev_header):
        sys_header = dev_header[h_len:]
        dev_header = dev_header[0:h_len]

        for disk, stats in dev_stats.items():
            if len(stats[0]) > h_len:
                sys_stats = [stat[h_len:] for stat in stats]
                dev_stats[disk] = [stat[0:h_len] for stat in stats]

        iostats['sys'] = _iostats_dict(sys_header, sys_stats)

    for disk, stats in dev_stats.items():
        iostats[disk] = _iostats_dict(dev_header, stats)

    return iostats
1050729
def get_stats(self):
        
        sent = ctypes.c_uint32()
        recv = ctypes.c_uint32()
        send_errors = ctypes.c_uint32()
        recv_errors = ctypes.c_uint32()
        result = self.library.Par_GetStats(self.pointer, ctypes.byref(sent),
                                   ctypes.byref(recv),
                                   ctypes.byref(send_errors),
                                   ctypes.byref(recv_errors))
        check_error(result, "partner")
        return sent, recv, send_errors, recv_errors
147552
def stat(self, filename, timeout=None):
    """"""
    transport = StatFilesyncTransport(self.stream)
    transport.write_data('STAT', filename, timeout)
    stat_msg = transport.read_message(timeout)
    stat_msg.assert_command_is('STAT')
    return DeviceFileStat(filename, stat_msg.mode, stat_msg.size, stat_msg.time)
799683
def _getDevMajorMinor(self, devpath):
        
        fstat = os.stat(devpath)
        if stat.S_ISBLK(fstat.st_mode):
            return(os.major(fstat.st_rdev), os.minor(fstat.st_rdev))
        else:
            raise ValueError("The file %s is not a valid block device." % devpath)
370223
def _blkid_output(out, fs_type=None):
    '''
    
    '''
    flt = lambda data: [el for el in data if el.strip()]
    data = {}
    for dev_meta in flt(out.split('\n\n')):
        dev = {}
        for items in flt(dev_meta.strip().split('\n')):
            key, val = items.split('=', 1)
            dev[key.lower()] = val
        if fs_type and dev.get('type', '') == fs_type or not fs_type:
            if 'type' in dev and fs_type:
                dev.pop('type')
            data[dev.pop('devname')] = dev

    if fs_type:
        mounts = _get_mounts(fs_type)
        for device in six.iterkeys(mounts):
            if data.get(device):
                data[device]['mounts'] = mounts[device]

    return data
1065549
def format_sync_stats(self, cnt):
        '''
        
        '''
        stats = salt.utils.odict.OrderedDict()
        if cnt.get('retcode') == salt.defaults.exitcodes.EX_OK:
            for line in cnt.get('stdout', '').split(os.linesep):
                line = line.split(': ')
                if len(line) == 2:
                    stats[line[0].lower().replace(' ', '_')] = line[1]
            cnt['transfer'] = stats
            del cnt['stdout']

        # Remove empty
        empty_sections = []
        for section in cnt:
            if not cnt[section] and section != 'retcode':
                empty_sections.append(section)
        for section in empty_sections:
            del cnt[section]

        return cnt
401855
def _getUniqueDev(self, devpath):
        
        realpath = os.path.realpath(devpath)
        mobj = re.match('\/dev\/(.*)$', realpath)
        if mobj:
            dev = mobj.group(1)
            if dev in self._diskStats:
                return dev
            else:
                try:
                    (major, minor) = self._getDevMajorMinor(realpath)
                except:
                    return None
                return self._mapMajorMinor2dev.get((major, minor))
        return None
782742
def _bdev(dev=None):
    '''
    
    '''
    if dev is None:
        dev = _fssys('cache0')
    else:
        dev = _bcpath(dev)

    if not dev:
        return False
    else:
        return _devbase(os.path.dirname(dev))
153734
def read_tpld_stats(self):
        
        payloads_stats = OrderedDict()
        for tpld in self.tplds.values():
            payloads_stats[tpld] = tpld.read_stats()
        return payloads_stats
983244
def _GetStat(self):
    
    stat_object = super(OSFileEntry, self)._GetStat()

    if not self._is_windows_device:
      # File data stat information.
      stat_object.size = self._stat_info.st_size

      # Ownership and permissions stat information.
      stat_object.mode = stat.S_IMODE(self._stat_info.st_mode)
      stat_object.uid = self._stat_info.st_uid
      stat_object.gid = self._stat_info.st_gid

      # Other stat information.
      stat_object.ino = self._stat_info.st_ino
      # stat_info.st_dev
      # stat_info.st_nlink

    return stat_object
326702
def _get_stats_files(data, out_dir=None):
    
    if not out_dir:
        out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
                                                  "qc", dd.get_sample_name(data), "samtools"))
    stats_file = tz.get_in(["depth", "samtools", "stats"], data)
    idxstats_file = tz.get_in(["depth", "samtools", "idxstats"], data)
    if not stats_file:
        stats_file = os.path.join(out_dir, "%s.txt" % dd.get_sample_name(data))
    if not idxstats_file:
        idxstats_file = os.path.join(out_dir, "%s-idxstats.txt" % dd.get_sample_name(data))
    return stats_file, idxstats_file
185102
def _GetStat(self):
    
    stat_object = super(BDEFileEntry, self)._GetStat()

    stat_object.size = self._bde_volume.get_size()

    return stat_object
1030101
def _initDevClasses(self):
        """"""
        self._devClassTree = {}
        self._partitionTree = {}
        self._mapDevType = {}
        basedevs = []
        otherdevs = []
        if self._mapMajorDevclass is None:
            self._initBlockMajorMap()
        for dev in self._diskStats:
            stats = self._diskStats[dev]
            devclass = self._mapMajorDevclass.get(stats['major'])
            if devclass is not None:
                devdir = os.path.join(sysfsBlockdevDir, dev)
                if os.path.isdir(devdir):
                    if not self._devClassTree.has_key(devclass):
                        self._devClassTree[devclass] = []
                    self._devClassTree[devclass].append(dev)
                    self._mapDevType[dev] = devclass
                    basedevs.append(dev)
                else:
                    otherdevs.append(dev)
        basedevs.sort(key=len, reverse=True)
        otherdevs.sort(key=len, reverse=True)
        idx = 0
        for partdev in otherdevs:
            while len(basedevs[idx]) > partdev:
                idx += 1 
            for dev in basedevs[idx:]:
                if re.match("%s(\d+|p\d+)$" % dev, partdev):
                    if not self._partitionTree.has_key(dev):
                        self._partitionTree[dev] = []
                    self._partitionTree[dev].append(partdev)
                    self._mapDevType[partdev] = 'part'
1275601
def stats(self):
        
        return OrderedDict([
            ("Intervals", len(self.array)),
            ("Mean", self.format_time(self.mean or 0)),
            ("Min", self.format_time(self.min or 0)),
            ("Median", self.format_time(self.median or 0)),
            ("Max", self.format_time(self.max or 0)),
            ("St. Dev.", self.format_time(self.stdev or 0)),
            ("Total", self.format_time(self.exectime or 0)),
        ])