]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add 'mgr stat' command
authorSage Weil <sage@newdream.net>
Thu, 21 Jan 2021 23:51:39 +0000 (17:51 -0600)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 29 Jan 2021 12:42:38 +0000 (13:42 +0100)
This is analogous to 'osd stat' and 'mds stat'.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit bb702eda199cf2def81e8277d0a222daafe9df28)

qa/workunits/cephtool/test.sh
src/mon/MgrMap.h
src/mon/MgrMonitor.cc
src/mon/MonCommands.h

index 90a28663d9fe1b54da96d294f57f7b49f1be3713..3c1eb36cb21f3c3e840f90a6dbb7e72434bf809b 100755 (executable)
@@ -751,6 +751,7 @@ function test_mon_misc()
   ceph log last 100 | grep "$mymsg"
   ceph_watch_wait "$mymsg"
 
+  ceph mgr stat
   ceph mgr dump
   ceph mgr module ls
   ceph mgr module enable restful
index aa576f32f7942acb0be76b5161134717610c5502..5342fc51fc3deda4e013fa88672e182e86064914 100644 (file)
@@ -264,6 +264,7 @@ public:
   bool get_available() const { return available; }
   const std::string &get_active_name() const { return active_name; }
   const utime_t& get_active_change() const { return active_change; }
+  int get_num_standby() const { return standbys.size(); }
 
   bool all_support_module(const std::string& module) {
     if (!have_module(module)) {
index 97c36f2924dad34cd9b846409fe8e21673d060b5..7fb8bc3290979eb63f35db5a8d996f4051467324 100644 (file)
@@ -953,7 +953,15 @@ bool MgrMonitor::preprocess_command(MonOpRequestRef op)
   cmd_getval(cmdmap, "prefix", prefix);
   int r = 0;
 
-  if (prefix == "mgr dump") {
+  if (prefix == "mgr stat") {
+    f->open_object_section("stat");
+    f->dump_unsigned("epoch", map.get_epoch());
+    f->dump_bool("available", map.get_available());
+    f->dump_string("active_name", map.get_active_name());
+    f->dump_unsigned("num_standby", map.get_num_standby());
+    f->close_section();
+    f->flush(rdata);
+  } else if (prefix == "mgr dump") {
     int64_t epoch = 0;
     cmd_getval(cmdmap, "epoch", epoch, (int64_t)map.get_epoch());
     if (epoch == (int64_t)map.get_epoch()) {
index 83f007477c0d890ecbd571970234e3303a19e6bb..fc8ab39083b7cb281613e4713eca4e63e0c9a99a 100644 (file)
@@ -1235,6 +1235,9 @@ COMMAND("config-key dump "
 /*
  * mon/MgrMonitor.cc
  */
+COMMAND("mgr stat",
+       "dump basic info about the mgr cluster state",
+       "mgr", "r")
 COMMAND("mgr dump "
        "name=epoch,type=CephInt,range=0,req=false",
        "dump the latest MgrMap",