Skip to content

Commit 5a2aed3

Browse files
authored
Merge pull request ceph#61624 from VallariAg/wip-nvmeof-ceph-status
mon: Add nvmeof group/gateway name in "ceph -s"
2 parents 5a7885a + 3065ffe commit 5a2aed3

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/mon/Monitor.cc

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,8 +3117,23 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
31173117
{
31183118
size_t maxlen = 3;
31193119
auto& service_map = mgrstatmon()->get_service_map();
3120+
std::map<NvmeGroupKey, std::set<std::string>> nvmeof_services;
31203121
for (auto& p : service_map.services) {
3121-
maxlen = std::max(maxlen, p.first.size());
3122+
if (p.first == "nvmeof") {
3123+
auto daemons = p.second.daemons;
3124+
for (auto& d : daemons) {
3125+
auto group = d.second.metadata.find("group");
3126+
auto pool = d.second.metadata.find("pool_name");
3127+
auto gw_id = d.second.metadata.find("id");
3128+
NvmeGroupKey group_key = std::make_pair(pool->second, group->second);
3129+
nvmeof_services[group_key].insert(gw_id->second);
3130+
maxlen = std::max(maxlen,
3131+
p.first.size() + group->second.size() + pool->second.size() + 4
3132+
); // nvmeof (pool.group):
3133+
}
3134+
} else {
3135+
maxlen = std::max(maxlen, p.first.size());
3136+
}
31223137
}
31233138
string spacing(maxlen - 3, ' ');
31243139
const auto quorum_names = get_quorum_names();
@@ -3164,8 +3179,31 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
31643179
if (ServiceMap::is_normal_ceph_entity(service)) {
31653180
continue;
31663181
}
3182+
if (p.first == "nvmeof") {
3183+
auto created_gws = nvmegwmon()->get_map().created_gws;
3184+
for (const auto& created_map_pair: created_gws) {
3185+
const auto& group_key = created_map_pair.first;
3186+
const NvmeGwMonStates& gw_created_map = created_map_pair.second;
3187+
const int total = gw_created_map.size();
3188+
auto& active_gws = nvmeof_services[group_key];
3189+
3190+
ss << " " << p.first << " (" << group_key.first << "." << group_key.second << "): ";
3191+
ss << string(maxlen - p.first.size() - group_key.first.size()
3192+
- group_key.second.size() - 4, ' ');
3193+
ss << total << " gateway" << (total > 1 ? "s" : "") << ": "
3194+
<< active_gws.size() << " active (";
3195+
for (auto gw = active_gws.begin(); gw != active_gws.end(); ++gw){
3196+
if (gw != active_gws.begin()) {
3197+
ss << ", ";
3198+
}
3199+
ss << *gw;
3200+
}
3201+
ss << ") \n";
3202+
}
3203+
} else {
31673204
ss << " " << p.first << ": " << string(maxlen - p.first.size(), ' ')
31683205
<< p.second.get_summary() << "\n";
3206+
}
31693207
}
31703208
}
31713209

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)