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
|
36
roles/munin_client/files/garage_bucket_size
Executable file
36
roles/munin_client/files/garage_bucket_size
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 Bytes by Bucket
|
||||
graph_vlabel Bytes
|
||||
graph_args --base 1024 -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
|
||||
BYTES=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}" | jq -r '.bytes')
|
||||
echo "${BUCKETS[${i}]}.value ${BYTES}"
|
||||
done
|
36
roles/munin_client/files/garage_bucket_unfinished
Executable file
36
roles/munin_client/files/garage_bucket_unfinished
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 Unfinished multipart uploads by Bucket
|
||||
graph_vlabel Number of unfinished multipart uploads
|
||||
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
|
||||
UNFINISHED=$(curl -s -H "${HEADER}" "http://[::1]:3903/v0/bucket?id=${i}" | jq -r '.unfinishedUploads')
|
||||
echo "${BUCKETS[${i}]}.value ${UNFINISHED}"
|
||||
done
|
23
roles/munin_client/tasks/garage.yml
Normal file
23
roles/munin_client/tasks/garage.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- name: Put garage plugin configuration
|
||||
ansible.builtin.template:
|
||||
src: garage.j2
|
||||
dest: /etc/munin/plugin-conf.d/garage
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0640'
|
||||
|
||||
- name: Put garage scripts
|
||||
ansible.builtin.copy:
|
||||
src: "files/{{ item }}"
|
||||
dest: "/etc/munin/plugins/{{ item }}"
|
||||
owner: root
|
||||
user: root
|
||||
mode: '0755'
|
||||
notify:
|
||||
- Restart munin-node
|
||||
loop:
|
||||
- garage_bucket_objects
|
||||
- garage_bucket_size
|
||||
- garage_bucket_unfinished
|
@@ -109,12 +109,17 @@
|
||||
loop:
|
||||
- users
|
||||
|
||||
# Useless junks for hypervisors
|
||||
- name: Execute delete states for hypervisors
|
||||
ansible.builtin.include_tasks: hypervisors.yml
|
||||
when: "'hypervisors' in group_names"
|
||||
|
||||
# Specific LXC commands
|
||||
- name: Execute specific LXC commands
|
||||
ansible.builtin.include_tasks: lxc.yml
|
||||
when: ansible_facts['virtualization_type'] == "lxc"
|
||||
|
||||
# Useless junks for hypervisors
|
||||
- name: Execute delete states for hypervisors
|
||||
ansible.builtin.include_tasks: hypervisors.yml
|
||||
when: "'hypervisors' in group_names"
|
||||
# Specific garage commands
|
||||
- name: Execute specific garage commands
|
||||
ansible.builtin.include_tasks: garage.yml
|
||||
when: "'garagegw' in inventory_hostname"
|
||||
|
2
roles/munin_client/templates/garage.j2
Normal file
2
roles/munin_client/templates/garage.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
[garage*]
|
||||
env.BEARER {{ garage_admin_token }}
|
Reference in New Issue
Block a user