38 lines
825 B
Bash
Executable File
38 lines
825 B
Bash
Executable File
#!/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 Bytes by Bucket
|
|
graph_vlabel Bytes
|
|
graph_args --base 1024 -l 0
|
|
graph_category garage
|
|
graph_total Total
|
|
EOM
|
|
for i in "${!BUCKETS[@]}"
|
|
do
|
|
echo "${BUCKETS[${i}]}.label ${BUCKETS[${i}]}"
|
|
done
|
|
exit 0;;
|
|
esac
|
|
|
|
for i in "${!BUCKETS[@]}"
|
|
do
|
|
BYTES=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}" | jq -r '.bytes')
|
|
echo "${BUCKETS[${i}]}.value ${BYTES}"
|
|
done
|