summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin/cgroup-network-helper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/cgroups.plugin/cgroup-network-helper.sh')
-rwxr-xr-xcollectors/cgroups.plugin/cgroup-network-helper.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/collectors/cgroups.plugin/cgroup-network-helper.sh b/collectors/cgroups.plugin/cgroup-network-helper.sh
index eb839ef57..1b60f452a 100755
--- a/collectors/cgroups.plugin/cgroup-network-helper.sh
+++ b/collectors/cgroups.plugin/cgroup-network-helper.sh
@@ -123,7 +123,7 @@ proc_pid_fdinfo_iff() {
find_tun_tap_interfaces_for_cgroup() {
local c="${1}" # the cgroup path
[ -d "${c}/emulator" ] && c="${c}/emulator" # check for 'emulator' subdirectory
- c="${c}/cgroup.procs" # make full path
+ c="${c}/cgroup.procs" # make full path
# for each pid of the cgroup
# find any tun/tap devices linked to the pid
@@ -168,18 +168,26 @@ virsh_find_all_interfaces_for_cgroup() {
then
local d
d="$(virsh_cgroup_to_domain_name "${c}")"
+ # convert hex to character
+ # e.g.: vm01\x2dweb => vm01-web (https://github.com/netdata/netdata/issues/11088#issuecomment-832618149)
+ d="$(printf '%b' "${d}")"
if [ ! -z "${d}" ]
then
debug "running: virsh domiflist ${d}; to find the network interfaces"
- # match only 'network' interfaces from virsh output
+ # 'virsh -r domiflist <domain>' example output
+ # Interface Type Source Model MAC
+ #--------------------------------------------------------------
+ # vnet3 bridge br0 virtio 52:54:00:xx:xx:xx
+ # vnet4 network default virtio 52:54:00:yy:yy:yy
+ # match only 'network' interfaces from virsh output
set_source "virsh"
"${virsh}" -r domiflist "${d}" |\
sed -n \
- -e "s|^\([^[:space:]]\+\)[[:space:]]\+network[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p" \
- -e "s|^\([^[:space:]]\+\)[[:space:]]\+bridge[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p"
+ -e "s|^[[:space:]]\?\([^[:space:]]\+\)[[:space:]]\+network[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p" \
+ -e "s|^[[:space:]]\?\([^[:space:]]\+\)[[:space:]]\+bridge[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p"
else
debug "no virsh domain extracted from cgroup ${c}"
fi