diff --git a/src/capport/stats.py b/src/capport/stats.py index 250aee5..971c6fd 100644 --- a/src/capport/stats.py +++ b/src/capport/stats.py @@ -101,4 +101,4 @@ def main(): if len(sys.argv) != 2: print("Need name of client interface as argument") sys.exit(1) - trio.run(amain, sys.argv[1:]) + trio.run(amain, sys.argv[1]) diff --git a/stats-to-prometheus-collector.sh b/stats-to-prometheus-collector.sh index 6b226a4..1852338 100755 --- a/stats-to-prometheus-collector.sh +++ b/stats-to-prometheus-collector.sh @@ -16,7 +16,12 @@ fi targetname="/var/lib/prometheus/node-exporter/capport-${instance}.prom" tmpname="${targetname}.$$" -if ./stats.sh "${ifname}" > "${tmpname}"; then +if [ -f "/run/netns/${instance}" ];then + _run_in_ns="/usr/sbin/ns-enter ${instance} -- " +else + _run_in_ns="" +fi +if ${_run_in_ns} ${base}/stats.sh "${ifname}" > "${tmpname}"; then mv "${tmpname}" "${targetname}" else rm "${tmpname}"