diff --git a/roles/munin_client/files/garage_bucket b/roles/munin_client/files/garage_bucket new file mode 100644 index 0000000..2e14f24 --- /dev/null +++ b/roles/munin_client/files/garage_bucket @@ -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 diff --git a/roles/munin_client/files/garage_bucket_objects b/roles/munin_client/files/garage_bucket_objects deleted file mode 100755 index 87c2314..0000000 --- a/roles/munin_client/files/garage_bucket_objects +++ /dev/null @@ -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 diff --git a/roles/munin_client/files/garage_bucket_size b/roles/munin_client/files/garage_bucket_size deleted file mode 100755 index 590131d..0000000 --- a/roles/munin_client/files/garage_bucket_size +++ /dev/null @@ -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 diff --git a/roles/munin_client/files/garage_bucket_unfinished b/roles/munin_client/files/garage_bucket_unfinished deleted file mode 100755 index 1607a07..0000000 --- a/roles/munin_client/files/garage_bucket_unfinished +++ /dev/null @@ -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 diff --git a/roles/munin_client/tasks/garage.yml b/roles/munin_client/tasks/garage.yml index 7f999c7..d441bb2 100644 --- a/roles/munin_client/tasks/garage.yml +++ b/roles/munin_client/tasks/garage.yml @@ -20,14 +20,10 @@ - name: Put garage scripts ansible.builtin.copy: - src: "files/{{ item }}" - dest: "/etc/munin/plugins/{{ item }}" + src: files/garage_bucket + dest: /etc/munin/plugins/garage_bucket owner: root group: root mode: '0755' notify: - Restart munin-node - loop: - - garage_bucket_objects - - garage_bucket_size - - garage_bucket_unfinished diff --git a/roles/munin_client/templates/nvme.j2 b/roles/munin_client/templates/nvme.j2 index 31ac903..affd32f 100644 --- a/roles/munin_client/templates/nvme.j2 +++ b/roles/munin_client/templates/nvme.j2 @@ -1,2 +1,4 @@ [nvme] user root +env.nvme_usage_warning 8:101 +env.nvme_usage_critical 5:101