diff options
author | Christian Breunig <christian@breunig.cc> | 2024-04-09 17:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 17:09:16 +0200 |
commit | 80257788f205e84722683ef6208a9869221d8d6a (patch) | |
tree | 614d779a9d923c5e65d7c6bd9f533f067ff38bfa | |
parent | 39e95fd06c852b7d39a5d65f648f6b4576b6ed4a (diff) | |
parent | 3419a8f039a6c16bc1a78f6a25662b996aee58da (diff) | |
download | vyos-1x-80257788f205e84722683ef6208a9869221d8d6a.tar.gz vyos-1x-80257788f205e84722683ef6208a9869221d8d6a.zip |
Merge pull request #3282 from vyos/mergify/bp/sagitta/pr-3280
T5858: Fix op-mode format for show conntrack statistics (backport #3280)
-rwxr-xr-x | src/op_mode/conntrack.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/op_mode/conntrack.py b/src/op_mode/conntrack.py index 5687b9b00..c379c3e60 100755 --- a/src/op_mode/conntrack.py +++ b/src/op_mode/conntrack.py @@ -62,7 +62,7 @@ def _get_raw_data(family): def _get_raw_statistics(): entries = [] - data = cmd('sudo conntrack -S') + data = cmd('sudo conntrack --stats') data = data.replace(' \t', '').split('\n') for entry in data: entries.append(entry.split()) @@ -70,8 +70,25 @@ def _get_raw_statistics(): def get_formatted_statistics(entries): - headers = ["CPU", "Found", "Invalid", "Insert", "Insert fail", "Drop", "Early drop", "Errors", "Search restart"] - output = tabulate(entries, headers, numalign="left") + headers = [ + "CPU", + "Found", + "Invalid", + "Insert", + "Insert fail", + "Drop", + "Early drop", + "Errors", + "Search restart", + "", + "", + ] + # Process each entry to extract and format the values after '=' + processed_entries = [ + [value.split('=')[-1] for value in entry] + for entry in entries + ] + output = tabulate(processed_entries, headers, numalign="left") return output |