Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aclshow] restore PRIO column and sort entries by priority #476

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/aclshow
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from natsort import natsorted
COUNTER_POSITION = '/tmp/.counters_acl.p'

### acl display header
ACL_HEADER = ["RULE NAME", "TABLE NAME", "PACKETS COUNT", "BYTES COUNT"]
ACL_HEADER = ["RULE NAME", "TABLE NAME", "PRIO", "PACKETS COUNT", "BYTES COUNT"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use the full word, PRIORITY? It's only 4 more chars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Priority label was "PRIO" long before my changes
#442
This time I just reverted this label, as it was before.


# some constants for rule properties
PACKETS_COUNTER = "packets counter"
Expand Down Expand Up @@ -178,12 +178,13 @@ class AclStat(object):
continue
rule = self.acl_rules[rule_key]
line = [rule_key[1], rule_key[0],
rule['PRIORITY'],
self.get_counter_value(rule_key, 'packets'),
self.get_counter_value(rule_key, 'bytes')]
aclstat.append(line)

# sort the list with table name first and then descending priority
aclstat.sort(key=lambda x: (x[1], -int(x[3])))
aclstat.sort(key=lambda x: (x[1], -int(x[2])))
print(tabulate(aclstat, header))

def clear_counters(self):
Expand Down