feat: nvme crit/warn + refacto: garage_bucket script
This commit is contained in:
87
roles/munin_client/files/garage_bucket
Normal file
87
roles/munin_client/files/garage_bucket
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/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 << 'EOF'
|
||||||
|
multigraph garage_bucket_unfinished
|
||||||
|
graph_title Unfinished multipart uploads by Bucket
|
||||||
|
graph_vlabel Number of unfinished multipart uploads
|
||||||
|
graph_args --base 1000 -l 0
|
||||||
|
graph_category garage
|
||||||
|
graph_total Total
|
||||||
|
EOF
|
||||||
|
for i in "${!BUCKETS[@]}"
|
||||||
|
do
|
||||||
|
echo "${BUCKETS[${i}]}.label ${BUCKETS[${i}]}"
|
||||||
|
done
|
||||||
|
cat << 'EOF'
|
||||||
|
multigraph garage_bucket_objects
|
||||||
|
graph_title Objects by Bucket
|
||||||
|
graph_vlabel Number of objects
|
||||||
|
graph_args --base 1000 -l 0
|
||||||
|
graph_category garage
|
||||||
|
graph_total Total
|
||||||
|
EOF
|
||||||
|
for i in "${!BUCKETS[@]}"
|
||||||
|
do
|
||||||
|
echo "${BUCKETS[${i}]}.label ${BUCKETS[${i}]}"
|
||||||
|
done
|
||||||
|
cat << 'EOF'
|
||||||
|
multigraph garage_bucket_size
|
||||||
|
graph_title Bytes by Bucket
|
||||||
|
graph_vlabel Bytes
|
||||||
|
graph_args --base 1024 -l 0
|
||||||
|
graph_category garage
|
||||||
|
graph_total Total
|
||||||
|
EOF
|
||||||
|
for i in "${!BUCKETS[@]}"
|
||||||
|
do
|
||||||
|
echo "${BUCKETS[${i}]}.label ${BUCKETS[${i}]}"
|
||||||
|
done
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
declare -A REQUESTS
|
||||||
|
|
||||||
|
for i in "${!BUCKETS[@]}"
|
||||||
|
do
|
||||||
|
REQUESTS+=([${BUCKETS[${i}]}]=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}"))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "multigraph garage_bucket_unfinished"
|
||||||
|
|
||||||
|
for i in "${!REQUESTS[@]}"
|
||||||
|
do
|
||||||
|
UNFINISHED=$(echo ${REQUESTS[${i}]} | jq -r '.unfinishedUploads')
|
||||||
|
echo "${i}.value ${UNFINISHED}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "multigraph garage_bucket_size"
|
||||||
|
|
||||||
|
for i in "${!REQUESTS[@]}"
|
||||||
|
do
|
||||||
|
BYTES=$(echo ${REQUESTS[${i}]} | jq -r '.bytes')
|
||||||
|
echo "${i}.value ${BYTES}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "multigraph garage_bucket_objects"
|
||||||
|
|
||||||
|
for i in "${!REQUESTS[@]}"
|
||||||
|
do
|
||||||
|
OBJECTS=$(echo ${REQUESTS[${i}]} | jq -r '.objects')
|
||||||
|
echo "${i}.value ${OBJECTS}"
|
||||||
|
done
|
@@ -1,37 +0,0 @@
|
|||||||
#!/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
|
|
||||||
graph_total Total
|
|
||||||
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
|
|
@@ -1,37 +0,0 @@
|
|||||||
#!/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
|
|
@@ -1,37 +0,0 @@
|
|||||||
#!/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 Unfinished multipart uploads by Bucket
|
|
||||||
graph_vlabel Number of unfinished multipart uploads
|
|
||||||
graph_args --base 1000 -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
|
|
||||||
UNFINISHED=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}" | jq -r '.unfinishedUploads')
|
|
||||||
echo "${BUCKETS[${i}]}.value ${UNFINISHED}"
|
|
||||||
done
|
|
@@ -20,14 +20,10 @@
|
|||||||
|
|
||||||
- name: Put garage scripts
|
- name: Put garage scripts
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "files/{{ item }}"
|
src: files/garage_bucket
|
||||||
dest: "/etc/munin/plugins/{{ item }}"
|
dest: /etc/munin/plugins/garage_bucket
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
notify:
|
notify:
|
||||||
- Restart munin-node
|
- Restart munin-node
|
||||||
loop:
|
|
||||||
- garage_bucket_objects
|
|
||||||
- garage_bucket_size
|
|
||||||
- garage_bucket_unfinished
|
|
||||||
|
@@ -1,2 +1,4 @@
|
|||||||
[nvme]
|
[nvme]
|
||||||
user root
|
user root
|
||||||
|
env.nvme_usage_warning 8:101
|
||||||
|
env.nvme_usage_critical 5:101
|
||||||
|
Reference in New Issue
Block a user