Skip to content

Commit

Permalink
Merge pull request #3282 from vyos/mergify/bp/sagitta/pr-3280
Browse files Browse the repository at this point in the history
T5858: Fix op-mode format for show conntrack statistics (backport #3280)
  • Loading branch information
c-po authored Apr 9, 2024
2 parents 39e95fd + 3419a8f commit 8025778
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/op_mode/conntrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,33 @@ 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())
return entries


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


Expand Down

0 comments on commit 8025778

Please sign in to comment.