]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: Add nvmeof group/gateway name in "ceph -s"
authorVallari Agrawal <vallari.agrawal@ibm.com>
Sat, 1 Feb 2025 16:08:22 +0000 (21:38 +0530)
committerVallari Agrawal <vallari.agrawal@ibm.com>
Wed, 26 Feb 2025 07:36:20 +0000 (13:06 +0530)
In "ceph status" command output, show gateway
group names and gateway names.

Before:
```
  services:
    mon:    4 daemons, quorum ceph-nvme-vm8,ceph-nvme-vm1,ceph-nvme-vm7,ceph-nvme-vm6 (age 71m)
    mgr:    ceph-nvme-vm8.tgytdq(active, since 73m), standbys: ceph-nvme-vm6.tequqo, ceph-nvme-vm1.pxrofr, ceph-nvme-vm7.lbxrea
    osd:    4 osds: 4 up (since 70m), 4 in (since 70m)
    nvmeof: 4 gateways active (4 hosts)
```

After:
```
  services:
    mon:               4 daemons, quorum ceph-nvme-vm14,ceph-nvme-vm11,ceph-nvme-vm13,ceph-nvme-vm12 (age 17m)
    mgr:               ceph-nvme-vm14.gjjgvq(active, since 19m), standbys: ceph-nvme-vm12.shbvpw, ceph-nvme-vm11.gucgiu, ceph-nvme-vm13.inzizw
    osd:               4 osds: 4 up (since 15m), 4 in (since 16m)
    nvmeof (mygroup1) : 2 gateways active (ceph-nvme-vm13.azfdpk, ceph-nvme-vm14.hdsoxl)
    nvmeof (mygroup2) : 2 gateways active (ceph-nvme-vm11.hnooxs, ceph-nvme-vm12.wcjcjs)
```

Signed-off-by: Vallari Agrawal <vallari.agrawal@ibm.com>
src/mon/Monitor.cc

index 7226d0f26d19f65c4f1a330ab2f72167c4a53f23..7483de4c7975a5064a3f0ef02bf1ed2a1c03d799 100644 (file)
@@ -3106,8 +3106,19 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
     {
       size_t maxlen = 3;
       auto& service_map = mgrstatmon()->get_service_map();
+      std::map<std::string, std::set<std::string>> nvmeof_groups;
       for (auto& p : service_map.services) {
-       maxlen = std::max(maxlen, p.first.size());
+        if (p.first == "nvmeof") {
+          auto daemons = p.second.daemons;
+          for (auto& d : daemons) {
+            auto group = d.second.metadata.find("group");
+            auto gw_id = d.second.metadata.find("id"); 
+            nvmeof_groups[group->second].insert(gw_id->second);
+            maxlen = std::max(maxlen, p.first.size() + group->second.size() + 3); 
+          }
+        } else {
+          maxlen = std::max(maxlen, p.first.size());
+        }
       }
       string spacing(maxlen - 3, ' ');
       const auto quorum_names = get_quorum_names();
@@ -3153,8 +3164,23 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
         if (ServiceMap::is_normal_ceph_entity(service)) {
           continue;
         }
+        if (p.first == "nvmeof") {
+          for (auto& group : nvmeof_groups) {
+            ss << "    " << p.first << " (" << group.first << "): ";
+            ss << string(maxlen - p.first.size() - group.first.size() - 3, ' ');
+            ss << group.second.size() << " gateway" << (group.second.size() ? "s" : "") << " active (";
+            for (auto gw = group.second.begin(); gw != group.second.end(); ++gw){
+              if (gw != group.second.begin()) {
+                     ss << ", ";
+              }
+              ss << *gw; 
+            }
+            ss << ") \n";
+          }
+        } else {
        ss << "    " << p.first << ": " << string(maxlen - p.first.size(), ' ')
           << p.second.get_summary() << "\n";
+        }
       }
     }