mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41: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:
parent
ab67ad805d
commit
9ef366c71a
7 changed files with 29 additions and 47 deletions
|
@ -6,4 +6,4 @@ Tested on Debian buster and Debian jessie.
|
|||
See the individual files for copyright and installation/configuration
|
||||
information.
|
||||
|
||||
This is version 1.0 by schaefer@alphanet.ch
|
||||
This is version 1.1 by schaefer@alphanet.ch
|
||||
|
|
|
@ -40,28 +40,40 @@ function active_guests {
|
|||
}
|
||||
|
||||
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 < 3
|
||||
# lxc-cgroup $*
|
||||
}
|
||||
|
||||
function lxc_clean_fieldname {
|
||||
# workaround for bug leaving out the first number
|
||||
echo $(clean_fieldname ${1::1}$1)
|
||||
# clean_fieldname should be used on the whole identifier, not just the
|
||||
# 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 {
|
||||
local g=$1 dev
|
||||
|
||||
if [ -f $lxcpath/$g/config ]; then
|
||||
# lxc3
|
||||
egrep '^lxc.net.0.veth.pair' $lxcpath/$g/config | awk '{print $NF;}'
|
||||
|
||||
# lxc < 3
|
||||
# egrep '^lxc.network.veth.pair' $lxcpath/$g/config | awk '{print $NF;}'
|
||||
# lxc 3 vs < 3
|
||||
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;}'
|
||||
else
|
||||
echo unknown
|
||||
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
|
||||
}
|
||||
|
|
|
@ -41,13 +41,7 @@ or GPLv3 license, at your option
|
|||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
|
|
@ -41,13 +41,7 @@ or GPLv3 license, at your option
|
|||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
|
|
@ -38,13 +38,7 @@ GPLv3
|
|||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
|
|
@ -77,13 +77,7 @@ count_processes () {
|
|||
}
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
|
|
@ -41,13 +41,7 @@ or GPLv3 license, at your option
|
|||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue