support for .libvirt-qemu naming of cgroups; fixes #3010
Costa Tsaousis (ktsaou) committed
Nov 14, 2017 at 02:03 UTC
bea29ff9bdcce707b13523fa41773317f8c1d84e
3 files changed
+20
-9
plugins.d/cgroup-name.sh
+5
@@ -126,6 +126,11 @@ if [ -z "${NAME}" ]
126
# NAME="$(echo ${CGROUP} | sed 's/machine.slice_machine.*-qemu//; s/\/x2d//; s/\/x2d/\-/g; s/\.scope//g')"
127
NAME="qemu_$(echo ${CGROUP} | sed 's/machine.slice_machine.*-qemu//; s/\/x2d[[:digit:]]*//; s/\/x2d//g; s/\.scope//g')"
128
129
+ elif [[ "${CGROUP}" =~ machine_*\.libvirt-qemu ]]
130
+ then
131
+ # libvirtd / qemu virtual machines
132
+ NAME="qemu_$(echo ${CGROUP} | sed 's/^machine_//; s/\.libvirt-qemu$//; s/-/_/;')"
133
+
134
elif [[ "${CGROUP}" =~ qemu.slice_([0-9]+).scope && -d /etc/pve ]]
135
then
136
# Proxmox VMs
plugins.d/cgroup-network-helper.sh
+13
-9
@@ -22,6 +22,9 @@
22
23
# -----------------------------------------------------------------------------
24
25
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
26
+export LC_ALL=C
27
+
28
PROGRAM_NAME="$(basename "${0}")"
29
30
logdate() {
@@ -145,13 +148,11 @@ virsh_cgroup_to_domain_name() {
148
debug "extracting a possible virsh domain from cgroup ${c}..."
149
150
# extract for the cgroup path
148
- # \1 = domain id
149
- # \2 = domain name
150
-
151
- echo "${c}" |\
152
- sed "s|.*/machine-qemu\\\\x2d\([0-9]\+\)\\\\x2d\(.*\)\.scope$|virsh_domain_found \2|" |\
153
- grep ^virsh_domain_found |\
154
- cut -d ' ' -f 2
151
+ sed -n -e "s|.*/machine-qemu\\\\x2d[0-9]\+\\\\x2d\(.*\)\.scope$|\1|p" \
152
+ -e "s|.*/machine/\(.*\)\.libvirt-qemu$|\1|p" \
153
+ <<EOF
154
+${c}
155
+EOF
156
}
157
158
virsh_find_all_interfaces_for_cgroup() {
@@ -168,10 +169,13 @@ virsh_find_all_interfaces_for_cgroup() {
169
then
170
debug "running: virsh domiflist ${d}; to find the network interfaces"
171
172
+ # match only 'network' interfaces from virsh output
173
+
174
set_source "virsh"
175
"${virsh}" domiflist ${d} |\
173
- grep -Ev "^(Interface|----)" |\
174
- cut -d ' ' -f 1
176
+ sed -n \
177
+ -e "s|^\([^[:space:]]\+\)[[:space:]]\+network[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1|p" \
178
+ -e "s|^\([^[:space:]]\+\)[[:space:]]\+bridge[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1|p"
179
else
180
debug "no virsh domain extracted from cgroup ${c}"
181
fi
src/sys_fs_cgroup.c
+2
@@ -181,6 +181,7 @@ void read_cgroup_plugin_configuration() {
181
config_get("plugin:cgroups", "search for cgroups in subpaths matching",
182
" !*/init.scope " // ignore init.scope
183
" !*-qemu " // #345
184
+ " !*.libvirt-qemu " // #3010
185
" !/init.scope "
186
" !/system "
187
" !/systemd "
@@ -202,6 +203,7 @@ void read_cgroup_plugin_configuration() {
203
" *docker* "
204
" *lxc* "
205
" *qemu* "
206
+ " *.libvirt-qemu " // #3010
207
" !/ "
208
" !*.mount "
209
" !*.partition "