1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00
Munin-Contrib/plugins/openstack_swift/openstack_swift_stats_
2021-01-02 20:31:50 +11:00

67 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
ME="${0##*/}"
CONTAINER=$(printf "%s" "$ME" | cut -d'_' -f4 -)
# printf "$CONTAINER\n"
case $1 in
config)
cat <<EOM
multigraph openstack_swift_stats_size
graph_title Swift container size ($CONTAINER)
graph_category cloud
graph_vlabel bytes
graph_args --base=1024 -l 0
graph_period hour
size.label Size
size.type GAUGE
size.draw AREA
size.min 0
growth.label Growth/\${graph_period}
growth.type DERIVE
growth.min 0
multigraph openstack_swift_stats_objects
graph_title Swift container object count ($CONTAINER)
graph_category cloud
graph_vlabel
graph_args --base=1000 -l 0
graph_period hour
objects.label Objects
objects.type GAUGE
objects.draw AREA
objects.min 0
objgrowth.label Growth/\${graph_period}
objgrowth.type DERIVE
objgrowth.min 0
EOM
exit 0;;
esac
IFS=" "
STAT_OUTPUT=( $(swift stat "$CONTAINER" | awk 'NR>=3&&NR<=4 {print $2}' FS=": " ORS=" ") )
# Size graph
printf "multigraph openstack_swift_stats_size\n"
# Check value is an integer.
if [ -z "${STAT_OUTPUT[1]}" ] || [ "${STAT_OUTPUT[1]}" != "${STAT_OUTPUT[1]}" ] 2>/dev/null; then
printf "size.value 0\n"
printf "Error: no usable size value from swift command.\n" 1>&2
exit 1
fi
printf "size.value %s\ngrowth.value %s\n" "${STAT_OUTPUT[1]}" "${STAT_OUTPUT[1]}"
# Objects graph
printf "multigraph openstack_swift_stats_objects\n"
if [ -z "${STAT_OUTPUT[0]}" ] || [ "${STAT_OUTPUT[0]}" != "${STAT_OUTPUT[0]}" ] 2>/dev/null; then
printf "objects.value 0\n"
printf "Error: no usable objects value from swift command.\n" 1>&2
exit 1
fi
printf "objects.value %s\nobjgrowth.value %s\n" "${STAT_OUTPUT[0]}" "${STAT_OUTPUT[0]}"