Merge pull request #15925 from jcsp/wip-fsstatus-cleanup

mgr: clean up fsstatus module

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-06-30 09:31:02 +08:00 committed by GitHub
commit 7ee4907698
6 changed files with 40 additions and 8 deletions

View File

@ -182,3 +182,7 @@
replicated rule in the CRUSH map for replicated pools. Erasure
coded pools have rules that are automatically created for them if they are
not specified at pool creation time.
* The `status` ceph-mgr module is enabled by default, and initially provides two
commands: `ceph tell mgr osd status` and `ceph tell mgr fs status`. These
are high level colorized views to complement the existing CLI.

View File

@ -2353,9 +2353,11 @@ function test_mds_tell_help_command()
ceph osd pool delete fs_metadata fs_metadata --yes-i-really-really-mean-it
}
function test_mgr_tell_help_command()
function test_mgr_tell()
{
ceph tell mgr help
ceph tell mgr fs status
ceph tell mgr osd status
}
#
@ -2414,7 +2416,7 @@ MDS_TESTS+=" mon_mds"
MDS_TESTS+=" mon_mds_metadata"
MDS_TESTS+=" mds_tell_help_command"
MGR_TESTS+=" mgr_tell_help_command"
MGR_TESTS+=" mgr_tell"
TESTS+=$MON_TESTS
TESTS+=$OSD_TESTS

View File

@ -1730,7 +1730,7 @@ OPTION(rgw_shard_warning_threshold, OPT_DOUBLE, 90) // pct of safe max
OPTION(rgw_swift_versioning_enabled, OPT_BOOL, false) // whether swift object versioning feature is enabled
OPTION(mgr_module_path, OPT_STR, CEPH_PKGLIBDIR "/mgr") // where to load python modules from
OPTION(mgr_modules, OPT_STR, "restful") // Which modules to load
OPTION(mgr_modules, OPT_STR, "restful status") // Which modules to load
OPTION(mgr_data, OPT_STR, "/var/lib/ceph/mgr/$cluster-$id") // where to find keyring etc
OPTION(mgr_tick_period, OPT_INT, 2) // How frequently to tick
OPTION(mgr_stats_period, OPT_INT, 5) // How frequently clients send stats

View File

@ -6,6 +6,8 @@ High level status display commands
from collections import defaultdict
from prettytable import PrettyTable
import prettytable
import fnmatch
import errno
from mgr_module import MgrModule
@ -19,7 +21,7 @@ class Module(MgrModule):
"perm": "r"
},
{
"cmd": "osd perf "
"cmd": "osd status "
"name=bucket,type=CephString,req=false",
"desc": "Show the status of OSDs within a bucket, or all",
"perm": "r"
@ -104,10 +106,15 @@ class Module(MgrModule):
def handle_fs_status(self, cmd):
output = ""
fs_filter = cmd.get('fs', None)
mds_versions = defaultdict(list)
fsmap = self.get("fs_map")
for filesystem in fsmap['filesystems']:
if fs_filter and filesystem['mdsmap']['fs_name'] != fs_filter:
continue
rank_table = PrettyTable(
("Rank", "State", "MDS", "Activity", "dns", "inos"),
hrules=prettytable.FRAME
@ -234,15 +241,34 @@ class Module(MgrModule):
return 0, "", output
def handle_osd_perf(self, cmd):
def handle_osd_status(self, cmd):
osd_table = PrettyTable(['id', 'host', 'used', 'avail', 'wr ops', 'wr data', 'rd ops', 'rd data'])
osdmap = self.get("osd_map")
filter_osds = set()
bucket_filter = None
if 'bucket' in cmd:
self.log.debug("Filtering to bucket '{0}'".format(cmd['bucket']))
bucket_filter = cmd['bucket']
crush = self.get("osd_map_crush")
found = False
for bucket in crush['buckets']:
if fnmatch.fnmatch(bucket['name'], bucket_filter):
found = True
filter_osds.update([i['id'] for i in bucket['items']])
if not found:
msg = "Bucket '{0}' not found".format(bucket_filter)
return errno.ENOENT, msg, ""
# Build dict of OSD ID to stats
osd_stats = dict([(o['osd'], o) for o in self.get("osd_stats")['osd_stats']])
for osd in osdmap['osds']:
osd_id = osd['osd']
if bucket_filter and osd_id not in filter_osds:
continue
metadata = self.get_metadata('osd', "%s" % osd_id)
stats = osd_stats[osd_id]
@ -263,8 +289,8 @@ class Module(MgrModule):
if cmd['prefix'] == "fs status":
return self.handle_fs_status(cmd)
elif cmd['prefix'] == "osd perf":
return self.handle_osd_perf(cmd)
elif cmd['prefix'] == "osd status":
return self.handle_osd_status(cmd)
else:
# mgr should respect our self.COMMANDS and not call us for
# any prefix we don't advertise

View File

@ -458,7 +458,7 @@ $CMDSDEBUG
mds root ino gid = `id -g`
$extra_conf
[mgr]
mgr modules = restful fsstatus dashboard
mgr modules = restful status dashboard
mgr data = $CEPH_DEV_DIR/mgr.\$id
mgr module path = $MGR_PYTHON_PATH
mon reweight min pgs per osd = 4