@@ -36,6 +36,15 @@ def write_sysfs_file(path, input):
return read_sysfs_file(path)
+def read_xprtsec_file(path):
+ """Read an xprtsec file."""
+ try:
+ with open(path, 'r') as f:
+ return f.readline().strip()
+ except FileNotFoundError:
+ return "(unknown)"
+
+
def read_info_file(path):
"""Read an xprt or xprt switch information file."""
res = collections.defaultdict(int)
@@ -58,6 +67,7 @@ class Xprt:
self.info = read_info_file(path / "xprt_info")
self.dstaddr = read_sysfs_file(path / "dstaddr")
self.srcaddr = read_sysfs_file(path / "srcaddr")
+ self.xprtsec = read_xprtsec_file(path / "xprtsec")
self.read_state()
def __lt__(self, rhs):
@@ -67,7 +77,8 @@ class Xprt:
def _xprt(self):
main = ", main" if self.info.get("main_xprt") else ""
return f"{self.name}: {self.type}, {self.dstaddr}, " \
- f"port {self.info['dst_port']}, state <{self.state}>{main}"
+ f"port {self.info['dst_port']}, sec {self.xprtsec}, " \
+ f"state <{self.state}>{main}"
def _src_reqs(self):
return f" Source: {self.srcaddr}, port {self.info['src_port']}, " \