unify DIRTYCONFIG handling in shell and python plugins
The following issues were fixed: * comparison too broad (e.g. "0" misinterpreted as "true") * python: comparing string with number (is never equal in python) * unwanted non-zero exitcode (compound command "&&" as last command in shell code block (e.g. "case" or "if" branch)) * access to unset variable (shell style issue)
This commit is contained in:
parent
270be2f59e
commit
c81c20ab3b
|
@ -72,9 +72,7 @@ if [ "$1" = "config" ]; then
|
|||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output the stats.
|
||||
|
|
|
@ -69,11 +69,9 @@ if [ "$1" = "config" ]; then
|
|||
echo ${key}.type COUNTER
|
||||
done
|
||||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output the stats.
|
||||
|
|
|
@ -67,11 +67,9 @@ if [ "$1" = "config" ]; then
|
|||
echo ${key}.type COUNTER
|
||||
done
|
||||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output the stats.
|
||||
|
|
|
@ -156,7 +156,7 @@ case ${1:-} in
|
|||
config)
|
||||
do_config
|
||||
# support "dirty config" capability
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ]; then do_fetch; fi
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||
;;
|
||||
autoconf)
|
||||
do_autoconf
|
||||
|
|
|
@ -1119,7 +1119,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
|||
echo ${pool}.type GAUGE
|
||||
done
|
||||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output looks like this:
|
||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
|||
echo ${pool}.type GAUGE
|
||||
done
|
||||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output looks like this:
|
||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
|||
echo ${pool}.type GAUGE
|
||||
done
|
||||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# Output looks like this:
|
||||
|
|
|
@ -73,9 +73,7 @@ if [ "$1" = "config" ]; then
|
|||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
while read pool sep backends junk
|
||||
|
|
|
@ -98,7 +98,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -163,7 +163,7 @@ suggest)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -160,7 +160,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -118,7 +118,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -334,7 +334,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -108,9 +108,7 @@ if [ "$1" = "config" ]; then
|
|||
|
||||
# If dirty config capability is enabled then fall through
|
||||
# to output the data with the config information.
|
||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
# If there are no pumps then output fake pump1 data and end.
|
||||
|
|
|
@ -83,7 +83,7 @@ then
|
|||
EOF
|
||||
|
||||
# Continue if dirty config is enabled
|
||||
[ "$MUNIN_CAP_DIRTYCONFIG" = 1 ] || exit 0
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] || exit 0
|
||||
fi
|
||||
|
||||
TEMP_AVG=$( expr "$OWAPI" : '.*\<temperature value=\"\(.*\)\" min.*/temperature.*' )
|
||||
|
|
|
@ -135,7 +135,7 @@ elif [ "${1:-}" = "suggest" ]; then
|
|||
done
|
||||
elif [ "${1:-}" = "config" ]; then
|
||||
do_config || exit 1
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||
else
|
||||
do_fetch
|
||||
fi
|
||||
|
|
|
@ -147,7 +147,7 @@ ACTION="${1:-}"
|
|||
case "$ACTION" in
|
||||
config)
|
||||
do_config || exit 1
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||
;;
|
||||
autoconf)
|
||||
if [ -z "$(get_wifi_interfaces)" ]; then
|
||||
|
|
|
@ -138,7 +138,7 @@ ACTION="${1:-}"
|
|||
case "$ACTION" in
|
||||
config)
|
||||
do_config || exit 1
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||
;;
|
||||
autoconf)
|
||||
[ -z "$(get_wifi_interfaces)" ] && echo "no (no wifi interfaces found)" && exit 1
|
||||
|
|
|
@ -351,7 +351,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -257,7 +257,7 @@ autoconf)
|
|||
;;
|
||||
config)
|
||||
config
|
||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||
;;
|
||||
*)
|
||||
fetch
|
||||
|
|
|
@ -159,7 +159,7 @@ def emit_config():
|
|||
print('graph_period minute')
|
||||
graph_order = []
|
||||
|
||||
if 'MUNIN_CAP_DIRTYCONFIG' in os.environ and os.environ['MUNIN_CAP_DIRTYCONFIG'] == 1:
|
||||
if os.getenv('MUNIN_CAP_DIRTYCONFIG') == "1":
|
||||
read_data(1)
|
||||
else:
|
||||
read_data(0)
|
||||
|
|
Loading…
Reference in New Issue