1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

- autoconf cleanup - better lxc_clean_fieldname workaround supporting non numeric compatibility - lxc_netdev now compatible with lxc3 and lxc2 at a small CPU cost - lxc_cgroup now compatible with lxc3 and lxc2; may however fail with lxc2 if your config file contains cruft

This commit is contained in:
Marc SCHAEFER 2019-08-11 09:40:39 +02:00 committed by Lars Kruse
parent ab67ad805d
commit 9ef366c71a
7 changed files with 29 additions and 47 deletions

View file

@ -6,4 +6,4 @@ Tested on Debian buster and Debian jessie.
See the individual files for copyright and installation/configuration See the individual files for copyright and installation/configuration
information. information.
This is version 1.0 by schaefer@alphanet.ch This is version 1.1 by schaefer@alphanet.ch

View file

@ -40,28 +40,40 @@ function active_guests {
} }
function lxc_cgroup { function lxc_cgroup {
# lxc3 # lxc3 (lxc < 3: may output some warnings if there is cruft in your config dir)
lxc-cgroup -o /dev/stdout -l INFO $* | sed 's/^.*lxc_cgroup.c:main:[0-9][0-9]* - //' 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 { function lxc_clean_fieldname {
# workaround for bug leaving out the first number # clean_fieldname should be used on the whole identifier, not just the
echo $(clean_fieldname ${1::1}$1) # lxc instance ID, because if it is only numeric, the first digit will
# be replaced with a "_"; this is a work-around
case "${1::1}" in
[0-9]) echo $(clean_fieldname ${1::1}$1);; # 104 -> __104
*) echo $(clean_fieldname $1);;
esac
} }
function lxc_netdev { function lxc_netdev {
local g=$1 dev local g=$1 dev
if [ -f $lxcpath/$g/config ]; then if [ -f $lxcpath/$g/config ]; then
# lxc3 # lxc 3 vs < 3
egrep '^lxc.net.0.veth.pair' $lxcpath/$g/config | awk '{print $NF;}' egrep '^lxc.net.0.veth.pair' $lxcpath/$g/config 2>/dev/null | awk '{print $NF;}' \
|| egrep '^lxc.network.veth.pair' $lxcpath/$g/config | awk '{print $NF;}'
# lxc < 3
# egrep '^lxc.network.veth.pair' $lxcpath/$g/config | awk '{print $NF;}'
else else
echo unknown echo unknown
fi fi
} }
# BUGS
# - I don't think this is enough or even appropriate
function lxc_autoconf {
if [ -r /proc/stat ]; then
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
}

View file

@ -41,13 +41,7 @@ or GPLv3 license, at your option
active_guests=$(active_guests) active_guests=$(active_guests)
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then lxc_autoconf
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then

View file

@ -41,13 +41,7 @@ or GPLv3 license, at your option
active_guests=$(active_guests) active_guests=$(active_guests)
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then lxc_autoconf
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then

View file

@ -38,13 +38,7 @@ GPLv3
active_guests=$(active_guests) active_guests=$(active_guests)
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then lxc_autoconf
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then

View file

@ -77,13 +77,7 @@ count_processes () {
} }
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then lxc_autoconf
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then

View file

@ -41,13 +41,7 @@ or GPLv3 license, at your option
active_guests=$(active_guests) active_guests=$(active_guests)
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then lxc_autoconf
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then