So I know how to obtain e.g. links that reside in another network namespace (with NetNS.get_links()), and I also know how to obtain TCP flow statistics for the default network namespace (with DiagSocket.get_sock_stats()).
Does pyroute2 currently allow obtaining TCP flow statistics for flows whose source or destination links reside in non-default (named) network namespaces, and if so how? Great package BTW.
I have e.g. tried calling DiagSocket.get_sock_stats() from a subprocess after switching its netns but that did not seem to work:
def stat():
nonlocal pid
pyroute2.netns.setns('/proc/{}/ns/net'.format(pid))
with pyroute2.DiagSocket() as ds:
ds.bind()
sstats = ds.get_sock_stats(...)
# ...
process = multiprocessing.Process(target=stat)
process.start()
So I know how to obtain e.g. links that reside in another network namespace (with
NetNS.get_links()
), and I also know how to obtain TCP flow statistics for the default network namespace (withDiagSocket.get_sock_stats()
).Does
pyroute2
currently allow obtaining TCP flow statistics for flows whose source or destination links reside in non-default (named) network namespaces, and if so how? Great package BTW.I have e.g. tried calling
DiagSocket.get_sock_stats()
from a subprocess after switching its netns but that did not seem to work: