modified as commented on code review

This commit is contained in:
madz 2015-07-03 16:17:49 +08:00
parent 5ae390066f
commit cfb92e0e37
2 changed files with 46 additions and 40 deletions

View File

@ -136,11 +136,11 @@ func (ceph *CephMetrics) getCommon(acc plugins.Accumulator) {
quorumValueMap["members"] = strings.Join(quorum_name, ",")
//clientIOs
sumOps := int64(0)
sumWrs := int64(0)
var sumOps int64 = 0
var sumWrs int64 = 0
for _, stat := range poolStatsList {
sumOps += int64(stat.ClientIoRate.OpsPerSec)
sumWrs += int64(stat.ClientIoRate.WriteBytesPerSecond) / 1024
sumOps += stat.ClientIoRate.OpsPerSec
sumWrs += stat.ClientIoRate.WriteBytesPerSecond / 1024
}
// OSD Epoch
@ -269,7 +269,7 @@ func (ceph *CephMetrics) getPg(acc plugins.Accumulator) {
}
for poolId, osdPgMap := range poolOsdPgMap {
poolPg := int64(0)
var poolPg int64 = 0
for osdId, pgs := range osdPgMap {
tags := map[string]string{"cluster": ceph.Cluster, "pool": fmt.Sprintf("%d", poolId), "osd": fmt.Sprintf("%d", osdId)}
poolPg += pgs
@ -346,8 +346,8 @@ func (ceph *CephMetrics) getOSDDaemon(acc plugins.Accumulator) {
tag := map[string]string{"cluster": ceph.Cluster, "osd": fmt.Sprintf("%d", osdNum)}
acc.Add("osd_utilization", utilized, tag)
acc.Add("osd_used", utilized, tag)
acc.Add("osd_total", total, tag)
acc.Add("osd_used_storage", used, tag)
acc.Add("osd_total_storage", total, tag)
}
//OSD Commit and Apply Latency

View File

@ -24,46 +24,52 @@ func TestCephGenerateMetrics(t *testing.T) {
assert.Equal(t, p.Cluster, "ceph", "Same Cluster")
intMetrics := []string{
"total_storage",
"used_storage",
"available_storage",
"client_io_kbs",
"client_io_ops",
"pool_used",
"pool_usedKb",
"pool_maxbytes",
"pool_objects",
"osd_epoch",
"op_in_bytes",
"op_out_bytes",
"op_r",
"op_w",
"op_w_in_bytes",
"op_rw",
"op_rw_in_bytes",
"op_rw_out_bytes",
"pg_map_count",
"pg_data_bytes",
"pg_data_avail",
// "osd_count",
// "osd_utilization",
// "total_storage",
// "used",
// "available",
// "client_io_kbs",
// "client_io_ops",
// "pool_used",
// "pool_usedKb",
// "pool_maxbytes",
// "pool_utilization",
// "osd_used",
// "osd_total",
// "osd_epoch",
// "osd_latency_commit",
// "osd_latency_apply",
// "op",
// "op_in_bytes",
// "op_out_bytes",
// "op_r",
// "op_r_out_byes",
// "op_w",
// "op_w_in_bytes",
// "op_rw",
// "op_rw_in_bytes",
// "op_rw_out_bytes",
// "pool_objects",
// "pg_map_count",
"pg_data_bytes",
"pg_data_avail",
"pg_data_total",
"pg_data_used",
"pg_data_total_storage",
"pg_data_used_storage",
"pg_distribution",
"pg_distribution_pool",
"pg_distribution_osd",
}
floatMetrics := []string{
"osd_utilization",
"pool_utilization",
"osd_used_storage",
"osd_total_storage",
}
for _, metric := range intMetrics {
assert.True(t, acc.HasIntValue(metric))
}
for _, metric := range floatMetrics {
assert.True(t, acc.HasFloatValue(metric))
}
}
func TestCephGenerateMetricsDefault(t *testing.T) {