summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-12-03 01:35:23 +0100
committerDaniil Baturin <daniil@baturin.org>2018-12-03 01:35:23 +0100
commit44c8175dc975c8a3b73bf14c71dd890d52f00e67 (patch)
tree51ff49de0afe8f2a56415131dcd08352f570b9bc /src
parentf285e0cba6550b316794bf04f9992e9b471ea562 (diff)
downloadvyos-1x-44c8175dc975c8a3b73bf14c71dd890d52f00e67.tar.gz
vyos-1x-44c8175dc975c8a3b73bf14c71dd890d52f00e67.zip
T956: display SA traffic counters in human-redable units.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/show_ipsec_sa.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/op_mode/show_ipsec_sa.py b/src/op_mode/show_ipsec_sa.py
index b03014b2f..3c8d678eb 100755
--- a/src/op_mode/show_ipsec_sa.py
+++ b/src/op_mode/show_ipsec_sa.py
@@ -4,6 +4,7 @@ import re
import subprocess
import tabulate
+import hurry.filesize
def parse_conn_spec(s):
# Example: ESTABLISHED 14 seconds ago, 10.0.0.2[foo]...10.0.0.1[10.0.0.1]
@@ -39,6 +40,11 @@ for conn in connections:
if ip == id:
id = None
enc, hash, dh, bytes_in, bytes_out = parse_ike_line(status)
+
+ # Convert bytes to human-readable units
+ bytes_in = hurry.filesize.size(bytes_in)
+ bytes_out = hurry.filesize.size(bytes_out)
+
status_line = [conn, "up", time, "{0}/{1}".format(bytes_in, bytes_out), ip, id, "{0}/{1}/{2}".format(enc, hash, dh)]
except Exception as e:
print(status)