Skip to content

Commit 3065ffe

Browse files
committed
mon: show count of active/total nvmeof gws in "ceph -s"
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 <[email protected]>
1 parent e3fab2a commit 3065ffe

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/mon/Monitor.cc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,15 +3106,19 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
31063106
{
31073107
size_t maxlen = 3;
31083108
auto& service_map = mgrstatmon()->get_service_map();
3109-
std::map<std::string, std::set<std::string>> nvmeof_groups;
3109+
std::map<NvmeGroupKey, std::set<std::string>> nvmeof_services;
31103110
for (auto& p : service_map.services) {
31113111
if (p.first == "nvmeof") {
31123112
auto daemons = p.second.daemons;
31133113
for (auto& d : daemons) {
31143114
auto group = d.second.metadata.find("group");
3115-
auto gw_id = d.second.metadata.find("id");
3116-
nvmeof_groups[group->second].insert(gw_id->second);
3117-
maxlen = std::max(maxlen, p.first.size() + group->second.size() + 3);
3115+
auto pool = d.second.metadata.find("pool_name");
3116+
auto gw_id = d.second.metadata.find("id");
3117+
NvmeGroupKey group_key = std::make_pair(pool->second, group->second);
3118+
nvmeof_services[group_key].insert(gw_id->second);
3119+
maxlen = std::max(maxlen,
3120+
p.first.size() + group->second.size() + pool->second.size() + 4
3121+
); // nvmeof (pool.group):
31183122
}
31193123
} else {
31203124
maxlen = std::max(maxlen, p.first.size());
@@ -3165,12 +3169,20 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
31653169
continue;
31663170
}
31673171
if (p.first == "nvmeof") {
3168-
for (auto& group : nvmeof_groups) {
3169-
ss << " " << p.first << " (" << group.first << "): ";
3170-
ss << string(maxlen - p.first.size() - group.first.size() - 3, ' ');
3171-
ss << group.second.size() << " gateway" << (group.second.size() ? "s" : "") << " active (";
3172-
for (auto gw = group.second.begin(); gw != group.second.end(); ++gw){
3173-
if (gw != group.second.begin()) {
3172+
auto created_gws = nvmegwmon()->get_map().created_gws;
3173+
for (const auto& created_map_pair: created_gws) {
3174+
const auto& group_key = created_map_pair.first;
3175+
const NvmeGwMonStates& gw_created_map = created_map_pair.second;
3176+
const int total = gw_created_map.size();
3177+
auto& active_gws = nvmeof_services[group_key];
3178+
3179+
ss << " " << p.first << " (" << group_key.first << "." << group_key.second << "): ";
3180+
ss << string(maxlen - p.first.size() - group_key.first.size()
3181+
- group_key.second.size() - 4, ' ');
3182+
ss << total << " gateway" << (total > 1 ? "s" : "") << ": "
3183+
<< active_gws.size() << " active (";
3184+
for (auto gw = active_gws.begin(); gw != active_gws.end(); ++gw){
3185+
if (gw != active_gws.begin()) {
31743186
ss << ", ";
31753187
}
31763188
ss << *gw;

src/mon/NVMeofGwMon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class NVMeofGwMon: public PaxosService,
8282
void check_subs(bool type);
8383
void check_sub(Subscription *sub);
8484
void check_sub_unconditional(Subscription *sub);
85+
86+
const NVMeofGwMap& get_map() const { return map; }
8587

8688
std::map<NvmeGroupKey, std::map<NvmeGwId, utime_t>> gws_deleting_time;
8789

0 commit comments

Comments
 (0)