]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmaptool: add --health option 16221/head
authorSage Weil <sage@redhat.com>
Mon, 10 Jul 2017 22:31:49 +0000 (18:31 -0400)
committerSage Weil <sage@redhat.com>
Thu, 13 Jul 2017 16:15:26 +0000 (12:15 -0400)
Generate and dump health checks.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/cli/osdmaptool/help.t
src/test/cli/osdmaptool/missing-argument.t
src/tools/osdmaptool.cc

index 06e20fcb8902f4aec7973719962a8c3a704adfa6..e3e6cd091fc15638fa5501f2245b0751bfbe11e0 100644 (file)
@@ -6,6 +6,7 @@
      --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
      --test-map-pgs-dump [--pool <poolid>] map all pgs
      --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
+     --health                dump health checks
      --mark-up-in            mark osds up and in (but do not persist)
      --with-default-pool     include default pool when creating map
      --clear-temp            clear pg_temp and primary_temp
index 84f872070aaaab7454b258c1b574926c5c9b1d0b..97ed692cb81eeb872e9b7ecaf3c402737e91b1e1 100644 (file)
@@ -6,6 +6,7 @@
      --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
      --test-map-pgs-dump [--pool <poolid>] map all pgs
      --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
+     --health                dump health checks
      --mark-up-in            mark osds up and in (but do not persist)
      --with-default-pool     include default pool when creating map
      --clear-temp            clear pg_temp and primary_temp
index 27a137af9d46e574e652d15b64e2916e3fdcc701..e5b75917e5c753b03562fe245eafa78c047440c2 100644 (file)
@@ -18,6 +18,7 @@
 #include "common/ceph_argparse.h"
 #include "common/errno.h"
 #include "common/safe_io.h"
+#include "mon/health_check.h"
 
 #include "global/global_init.h"
 #include "osd/OSDMap.h"
@@ -32,6 +33,7 @@ void usage()
   cout << "   --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs" << std::endl;
   cout << "   --test-map-pgs-dump [--pool <poolid>] map all pgs" << std::endl;
   cout << "   --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds" << std::endl;
+  cout << "   --health                dump health checks" << std::endl;
   cout << "   --mark-up-in            mark osds up and in (but do not persist)" << std::endl;
   cout << "   --with-default-pool     include default pool when creating map" << std::endl;
   cout << "   --clear-temp            clear pg_temp and primary_temp" << std::endl;
@@ -121,6 +123,7 @@ int main(int argc, const char **argv)
   bool upmap_cleanup = false;
   bool upmap = false;
   bool upmap_save = false;
+  bool health = false;
   std::string upmap_file = "-";
   int upmap_max = 100;
   float upmap_deviation = .01;
@@ -164,6 +167,8 @@ int main(int argc, const char **argv)
        exit(EXIT_FAILURE);
       }
       createsimple = true;
+    } else if (ceph_argparse_flag(args, i, "--health", (char*)NULL)) {
+      health = true;
     } else if (ceph_argparse_flag(args, i, "--with-default-pool", (char*)NULL)) {
       createpool = true;
     } else if (ceph_argparse_flag(args, i, "--create-from-conf", (char*)NULL)) {
@@ -608,7 +613,7 @@ int main(int argc, const char **argv)
     }
   }
 
-  if (!print && !tree && !modified &&
+  if (!print && !health && !tree && !modified &&
       export_crush.empty() && import_crush.empty() && 
       test_map_pg.empty() && test_map_object.empty() &&
       !test_map_pgs && !test_map_pgs_dump && !test_map_pgs_dump_all &&
@@ -620,6 +625,13 @@ int main(int argc, const char **argv)
   if (modified)
     osdmap.inc_epoch();
 
+  if (health) {
+    health_check_map_t checks;
+    osdmap.check_health(&checks);
+    JSONFormatter jf(true);
+    jf.dump_object("checks", checks);
+    jf.flush(cout);
+  }
   if (print) {
     if (print_formatter) {
       print_formatter->open_object_section("osdmap");