2022-04-11 18:17:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
base=$(dirname "$(readlink -f "$0")")
|
|
|
|
cd "${base}"
|
|
|
|
|
|
|
|
instance=$1
|
|
|
|
ifname=$2
|
|
|
|
|
|
|
|
if [ -z "${instance}" -o -z "${ifname}" ]; then
|
|
|
|
echo >&2 "Syntax: $0 instancename clientifname"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
targetname="/var/lib/prometheus/node-exporter/capport-${instance}.prom"
|
|
|
|
tmpname="${targetname}.$$"
|
|
|
|
|
2023-07-09 22:28:29 +02:00
|
|
|
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
|
2022-04-11 18:17:00 +02:00
|
|
|
mv "${tmpname}" "${targetname}"
|
|
|
|
else
|
|
|
|
rm "${tmpname}"
|
|
|
|
exit 1
|
|
|
|
fi
|