Skip to content

Commit c84ef2c

Browse files
authored
Add trimming function (#31)
1 parent b609d6d commit c84ef2c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/agent/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ContainerSummary,
1616
HostSummary,
1717
MetricType,
18+
get_container_name,
1819
)
1920

2021

@@ -57,7 +58,7 @@ def get_containers_summary(self) -> List[ContainerSummary]:
5758
)
5859
container_summary = ContainerSummary(
5960
id=attrs["Id"],
60-
name=attrs["Name"],
61+
name=get_container_name(attrs["Name"]),
6162
image=attrs["Config"]["Image"],
6263
state=ContainerState[attrs["State"]["Status"]].name,
6364
metrics=[virtual_memory_metric, cpu_metric],

src/agent/dataclasses.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class PercentMetric:
4040
percent: float
4141

4242

43+
def get_container_name(container_name: str) -> str:
44+
if container_name.startswith("/"):
45+
return container_name[1:]
46+
return container_name
47+
48+
4349
@dataclass_json(letter_case=LetterCase.CAMEL)
4450
@dataclass
4551
class ContainerSummary:

0 commit comments

Comments
 (0)