feat: add garage specific munin shell scripts
This commit is contained in:
36
roles/munin_client/files/garage_bucket_objects
Executable file
36
roles/munin_client/files/garage_bucket_objects
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the Header
|
||||
HEADER="Authorization: Bearer ${BEARER}"
|
||||
|
||||
# Create associative array
|
||||
declare -A BUCKETS=()
|
||||
|
||||
API_BUCKETS_JSON=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket" | jq -r '.[] | .id + "," + .globalAliases[0]')
|
||||
|
||||
# Populate associative array
|
||||
for bucket in ${API_BUCKETS_JSON}
|
||||
do
|
||||
BUCKETS+=([$(echo ${bucket} | cut -d ',' -f 1)]="$(echo ${bucket} | cut -d ',' -f 2)")
|
||||
done
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat << 'EOM'
|
||||
graph_title Objects by Bucket
|
||||
graph_vlabel Number of objects
|
||||
graph_args --base 1000 -l 0
|
||||
graph_category garage
|
||||
EOM
|
||||
for i in "${!BUCKETS[@]}"
|
||||
do
|
||||
echo "${BUCKETS[${i}]}.label ${BUCKETS[${i}]}"
|
||||
done
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
for i in "${!BUCKETS[@]}"
|
||||
do
|
||||
OBJECTS=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}" | jq -r '.objects')
|
||||
echo "${BUCKETS[${i}]}.value ${OBJECTS}"
|
||||
done
|
Reference in New Issue
Block a user