lib: implement GetClusterStats

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
Noah Watkins 2014-05-26 12:43:44 -07:00
parent fc036b6edd
commit bb67ba13a4

24
conn.go
View File

@ -8,6 +8,13 @@ import "C"
import "unsafe"
import "bytes"
type ClusterStat struct {
Kb uint64
Kb_used uint64
Kb_avail uint64
Num_objects uint64
}
type Conn struct {
cluster C.rados_t
}
@ -129,3 +136,20 @@ func (c *Conn) WaitForLatestOSDMap() error {
return nil
}
}
// GetClusterStat returns statistics about the cluster. It returns an error,
// if any.
func (c *Conn) GetClusterStats() (stat ClusterStat, err error) {
c_stat := C.struct_rados_cluster_stat_t{}
ret := C.rados_cluster_stat(c.cluster, &c_stat)
if ret < 0 {
return ClusterStat{}, RadosError(int(ret))
} else {
return ClusterStat{
Kb: uint64(c_stat.kb),
Kb_used: uint64(c_stat.kb_used),
Kb_avail: uint64(c_stat.kb_avail),
Num_objects: uint64(c_stat.num_objects),
}, nil
}
}