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
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the stats.
|
# Output the stats.
|
||||||
|
|
|
@ -69,11 +69,9 @@ if [ "$1" = "config" ]; then
|
||||||
echo ${key}.type COUNTER
|
echo ${key}.type COUNTER
|
||||||
done
|
done
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the stats.
|
# Output the stats.
|
||||||
|
|
|
@ -67,11 +67,9 @@ if [ "$1" = "config" ]; then
|
||||||
echo ${key}.type COUNTER
|
echo ${key}.type COUNTER
|
||||||
done
|
done
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the stats.
|
# Output the stats.
|
||||||
|
|
|
@ -156,7 +156,7 @@ case ${1:-} in
|
||||||
config)
|
config)
|
||||||
do_config
|
do_config
|
||||||
# support "dirty config" capability
|
# support "dirty config" capability
|
||||||
if [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ]; then do_fetch; fi
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||||
;;
|
;;
|
||||||
autoconf)
|
autoconf)
|
||||||
do_autoconf
|
do_autoconf
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
||||||
echo ${pool}.type GAUGE
|
echo ${pool}.type GAUGE
|
||||||
done
|
done
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output looks like this:
|
# Output looks like this:
|
||||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
||||||
echo ${pool}.type GAUGE
|
echo ${pool}.type GAUGE
|
||||||
done
|
done
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output looks like this:
|
# Output looks like this:
|
||||||
|
|
|
@ -46,11 +46,9 @@ if [ "$1" = "config" ]; then
|
||||||
echo ${pool}.type GAUGE
|
echo ${pool}.type GAUGE
|
||||||
done
|
done
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output looks like this:
|
# Output looks like this:
|
||||||
|
|
|
@ -73,9 +73,7 @@ if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while read pool sep backends junk
|
while read pool sep backends junk
|
||||||
|
|
|
@ -98,7 +98,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -163,7 +163,7 @@ suggest)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -160,7 +160,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -118,7 +118,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -334,7 +334,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -108,9 +108,7 @@ if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
# If dirty config capability is enabled then fall through
|
# If dirty config capability is enabled then fall through
|
||||||
# to output the data with the config information.
|
# to output the data with the config information.
|
||||||
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If there are no pumps then output fake pump1 data and end.
|
# If there are no pumps then output fake pump1 data and end.
|
||||||
|
|
|
@ -83,7 +83,7 @@ then
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Continue if dirty config is enabled
|
# Continue if dirty config is enabled
|
||||||
[ "$MUNIN_CAP_DIRTYCONFIG" = 1 ] || exit 0
|
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] || exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TEMP_AVG=$( expr "$OWAPI" : '.*\<temperature value=\"\(.*\)\" min.*/temperature.*' )
|
TEMP_AVG=$( expr "$OWAPI" : '.*\<temperature value=\"\(.*\)\" min.*/temperature.*' )
|
||||||
|
|
|
@ -135,7 +135,7 @@ elif [ "${1:-}" = "suggest" ]; then
|
||||||
done
|
done
|
||||||
elif [ "${1:-}" = "config" ]; then
|
elif [ "${1:-}" = "config" ]; then
|
||||||
do_config || exit 1
|
do_config || exit 1
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||||
else
|
else
|
||||||
do_fetch
|
do_fetch
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -147,7 +147,7 @@ ACTION="${1:-}"
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
config)
|
config)
|
||||||
do_config || exit 1
|
do_config || exit 1
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||||
;;
|
;;
|
||||||
autoconf)
|
autoconf)
|
||||||
if [ -z "$(get_wifi_interfaces)" ]; then
|
if [ -z "$(get_wifi_interfaces)" ]; then
|
||||||
|
|
|
@ -138,7 +138,7 @@ ACTION="${1:-}"
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
config)
|
config)
|
||||||
do_config || exit 1
|
do_config || exit 1
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||||||
;;
|
;;
|
||||||
autoconf)
|
autoconf)
|
||||||
[ -z "$(get_wifi_interfaces)" ] && echo "no (no wifi interfaces found)" && exit 1
|
[ -z "$(get_wifi_interfaces)" ] && echo "no (no wifi interfaces found)" && exit 1
|
||||||
|
|
|
@ -351,7 +351,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -257,7 +257,7 @@ autoconf)
|
||||||
;;
|
;;
|
||||||
config)
|
config)
|
||||||
config
|
config
|
||||||
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch
|
fetch
|
||||||
|
|
|
@ -159,7 +159,7 @@ def emit_config():
|
||||||
print('graph_period minute')
|
print('graph_period minute')
|
||||||
graph_order = []
|
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)
|
read_data(1)
|
||||||
else:
|
else:
|
||||||
read_data(0)
|
read_data(0)
|
||||||
|
|
Loading…
Reference in New Issue