From f00f28cf6fadb589ecea14305cf22e12002838f3 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Mon, 12 Aug 2019 01:49:48 +0200 Subject: [PATCH] Plugin lxc: use functions for top-level activities This clarifies the flow of control and allows to use MUNIN_CAP_DIRTYCONFIG later. --- plugins/lxc/lxc-multigraph | 134 +++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 59 deletions(-) diff --git a/plugins/lxc/lxc-multigraph b/plugins/lxc/lxc-multigraph index 70f7abad..d273b543 100755 --- a/plugins/lxc/lxc-multigraph +++ b/plugins/lxc/lxc-multigraph @@ -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 <&2 "Invalid action requested (none of: autoconf / config / '')" + exit 1 +esac