Beispiel #1
0
    def get(self):
        zio_type_t = bindings['zio_type_t']

        stats = []
        for pool in ZPool.list():
            pool.refresh_stats()

            stat = {}
            stat['pool_name'] = pool.name
            raw_stats = pool.config.vdev_tree.get('vdev_stats',None)
            if raw_stats:
                (timestamp, state, aux, alloc, space, dspace, rsize, esize) = raw_stats[:8]
                zio_ops = raw_stats[8:14]
                zio_bytes = raw_stats[14:20]
                fragmentation = None

                if len(raw_stats) > 26:
                    (read_errors, write_errors, checksum_errors, self_healed, scan_removing, scan_processed, fragmentation) = raw_stats[20:27]
                else:
                    (read_errors, write_errors, checksum_errors, self_healed, scan_removing, scan_processed) = raw_stats[20:26]
                stat['timestamp'] = int(time.time())
                stat['state'] = state
                stat['aux'] = aux
                stat['alloc'] = alloc
                stat['space'] = space
                stat['dspace'] = dspace
                stat['rsize'] = rsize
                stat['esize'] = esize

                stat['zio_ops'] = {key.name: int(zio_ops[key]) for key in zio_type_t if key < zio_type_t.ZIO_TYPES}

                stat['zio_bytes'] = {key.name: int(zio_bytes[key]) for key in zio_type_t if key < zio_type_t.ZIO_TYPES}

                stat['read_errors'] = read_errors
                stat['write_errors'] = write_errors
                stat['checksum_errors'] = checksum_errors
                stat['self_healed'] = self_healed
                stat['scan_removing'] = scan_removing
                stat['scan_processed'] = scan_processed
                stat['fragmentation'] = fragmentation

                if self.pool_stats.has_key(pool.name):
                    stat['diff'] = self.get_diff(self.pool_stats[pool.name], stat)

                stats.append(stat)

                self.pool_stats[pool.name] = stat
        return stats
 def test_001_iter_zpools(self):
     pools = ZPool.list()
     assert len(pools) > 0