示例#1
0
func (r *RadosIoCtx) PoolStat() (*RadosPoolStat, error) {
	var pool_stat C.struct_rados_pool_stat_t
	cerr := C.rados_ioctx_pool_stat(*r.ctx, &pool_stat)
	if cerr < 0 {
		return nil, errors.New("Get pool status failed")
	}
	return &RadosPoolStat{
		num_bytes:         uint64(pool_stat.num_bytes),
		num_kb:            uint64(pool_stat.num_kb),
		num_objects:       uint64(pool_stat.num_objects),
		num_object_clones: uint64(pool_stat.num_object_clones),
		num_object_copies: uint64(pool_stat.num_object_copies)}, nil
}
示例#2
0
文件: ioctx.go 项目: mittalms/go-ceph
// Stat returns a set of statistics about the pool associated with this I/O
// context.
func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
	c_stat := C.struct_rados_pool_stat_t{}
	ret := C.rados_ioctx_pool_stat(ioctx.ioctx, &c_stat)
	if ret < 0 {
		return PoolStat{}, RadosError(int(ret))
	} else {
		return PoolStat{
			Num_bytes:                      uint64(c_stat.num_bytes),
			Num_kb:                         uint64(c_stat.num_kb),
			Num_objects:                    uint64(c_stat.num_objects),
			Num_object_clones:              uint64(c_stat.num_object_clones),
			Num_object_copies:              uint64(c_stat.num_object_copies),
			Num_objects_missing_on_primary: uint64(c_stat.num_objects_missing_on_primary),
			Num_objects_unfound:            uint64(c_stat.num_objects_unfound),
			Num_objects_degraded:           uint64(c_stat.num_objects_degraded),
			Num_rd:                         uint64(c_stat.num_rd),
			Num_rd_kb:                      uint64(c_stat.num_rd_kb),
			Num_wr:                         uint64(c_stat.num_wr),
			Num_wr_kb:                      uint64(c_stat.num_wr_kb),
		}, nil
	}
}
示例#3
0
// PoolStat retrieves the current usage for pool referenced by the
// given context and returns them in the PoolInfo structure.
func (c *Context) PoolStat() (*PoolInfo, error) {
	var pstat C.struct_rados_pool_stat_t

	if cerr := C.rados_ioctx_pool_stat(c.ctx, &pstat); cerr < 0 {
		return nil, radosReturnCodeError(cerr)
	}

	info := &PoolInfo{
		BytesUsed:                uint64(pstat.num_bytes),
		KBytesUsed:               uint64(pstat.num_kb),
		NObjects:                 uint64(pstat.num_objects),
		NObjectClones:            uint64(pstat.num_object_clones),
		NObjectCopies:            uint64(pstat.num_object_copies),
		NObjectsMissingOnPrimary: uint64(pstat.num_objects_missing_on_primary),
		NObjectsUnfound:          uint64(pstat.num_objects_unfound),
		NObjectsDegraded:         uint64(pstat.num_objects_degraded),
		BytesRead:                uint64(pstat.num_rd),
		BytesWritten:             uint64(pstat.num_wr),
		KBytesRead:               uint64(pstat.num_rd_kb),
		KBytesWritten:            uint64(pstat.num_wr_kb),
	}

	return info, nil
}
示例#4
0
// Status retrieves the PoolStatus.
func (pool *Pool) Status() (*PoolStatus, error) {
	var poolStat C.struct_rados_pool_stat_t
	ret := C.rados_ioctx_pool_stat(pool.context, &poolStat)
	if err := toRadosError(ret); err != nil {
		err.Message = "Unable to get pool status."
		return nil, err
	}

	status := &PoolStatus{
		FreeBytes:               uint64(poolStat.num_bytes),
		FreeKiloBytes:           uint64(poolStat.num_kb),
		Objects:                 uint64(poolStat.num_objects),
		ObjectClones:            uint64(poolStat.num_object_clones),
		ObjectCopies:            uint64(poolStat.num_object_copies),
		ObjectsMissingOnPrimary: uint64(poolStat.num_objects_missing_on_primary),
		ObjectsFound:            uint64(poolStat.num_objects_unfound),
		ObjectsDegraded:         uint64(poolStat.num_objects_degraded),
		ReadBytes:               uint64(poolStat.num_rd),
		ReadKiloBytes:           uint64(poolStat.num_rd_kb),
		WriteBytes:              uint64(poolStat.num_wr),
		WriteKiloBytes:          uint64(poolStat.num_wr_kb),
	}
	return status, nil
}