Skip to content

Commit

Permalink
Merge pull request #14810 from liewegas/wip-status
Browse files Browse the repository at this point in the history
mon: show inactive % in ceph status

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
yuriw committed May 2, 2017
2 parents 76e94a0 + ae2241f commit 3dbc29b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
21 changes: 21 additions & 0 deletions src/mon/PGMap.cc
Expand Up @@ -337,6 +337,7 @@ void PGMap::calc_stats()
{
num_pg_by_state.clear();
num_pg = 0;
num_pg_active = 0;
num_osd = 0;
pg_pool_sum.clear();
pg_sum = pool_stat_t();
Expand Down Expand Up @@ -457,6 +458,10 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s,
}
}

if (s.state & PG_STATE_ACTIVE) {
++num_pg_active;
}

if (sameosds)
return;

Expand Down Expand Up @@ -500,6 +505,10 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s,
}
}

if (s.state & PG_STATE_ACTIVE) {
--num_pg_active;
}

if (sameosds)
return;

Expand Down Expand Up @@ -1657,6 +1666,18 @@ void PGMap::print_summary(Formatter *f, ostream *out) const
<< kb_t(osd_sum.kb) << " avail\n";
}


if (num_pg_active < num_pg) {
float p = (float)num_pg_active / (float)num_pg;
if (f) {
f->dump_float("active_pgs_ratio", p);
} else {
char b[20];
snprintf(b, sizeof(b), "%.3lf", (1.0 - p) * 100.0);
*out << " " << b << "% pgs inactive\n";
}
}

list<string> sl;
overall_recovery_summary(f, &sl);
if (!f && !sl.empty()) {
Expand Down
10 changes: 4 additions & 6 deletions src/mon/PGMap.h
Expand Up @@ -117,11 +117,12 @@ class PGMap {

// aggregate stats (soft state), generated by calc_stats()
ceph::unordered_map<int,int> num_pg_by_state;
int64_t num_pg, num_osd;
int64_t num_pg = 0, num_osd = 0;
int64_t num_pg_active = 0;
ceph::unordered_map<int,pool_stat_t> pg_pool_sum;
pool_stat_t pg_sum;
osd_stat_t osd_sum;
mutable epoch_t min_last_epoch_clean;
mutable epoch_t min_last_epoch_clean = 0;
ceph::unordered_map<int,int> blocked_by_sum;
ceph::unordered_map<int,set<pg_t> > pg_by_osd;

Expand Down Expand Up @@ -198,10 +199,7 @@ class PGMap {
PGMap()
: version(0),
last_osdmap_epoch(0), last_pg_scan(0),
full_ratio(0), nearfull_ratio(0),
num_pg(0),
num_osd(0),
min_last_epoch_clean(0)
full_ratio(0), nearfull_ratio(0)
{}

void set_full_ratios(float full, float nearfull) {
Expand Down

0 comments on commit 3dbc29b

Please sign in to comment.