def test_005_get_zpool_config(self):
     pool = ZPool.get(name=LIBZFS_TEST_POOL)
     config = pool.config
     pool.refresh_stats()
     oldconfig = pool.old_config
     assert len(config.keys()) > 0
     assert len(oldconfig.keys()) > 0
     assert config == oldconfig
     assert config.get(bindings['ZPOOL_CONFIG_POOL_NAME'])
Example #2
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_006_get_zpool_config_easy_access(self):
     from datetime import datetime
     pool = ZPool.get(name=LIBZFS_TEST_POOL)
     config = pool.config
     assert isinstance(config.initial_load_time, datetime)
     assert config.name == config.get(bindings['ZPOOL_CONFIG_POOL_NAME'], None)
 def test_004_get_zpool_properties_easy_access(self):
     pool = ZPool.get(name=LIBZFS_TEST_POOL)
     props = pool.properties
     assert props.name == props.get(zpool_prop_t.ZPOOL_PROP_NAME, None)
     assert props.size == props.get(zpool_prop_t.ZPOOL_PROP_SIZE, None)
 def test_003_get_zpool_properties(self):
     pool = ZPool.get(name=LIBZFS_TEST_POOL)
     props = pool.properties
     assert len(props.keys()) > 0
     assert props.get(zpool_prop_t.ZPOOL_PROP_NAME) == LIBZFS_TEST_POOL
     assert props.get(zpool_prop_t.ZPOOL_PROP_SIZE) > 0
 def test_002_get_zpool(self):
     pool = ZPool.get(name=LIBZFS_TEST_POOL)
     assert pool is not None
 def test_001_iter_zpools(self):
     pools = ZPool.list()
     assert len(pools) > 0