Skip to content

Commit

Permalink
Collect Bluestore fragmentation score metric for Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
ricolin committed Mar 29, 2024
1 parent 34228a8 commit fc8952a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions roles/osd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ ceph_osd_osds_group: "{{ ceph_osd_group | default('cephs') }}"
# Filesystem ID
ceph_mon_fsid: "{{ ceph_fsid }}"
cephadm_image: "quay.io/ceph/ceph:v{{ ceph_version | default('18.2.1') }}"

ceph_bluestore_frag_collect: true
25 changes: 25 additions & 0 deletions roles/osd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,28 @@
ansible.builtin.include_tasks: check-osds.yml
when:
- inventory_hostname == groups[ceph_osd_osds_group] | last

- name: Prepare Cronjob script for collect Bluestore fragmentation score
when: ceph_bluestore_frag_collect
ansible.builtin.copy:
src: "bs-frag-score.sh.j2"
dest: "/var/lib/cron/bs-frag-score.sh"
owner: root
group: root
mode: u+rwx,g=,o=

- name: Prepare Cronjob script for collect Bluestore fragmentation score

Check failure on line 139 in roles/osd/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

syntax-check[specific]

couldn't resolve module/action 'ansible.builtin.templates'. This often indicates a misspelling, missing collection, or incorrect module path.
when: ceph_bluestore_frag_collect
ansible.builtin.templates:
src: "prom-bs-frag-score-collector.sh.j2"
dest: "/var/lib/cron/prom-bs-frag-score-collector.sh"
owner: root
group: root
mode: u+rwx,g=,o=

- name: Setup Cron job collect Bluestore fragmentation score for Prometheus
when: ceph_bluestore_frag_collect
ansible.builtin.cron:
name: "collect bluestore fragmentation score"
minute: "1"
job: "/var/lib/cron/prom-bs-frag-score-collector.sh"
4 changes: 4 additions & 0 deletions roles/osd/templates/bs-frag-score.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# {{ ansible_managed }}

ceph-volume lvm list|grep "osd id" |grep -o [0-9]*| xargs -i sh -c 'echo bluestore_allocator_score_block{osd=osd.{}} $(ceph daemon osd.{} bluestore allocator score block | grep fragmentation_rating|cut -d ':' -f2) $(date +%s)'
15 changes: 15 additions & 0 deletions roles/osd/templates/prom-bs-frag-score-collector.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# {{ ansible_managed }}

export TMPFILE=/tmp/bluestore_allocator_score_block.prom.$$
osd_path=$(find /var/lib/ceph/{{ ceph_mon_fsid }}/ -type d -name "osd.*"| head -n 1)
if [ -z $osd_path ]; then
cephadm --image "{{ cephadm_image }}" shell --fsid "{{ ceph_mon_fsid }}" \
--config "$osd_path/config" \
-m /var/lib/cron/bs-frag-score.sh -- ./mnt/bs-frag-score.sh > TMPFILE
else
cephadm --image "{{ cephadm_image }}" shell --fsid "{{ ceph_mon_fsid }}" \
-m /var/lib/cron/bs-frag-score.sh -- ./mnt/bs-frag-score.sh > TMPFILE
fi

mv $TMPFILE /tmp/bluestore_allocator_score_block.prom

0 comments on commit fc8952a

Please sign in to comment.