mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Plugin lxc: use functions for top-level activities
This clarifies the flow of control and allows to use MUNIN_CAP_DIRTYCONFIG later.
This commit is contained in:
parent
4356a024a7
commit
f00f28cf6f
1 changed files with 75 additions and 59 deletions
|
@ -178,13 +178,7 @@ title_case() {
|
|||
}
|
||||
|
||||
|
||||
# --- BASIC DEFINES
|
||||
|
||||
active_guests=$(get_active_guests "$exclude")
|
||||
|
||||
# --- AUTOCONF
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
do_autoconf() {
|
||||
if [ ! -r /proc/net/dev ]; then
|
||||
echo "no (/proc/net/dev cannot be read)"
|
||||
elif [ ! -e "$lxcpath" ]; then
|
||||
|
@ -192,12 +186,13 @@ if [ "$1" = "autoconf" ]; then
|
|||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# --- CONFIG OUTPUT
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
do_config() {
|
||||
local active_guests guest_name draw_style
|
||||
active_guests=$(get_active_guests "$exclude")
|
||||
|
||||
cat <<EOF
|
||||
multigraph lxc_cpu
|
||||
graph_title CPU Usage
|
||||
|
@ -335,11 +330,12 @@ $(clean_fieldname "mem_inactive__${guest_name}").label ${guest_name}: Inactive
|
|||
$(clean_fieldname "mem_inactive__${guest_name}").type GAUGE
|
||||
EOF
|
||||
done
|
||||
}
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- DATA OUTPUT
|
||||
do_fetch() {
|
||||
local active_guests cpu_usage device value_up value_down
|
||||
active_guests=$(get_active_guests "$exclude")
|
||||
|
||||
echo "multigraph lxc_cpu"
|
||||
for guest_name in $active_guests
|
||||
|
@ -396,3 +392,23 @@ $(clean_fieldname "mem_active__${guest_name}").value $(get_lxc_cgroup_info "$gue
|
|||
$(clean_fieldname "mem_inactive__${guest_name}").value $(get_lxc_cgroup_info "$guest_name" "memory.stat" | grep total_inactive_anon | awk '{print $2;}')
|
||||
EOF
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
case "${1:-}" in
|
||||
autoconf)
|
||||
do_autoconf
|
||||
exit 0
|
||||
;;
|
||||
config)
|
||||
do_config
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
do_fetch
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Invalid action requested (none of: autoconf / config / '')"
|
||||
exit 1
|
||||
esac
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue