summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <jecluis@gmail.com>2013-08-22 16:05:17 +0100
committerJoao Eduardo Luis <jecluis@gmail.com>2013-08-24 14:16:11 +0100
commit46fb86aaab30a1c1c99fc12181055069f39c4a64 (patch)
tree37caadf63767643d6f736f86f6f8d496ff6a6259
parent9a1badf16073b3abe4f39f32a8a118a75393b2ca (diff)
downloadceph-46fb86aaab30a1c1c99fc12181055069f39c4a64.tar.gz
mon: mon_types: DataStats: add 'dump(Formatter*)' method
... and use it on DataHealthService.cc, instead of building our own version of the classes' formatted output. Signed-off-by: Joao Eduardo Luis <jecluis@gmail.com>
-rw-r--r--src/mon/DataHealthService.cc10
-rw-r--r--src/mon/mon_types.h13
2 files changed, 15 insertions, 8 deletions
diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc
index 6e8aa313a36..e74e00864cc 100644
--- a/src/mon/DataHealthService.cc
+++ b/src/mon/DataHealthService.cc
@@ -95,18 +95,14 @@ health_status_t DataHealthService::get_health(
if (f) {
f->open_object_section("mon");
f->dump_string("name", mon_name.c_str());
- f->dump_int("kb_total", stats.kb_total);
- f->dump_int("kb_used", stats.kb_used);
- f->dump_int("kb_avail", stats.kb_avail);
- f->dump_int("avail_percent", stats.latest_avail_percent);
- f->dump_stream("last_updated") << stats.last_update;
+ stats.dump(f);
f->dump_stream("health") << health_status;
if (health_status != HEALTH_OK)
- f->dump_string("health_detail", health_detail);
+ f->dump_string("health_detail", health_detail);
f->close_section();
}
}
-
+
if (f) {
f->close_section(); // mons
f->close_section(); // data_health
diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h
index 0eae3b172bf..f94f6c7e33e 100644
--- a/src/mon/mon_types.h
+++ b/src/mon/mon_types.h
@@ -50,6 +50,18 @@ struct DataStats {
int latest_avail_percent;
utime_t last_update;
+ void dump(Formatter *f) const {
+ assert(f != NULL);
+ f->open_object_section("data_stats");
+ f->dump_int("kb_total", kb_total);
+ f->dump_int("kb_used", kb_used);
+ f->dump_int("kb_avail", kb_avail);
+ f->dump_int("avail_percent", latest_avail_percent);
+ f->dump_stream("last_updated") << last_update;
+
+ f->close_section();
+ }
+
void encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
::encode(kb_total, bl);
@@ -69,7 +81,6 @@ struct DataStats {
DECODE_FINISH(p);
}
};
-
WRITE_CLASS_ENCODER(DataStats);
struct ScrubResult {