2020-05-27 18:41:21 +00:00
|
|
|
#!/bin/sh
|
2020-05-27 10:15:58 +00:00
|
|
|
|
2020-05-27 18:41:21 +00:00
|
|
|
# This script will find the locally active osd-s and display their information with the help of Megacli tools.
|
|
|
|
# Assumes that you run it on a host which has at least 1 osd that matches hdd or ssd disk device class in ceph osd df tree output.
|
|
|
|
#
|
|
|
|
# An example for usage:
|
|
|
|
# for NUM in 14 2 3 4 6 ; do printf "server$NUM\n" >> /tmp/osd_infos; ssh root@server"$NUM".place6.ungleich.ch "/opt/ungleich-tools/map-osd-to-disktype" >> /tmp/osd_infos ; printf "\n \n" >> /tmp/osd_infos; done
|
2020-05-27 10:27:26 +00:00
|
|
|
#
|
2020-05-27 18:41:21 +00:00
|
|
|
# llnu's most hacky/advanced script at the time of writing (2020-05-27)
|
|
|
|
|
|
|
|
|
|
|
|
# Future functionality (arguments, and filtering):
|
2020-05-27 17:21:33 +00:00
|
|
|
#OSDTYPE=ssd
|
2020-05-27 10:27:26 +00:00
|
|
|
|
|
|
|
|
2020-05-27 10:15:58 +00:00
|
|
|
# Tempfile
|
2020-05-27 10:27:26 +00:00
|
|
|
/opt/ungleich-tools/megaclisas-status > /tmp/megaclisas-status.out
|
2020-05-27 10:15:58 +00:00
|
|
|
|
|
|
|
# Gets osd numbers of a particular device class, and gets their mountpoints on the host, and puts them into a tempfile
|
2020-05-27 17:21:33 +00:00
|
|
|
#for osd in $(ceph osd tree | grep $OSDTYPE | grep -v down | cut -b 1-3); do findmnt -t xfs -n -o TARGET,SOURCE | grep "ceph-$osd " | cut -c 24- >> /tmp/list_osd_mountpoint.out; done
|
|
|
|
for osd in $(ceph osd tree | grep 'ssd\|hdd' | grep -v down | cut -b 1-3); do lsblk -p -o NAME,MOUNTPOINT | grep -w "/var/lib/ceph/osd/ceph-$osd" | cut -c 3- >> /tmp/list_osd_mountpoint.out ; done
|
2020-05-27 10:15:58 +00:00
|
|
|
|
|
|
|
# Gets the Megacli mappings for the mountpoints
|
2020-05-27 17:21:33 +00:00
|
|
|
for MOUNT in $(cat /tmp/list_osd_mountpoint.out | awk '{print $1}' | sed 's/[0-9]*//g') ; do cat /tmp/megaclisas-status.out | grep $MOUNT | awk '{print $1}' >> /tmp/megacli-mappings.out; done
|
2020-05-27 10:15:58 +00:00
|
|
|
|
|
|
|
# Gets the hardware types for the Megacli mappings
|
2020-05-27 17:42:27 +00:00
|
|
|
for megacli_mappings in $(cat /tmp/megacli-mappings.out); do awk '/Disk info/,0' /tmp/megaclisas-status.out | grep -w "$megacli_mappings"p0 | cut -d '|' -f 2-6,8 >> /tmp/disk_types.out; done
|
2020-05-27 10:52:02 +00:00
|
|
|
|
|
|
|
# Formatting, to get the local $OSDTYPE osd-s
|
2020-05-27 18:13:39 +00:00
|
|
|
for osd_num in $(cat /tmp/list_osd_mountpoint.out | awk '{print $2}' | cut -c 24- ); do printf "%-7s%s\n" "osd-$osd_num" >> /tmp/local_osds.out; done
|
2020-05-27 10:52:02 +00:00
|
|
|
|
|
|
|
# Combine and display the outputs
|
2020-05-27 18:13:39 +00:00
|
|
|
paste /tmp/local_osds.out /tmp/disk_types.out -d '|'
|
2020-05-27 10:52:02 +00:00
|
|
|
|
|
|
|
# Cleanup *.out files in the temp dir
|
2020-05-27 18:16:58 +00:00
|
|
|
rm /tmp/*.out
|