2
0

permit running in light-ns

This commit is contained in:
Kilian Krause 2023-07-09 22:28:29 +02:00
parent 7b85a0d388
commit a832d0ad48
2 changed files with 7 additions and 2 deletions

View File

@ -101,4 +101,4 @@ def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:
print("Need name of client interface as argument") print("Need name of client interface as argument")
sys.exit(1) sys.exit(1)
trio.run(amain, sys.argv[1:]) trio.run(amain, sys.argv[1])

View File

@ -16,7 +16,12 @@ fi
targetname="/var/lib/prometheus/node-exporter/capport-${instance}.prom" targetname="/var/lib/prometheus/node-exporter/capport-${instance}.prom"
tmpname="${targetname}.$$" 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}" mv "${tmpname}" "${targetname}"
else else
rm "${tmpname}" rm "${tmpname}"