From 8c291d3a948a98df8c7bab8f3ee3a6fbdd97377b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 30 Nov 2025 13:29:08 +0100 Subject: [PATCH] statd: fix EXPIRES column alignment in 'show dhcp-server' The EXPIRES column was misaligned due to multiple issues: - Column header used width 10 while data rows used width 9 - Expiry values had leading space intended for the narrower width - CLIENT ID column width (19) was too narrow for typical client IDs like "01:00:a0:85:00:01:05" (20 chars), causing overflow Fixed by using consistent width for EXPIRES, removing the leading space from expiry values, and widening CLIENT ID column to 22. Signed-off-by: Joachim Wiberg --- src/statd/python/cli_pretty/cli_pretty.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py index ff617c95..851e8eb4 100755 --- a/src/statd/python/cli_pretty/cli_pretty.py +++ b/src/statd/python/cli_pretty/cli_pretty.py @@ -154,7 +154,7 @@ class PadDhcpServer: ip = 17 mac = 19 host = 21 - cid = 19 + cid = 22 exp = 10 @@ -720,11 +720,11 @@ class DhcpServer: now = datetime.now(timezone.utc) for lease in get_json_data([], self.data, 'leases', 'lease'): if lease["expires"] == "never": - exp = " never" + exp = "never" else: dt = datetime.strptime(lease['expires'], '%Y-%m-%dT%H:%M:%S%z') seconds = int((dt - now).total_seconds()) - exp = f" {self.format_duration(seconds)}" + exp = self.format_duration(seconds) self.leases.append({ "ip": lease["address"], "mac": lease["phys-address"], @@ -775,7 +775,7 @@ class DhcpServer: row += f"{mac:<{PadDhcpServer.mac}}" row += f"{host:<{PadDhcpServer.host}}" row += f"{cid:<{PadDhcpServer.cid}}" - row += f"{exp:>{PadDhcpServer.exp - 1}}" + row += f"{exp:>{PadDhcpServer.exp}}" print(row) def print_stats(self):