mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 22:25:23 +00:00
Apply shellcheck recommendations
This commit is contained in:
parent
cf44597b58
commit
099d7821d9
1 changed files with 6 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ME="${0##*/}"
|
ME="${0##*/}"
|
||||||
CONTAINER=$(printf "$ME" | cut -d'_' -f4 -)
|
CONTAINER=$(printf "%s" "$ME" | cut -d'_' -f4 -)
|
||||||
# printf "$CONTAINER\n"
|
# printf "$CONTAINER\n"
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
@ -39,31 +39,29 @@ EOM
|
||||||
esac
|
esac
|
||||||
|
|
||||||
IFS=" "
|
IFS=" "
|
||||||
STAT_OUTPUT=( $(swift stat $CONTAINER | awk 'NR>=3&&NR<=4 {print $2}' FS=": " ORS=" ") )
|
STAT_OUTPUT=( $(swift stat "$CONTAINER" | awk 'NR>=3&&NR<=4 {print $2}' FS=": " ORS=" ") )
|
||||||
|
|
||||||
# Size graph
|
# Size graph
|
||||||
printf "multigraph openstack_swift_stats_size\n"
|
printf "multigraph openstack_swift_stats_size\n"
|
||||||
|
|
||||||
# Check value is an integer.
|
# Check value is an integer.
|
||||||
[ -n "${STAT_OUTPUT[1]}" ] && [ "${STAT_OUTPUT[1]}" -eq "${STAT_OUTPUT[1]}" ] 2>/dev/null
|
if [ -z "${STAT_OUTPUT[1]}" ] || [ "${STAT_OUTPUT[1]}" != "${STAT_OUTPUT[1]}" ] 2>/dev/null; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
printf "size.value 0\n"
|
printf "size.value 0\n"
|
||||||
printf "Error: no usable size value from swift command.\n" 1>&2
|
printf "Error: no usable size value from swift command.\n" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "size.value ${STAT_OUTPUT[1]}\ngrowth.value ${STAT_OUTPUT[1]}\n"
|
printf "size.value %s\ngrowth.value %s\n" "${STAT_OUTPUT[1]}" "${STAT_OUTPUT[1]}"
|
||||||
|
|
||||||
# Objects graph
|
# Objects graph
|
||||||
printf "multigraph openstack_swift_stats_objects\n"
|
printf "multigraph openstack_swift_stats_objects\n"
|
||||||
|
|
||||||
[ -n "${STAT_OUTPUT[0]}" ] && [ "${STAT_OUTPUT[0]}" -eq "${STAT_OUTPUT[0]}" ] 2>/dev/null
|
if [ -z "${STAT_OUTPUT[0]}" ] || [ "${STAT_OUTPUT[0]}" != "${STAT_OUTPUT[0]}" ] 2>/dev/null; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
printf "objects.value 0\n"
|
printf "objects.value 0\n"
|
||||||
printf "Error: no usable objects value from swift command.\n" 1>&2
|
printf "Error: no usable objects value from swift command.\n" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "objects.value ${STAT_OUTPUT[0]}\nobjgrowth.value ${STAT_OUTPUT[0]}\n"
|
printf "objects.value %s\nobjgrowth.value %s\n" "${STAT_OUTPUT[0]}" "${STAT_OUTPUT[0]}"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue