]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: show count of active/total nvmeof gws in "ceph -s"
authorVallari Agrawal <vallari.agrawal@ibm.com>
Wed, 5 Feb 2025 11:59:07 +0000 (17:29 +0530)
committerVallari Agrawal <vallari.agrawal@ibm.com>
Wed, 26 Feb 2025 07:40:51 +0000 (13:10 +0530)
Improve "ceph status" output for nvmeof service:

1. Group by service_id (<pool>.<group>) instead of
  just by gateway groups.
2. Show total gateway count from NVMeofGwMap, and count
  of active gateways.

New output:
```
  services:
    mon:                     4 daemons, quorum ceph-nvme-vm31,ceph-nvme-vm28,ceph-nvme-vm30,ceph-nvme-vm29 (age 16m)
    mgr:                     ceph-nvme-vm31.wnfclf(active, since 18m), standbys: ceph-nvme-vm29.iuwqin, ceph-nvme-vm28.lnnyui, ceph-nvme-vm30.fitwnw
    osd:                     4 osds: 4 up (since 14m), 4 in (since 15m)
    nvmeof (mypool.mygroup1): 2 gateways: 1 active (ceph-nvme-vm30.kkcfux)
    nvmeof (mypool.mygroup2): 2 gateways: 2 active (ceph-nvme-vm28.mfqucr, ceph-nvme-vm29.hrizzl)
```

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

index 7483de4c7975a5064a3f0ef02bf1ed2a1c03d799..7cd8e076b22b99e80ac1bc5e0a7cf70ba214849b 100644 (file)
@@ -3106,15 +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;
+      std::map<NvmeGroupKey, std::set<std::string>> nvmeof_services;
       for (auto& p : service_map.services) {
         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); 
+            auto pool = d.second.metadata.find("pool_name"); 
+            auto gw_id = d.second.metadata.find("id");
+            NvmeGroupKey group_key = std::make_pair(pool->second,  group->second); 
+            nvmeof_services[group_key].insert(gw_id->second);
+            maxlen = std::max(maxlen, 
+                p.first.size() + group->second.size() + pool->second.size() + 4
+              ); // nvmeof (pool.group):
           }
         } else {
           maxlen = std::max(maxlen, p.first.size());
@@ -3165,12 +3169,20 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
           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()) {
+          auto created_gws = nvmegwmon()->get_map().created_gws;
+          for (const auto& created_map_pair: created_gws) {
+            const auto& group_key = created_map_pair.first;
+            const NvmeGwMonStates& gw_created_map = created_map_pair.second;
+            const int total = gw_created_map.size();
+            auto& active_gws = nvmeof_services[group_key];
+
+            ss << "    " << p.first << " (" << group_key.first << "." << group_key.second << "): ";
+            ss << string(maxlen - p.first.size() - group_key.first.size() 
+                    - group_key.second.size() - 4, ' ');
+            ss << total << " gateway" << (total > 1 ? "s" : "") << ": " 
+               << active_gws.size() << " active (";
+            for (auto gw = active_gws.begin(); gw != active_gws.end(); ++gw){
+              if (gw != active_gws.begin()) {
                      ss << ", ";
               }
               ss << *gw; 
index 8cde2af54b1fb621a30e92d43c4452f022a1c1b2..714bef95d45498bd41c19f6ed8323a957ad41d7a 100644 (file)
@@ -82,6 +82,8 @@ public:
   void check_subs(bool type);
   void check_sub(Subscription *sub);
   void check_sub_unconditional(Subscription *sub);
+  const NVMeofGwMap& get_map() const { return map; }
 
   std::map<NvmeGroupKey, std::map<NvmeGwId, utime_t>> gws_deleting_time;