1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-27 19:34:43 +00:00

lxc: working on buster (gandalf), and almost working on virtual (jessie), except lxc_net

This commit is contained in:
Marc SCHAEFER 2019-08-10 11:33:27 +02:00 committed by Lars Kruse
parent 0e0de01136
commit ce6e67fffc
7 changed files with 371 additions and 303 deletions

63
plugins/lxc/lxc-lib Normal file
View file

@ -0,0 +1,63 @@
: << =cut
=head1 NAME
lxc-lib -- some base functions for the lxc_* plugins
=head1 AUTHOR
schaefer@alphanet.ch
=head1 LICENSE
GPLv3
=cut
lxcpath=${lxcpath:-/var/lib/lxc}
function active_guests {
local g active i ok
for g in $(lxc-ls | sort -u)
do
# handle optional exclude list in $1
ok=1
for i in $1
do
if [ "$i" = "$g" ]; then
ok=0
fi
done
if [ $ok = 1 ]; then
if lxc-info -n $g 2>&1 | grep -qs RUNNING; then
active="$active $g"
fi
fi
done
echo $active
}
function lxc_cgroup {
# lxc3
lxc-cgroup -o /dev/stdout -l INFO $* | sed 's/^.*lxc_cgroup.c:main:[0-9][0-9]* - //'
# lxc < 3
#lxc-cgroup $*
}
function lxc_clean_fieldname {
# workaround for bug leaving out the first number
echo $(clean_fieldname ${1::1}$1)
}
function lxc_netdev {
local g=$1 dev
if [ -f $lxcpath/$g/config ]; then
grep lxc.net.0.veth.pair $lxcpath/$g/config | awk '{print $NF;}'
else
echo unknown
fi
}