mon: add a column 'RAW USED' for ceph df detail

Signed-off-by: Ruifeng Yang <yangruifeng.09209@h3c.com>
This commit is contained in:
Ruifeng Yang 2016-01-12 22:08:41 +08:00
parent 4dd0d1bd01
commit 2b597ae6d4
3 changed files with 42 additions and 4 deletions

View File

@ -1751,6 +1751,30 @@ function test_mon_deprecated_commands()
ceph tell mon.a injectargs '--no-mon-debug-deprecated-as-obsolete'
}
function test_mon_cephdf_commands()
{
# ceph df detail:
# pool section:
# RAW USED The near raw used per pool in raw total
ceph osd pool create cephdf_for_test 32 32 replicated
ceph osd pool set cephdf_for_test size 2
dd if=/dev/zero of=./cephdf_for_test bs=4k count=1
rados put cephdf_for_test cephdf_for_test -p cephdf_for_test
#wait for update
sleep 10
cal_raw_used_size=`ceph df detail | grep cephdf_for_test | awk -F ' ' '{printf "%d\n", 2 * $4}'`
raw_used_size=`ceph df detail | grep cephdf_for_test | awk -F ' ' '{print $11}'`
ceph osd pool delete cephdf_for_test cephdf_for_test --yes-i-really-really-mean-it
rm ./cephdf_for_test
expect_false test $cal_raw_used_size != $raw_used_size
}
#
# New tests should be added to the TESTS array below
#
@ -1795,6 +1819,7 @@ OSD_TESTS+=" tiering_agent"
MDS_TESTS+=" mds_tell"
MDS_TESTS+=" mon_mds"
MDS_TESTS+=" mon_mds_metadata"
MDS_TESTS+=" mon_cephdf_commands"
TESTS+=$MON_TESTS
TESTS+=$OSD_TESTS

View File

@ -1333,8 +1333,12 @@ inline string percentify(const float& a) {
//void PGMonitor::dump_object_stat_sum(stringstream& ss, Formatter *f,
void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
object_stat_sum_t &sum, uint64_t avail,
bool verbose) const
float raw_used_rate, bool verbose) const
{
float curr_object_copies_rate = 0.0;
if (sum.num_object_copies > 0)
curr_object_copies_rate = (float)(sum.num_object_copies - sum.num_objects_degraded) / sum.num_object_copies;
if (f) {
f->dump_int("kb_used", SHIFT_ROUND_UP(sum.num_bytes, 10));
f->dump_int("bytes_used", sum.num_bytes);
@ -1346,6 +1350,7 @@ void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
f->dump_int("rd_bytes", sum.num_rd_kb * 1024ull);
f->dump_int("wr", sum.num_wr);
f->dump_int("wr_bytes", sum.num_wr_kb * 1024ull);
f->dump_int("raw_bytes_used", sum.num_bytes * raw_used_rate * curr_object_copies_rate);
}
} else {
tbl << stringify(si_t(sum.num_bytes));
@ -1359,7 +1364,8 @@ void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
if (verbose) {
tbl << stringify(si_t(sum.num_objects_dirty))
<< stringify(si_t(sum.num_rd))
<< stringify(si_t(sum.num_wr));
<< stringify(si_t(sum.num_wr))
<< stringify(si_t(sum.num_bytes * raw_used_rate * curr_object_copies_rate));
}
}
}
@ -1416,6 +1422,7 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
tbl.define_column("DIRTY", TextTable::LEFT, TextTable::RIGHT);
tbl.define_column("READ", TextTable::LEFT, TextTable::RIGHT);
tbl.define_column("WRITE", TextTable::LEFT, TextTable::RIGHT);
tbl.define_column("RAW USED", TextTable::LEFT, TextTable::RIGHT);
}
}
@ -1434,6 +1441,7 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
pool->get_type(),
pool->get_size());
int64_t avail;
float raw_used_rate;
if (avail_by_rule.count(ruleno) == 0) {
avail = get_rule_avail(osdmap, ruleno);
if (avail < 0)
@ -1445,6 +1453,7 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
switch (pool->get_type()) {
case pg_pool_t::TYPE_REPLICATED:
avail /= pool->get_size();
raw_used_rate = pool->get_size();
break;
case pg_pool_t::TYPE_ERASURE:
{
@ -1456,6 +1465,9 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
int k = atoi(pk->second.c_str());
int m = atoi(pm->second.c_str());
avail = avail * k / (m + k);
raw_used_rate = (float)(m + k) / k;
} else {
raw_used_rate = 0.0;
}
}
break;
@ -1474,7 +1486,7 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
if (verbose)
tbl << "-";
}
dump_object_stat_sum(tbl, f, stat.stats.sum, avail, verbose);
dump_object_stat_sum(tbl, f, stat.stats.sum, avail, raw_used_rate, verbose);
if (f)
f->close_section(); // stats
else

View File

@ -154,8 +154,9 @@ private:
vector<string>& args) const;
void dump_object_stat_sum(TextTable &tbl, Formatter *f,
object_stat_sum_t &sum,
object_stat_sum_t &sum,
uint64_t avail,
float raw_used_rate,
bool verbose) const;
int64_t get_rule_avail(OSDMap& osdmap, int ruleno) const;