From af2e633ea0a68802d2b70dab9a54bdb56bc3ce4c Mon Sep 17 00:00:00 2001 From: svenwiltink Date: Wed, 2 Jan 2019 22:06:54 +0100 Subject: [PATCH] Add read and write op per second fields (#5210) --- plugins/inputs/ceph/README.md | 8 ++++++-- plugins/inputs/ceph/ceph.go | 32 ++++++++++++++++++++------------ plugins/inputs/ceph/ceph_test.go | 32 +++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/plugins/inputs/ceph/README.md b/plugins/inputs/ceph/README.md index 8d04c54b28f41..c53f908ab413e 100644 --- a/plugins/inputs/ceph/README.md +++ b/plugins/inputs/ceph/README.md @@ -108,7 +108,9 @@ All fields are collected under the **ceph** measurement and stored as float64s. * bytes\_used (float) * data\_bytes (float) * num\_pgs (float) - * op\_per\_sec (float) + * op\_per\_sec (float, ceph < 10) + * read_op\_per\_sec (float) + * write_op\_per\_sec (float) * read\_bytes\_sec (float) * version (float) * write\_bytes\_sec (float) @@ -132,7 +134,9 @@ All fields are collected under the **ceph** measurement and stored as float64s. * objects (float) * ceph\_pool\_stats - * op\_per\_sec (float) + * op\_per\_sec (float, ceph < 10) + * read_op\_per\_sec (float) + * write_op\_per\_sec (float) * read\_bytes\_sec (float) * write\_bytes\_sec (float) * recovering\_object\_per\_sec (float) diff --git a/plugins/inputs/ceph/ceph.go b/plugins/inputs/ceph/ceph.go index 95f50958c6d9f..b6a6c5c080b4b 100644 --- a/plugins/inputs/ceph/ceph.go +++ b/plugins/inputs/ceph/ceph.go @@ -344,7 +344,9 @@ type CephStatus struct { BytesTotal float64 `json:"bytes_total"` ReadBytesSec float64 `json:"read_bytes_sec"` WriteBytesSec float64 `json:"write_bytes_sec"` - OpPerSec float64 `json:"op_per_sec"` + OpPerSec float64 `json:"op_per_sec"` // This field is no longer reported in ceph 10 and later + ReadOpPerSec float64 `json:"read_op_per_sec"` + WriteOpPerSec float64 `json:"write_op_per_sec"` } `json:"pgmap"` } @@ -388,15 +390,17 @@ func decodeStatusOsdmap(acc telegraf.Accumulator, data *CephStatus) error { // decodeStatusPgmap decodes the PG map portion of the output of 'ceph -s' func decodeStatusPgmap(acc telegraf.Accumulator, data *CephStatus) error { fields := map[string]interface{}{ - "version": data.PGMap.Version, - "num_pgs": data.PGMap.NumPGs, - "data_bytes": data.PGMap.DataBytes, - "bytes_used": data.PGMap.BytesUsed, - "bytes_avail": data.PGMap.BytesAvail, - "bytes_total": data.PGMap.BytesTotal, - "read_bytes_sec": data.PGMap.ReadBytesSec, - "write_bytes_sec": data.PGMap.WriteBytesSec, - "op_per_sec": data.PGMap.OpPerSec, + "version": data.PGMap.Version, + "num_pgs": data.PGMap.NumPGs, + "data_bytes": data.PGMap.DataBytes, + "bytes_used": data.PGMap.BytesUsed, + "bytes_avail": data.PGMap.BytesAvail, + "bytes_total": data.PGMap.BytesTotal, + "read_bytes_sec": data.PGMap.ReadBytesSec, + "write_bytes_sec": data.PGMap.WriteBytesSec, + "op_per_sec": data.PGMap.OpPerSec, // This field is no longer reported in ceph 10 and later + "read_op_per_sec": data.PGMap.ReadOpPerSec, + "write_op_per_sec": data.PGMap.WriteOpPerSec, } acc.AddFields("ceph_pgmap", fields, map[string]string{}) return nil @@ -470,7 +474,9 @@ type CephOSDPoolStats []struct { ClientIORate struct { ReadBytesSec float64 `json:"read_bytes_sec"` WriteBytesSec float64 `json:"write_bytes_sec"` - OpPerSec float64 `json:"op_per_sec"` + OpPerSec float64 `json:"op_per_sec"` // This field is no longer reported in ceph 10 and later + ReadOpPerSec float64 `json:"read_op_per_sec"` + WriteOpPerSec float64 `json:"write_op_per_sec"` } `json:"client_io_rate"` RecoveryRate struct { RecoveringObjectsPerSec float64 `json:"recovering_objects_per_sec"` @@ -494,7 +500,9 @@ func decodeOsdPoolStats(acc telegraf.Accumulator, input string) error { fields := map[string]interface{}{ "read_bytes_sec": pool.ClientIORate.ReadBytesSec, "write_bytes_sec": pool.ClientIORate.WriteBytesSec, - "op_per_sec": pool.ClientIORate.OpPerSec, + "op_per_sec": pool.ClientIORate.OpPerSec, // This field is no longer reported in ceph 10 and later + "read_op_per_sec": pool.ClientIORate.ReadOpPerSec, + "write_op_per_sec": pool.ClientIORate.WriteOpPerSec, "recovering_objects_per_sec": pool.RecoveryRate.RecoveringObjectsPerSec, "recovering_bytes_per_sec": pool.RecoveryRate.RecoveringBytesPerSec, "recovering_keys_per_sec": pool.RecoveryRate.RecoveringKeysPerSec, diff --git a/plugins/inputs/ceph/ceph_test.go b/plugins/inputs/ceph/ceph_test.go index a0365c8fbccfe..ee2f96491d47a 100644 --- a/plugins/inputs/ceph/ceph_test.go +++ b/plugins/inputs/ceph/ceph_test.go @@ -835,7 +835,9 @@ var clusterStatusDump = ` "bytes_total": 17335810048000, "read_bytes_sec": 0, "write_bytes_sec": 367217, - "op_per_sec": 98 + "op_per_sec": 98, + "read_op_per_sec": 322, + "write_op_per_sec": 1022 }, "mdsmap": { "epoch": 1, @@ -864,15 +866,17 @@ var cephStatusResults = []expectedResult{ { metric: "ceph_pgmap", fields: map[string]interface{}{ - "version": float64(52314277), - "num_pgs": float64(2560), - "data_bytes": float64(2700031960713), - "bytes_used": float64(7478347665408), - "bytes_avail": float64(9857462382592), - "bytes_total": float64(17335810048000), - "read_bytes_sec": float64(0), - "write_bytes_sec": float64(367217), - "op_per_sec": float64(98), + "version": float64(52314277), + "num_pgs": float64(2560), + "data_bytes": float64(2700031960713), + "bytes_used": float64(7478347665408), + "bytes_avail": float64(9857462382592), + "bytes_total": float64(17335810048000), + "read_bytes_sec": float64(0), + "write_bytes_sec": float64(367217), + "op_per_sec": float64(98), + "read_op_per_sec": float64(322), + "write_op_per_sec": float64(1022), }, tags: map[string]string{}, }, @@ -1014,7 +1018,9 @@ var cephODSPoolStatsDump = ` "recovering_keys_per_sec": 0}, "client_io_rate": { "read_bytes_sec": 10566067, "write_bytes_sec": 15165220376, - "op_per_sec": 9828}}]` + "op_per_sec": 9828, + "read_op_per_sec": 182, + "write_op_per_sec": 473}}]` var cephOSDPoolStatsResults = []expectedResult{ { @@ -1023,6 +1029,8 @@ var cephOSDPoolStatsResults = []expectedResult{ "read_bytes_sec": float64(0), "write_bytes_sec": float64(0), "op_per_sec": float64(0), + "read_op_per_sec": float64(0), + "write_op_per_sec": float64(0), "recovering_objects_per_sec": float64(0), "recovering_bytes_per_sec": float64(0), "recovering_keys_per_sec": float64(0), @@ -1037,6 +1045,8 @@ var cephOSDPoolStatsResults = []expectedResult{ "read_bytes_sec": float64(10566067), "write_bytes_sec": float64(15165220376), "op_per_sec": float64(9828), + "read_op_per_sec": float64(182), + "write_op_per_sec": float64(473), "recovering_objects_per_sec": float64(279), "recovering_bytes_per_sec": float64(176401059), "recovering_keys_per_sec": float64(0),