From: Sage Weil Date: Fri, 5 Feb 2021 21:48:59 +0000 (-0600) Subject: mgr/cephadm: report memory usage, request (limit) in 'orch ps' X-Git-Tag: v16.2.5~115^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5cd4ff876729f8228157319d1e575fc219dbd64;p=ceph.git mgr/cephadm: report memory usage, request (limit) in 'orch ps' Fill in from {osd,mon}_memory_target if no container limit is set. Signed-off-by: Sage Weil (cherry picked from commit 4a8182a60658bfbd7034d8eb03e54dc1b154b165) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index fa904b21e3a..e17c8752416 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1777,6 +1777,11 @@ Then run the following: continue if service_name is not None and service_name != dd.service_name(): continue + if not dd.memory_request and dd.daemon_type in ['osd', 'mon']: + dd.memory_request = cast(Optional[int], self.get_foreign_ceph_option( + dd.name(), + f"{dd.daemon_type}_memory_target" + )) result.append(dd) return result diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index f8d92dea37c..94d03243a04 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -14,7 +14,7 @@ from ceph.deployment.service_spec import PlacementSpec, ServiceSpec from ceph.deployment.hostspec import SpecValidationError from ceph.utils import datetime_now -from mgr_util import to_pretty_timedelta, format_dimless +from mgr_util import to_pretty_timedelta, format_dimless, format_bytes from mgr_module import MgrModule, HandleCommandResult, Option from ._interface import OrchestratorClientMixin, DeviceLightLoc, _cli_read_command, \ @@ -32,6 +32,12 @@ def nice_delta(now: datetime.datetime, t: Optional[datetime.datetime], suffix: s return '-' +def nice_bytes(v: Optional[int]) -> str: + if not v: + return '-' + return format_bytes(v, 5) + + class Format(enum.Enum): plain = 'plain' json = 'json' @@ -632,9 +638,14 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, table = PrettyTable( ['NAME', 'HOST', 'PORTS', 'STATUS', 'REFRESHED', 'AGE', + 'MEM USE', 'MEM LIM', 'VERSION', 'IMAGE ID', 'CONTAINER ID'], border=False) table.align = 'l' + table._align['REFRESHED'] = 'r' + table._align['AGE'] = 'r' + table._align['MEM USE'] = 'r' + table._align['MEM LIM'] = 'r' table.left_padding_width = 0 table.right_padding_width = 2 for s in sorted(daemons, key=lambda s: s.name()): @@ -657,6 +668,8 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, status, nice_delta(now, s.last_refresh, ' ago'), nice_delta(now, s.created), + nice_bytes(s.memory_usage), + nice_bytes(s.memory_request), ukn(s.version), ukn(s.container_image_id)[0:12], ukn(s.container_id)))