Skip to content

Instantly share code, notes, and snippets.

@linuxkidd
Created March 4, 2015 22:57
Show Gist options
  • Save linuxkidd/1aa61ac7e36e01213068 to your computer and use it in GitHub Desktop.
Save linuxkidd/1aa61ac7e36e01213068 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo osd,device,pci id,pci path,description
for i in $(mount | awk '/ceph\/osd/ {printf("%s,%s\n", $1, $3)}'); do
osdid=$(echo $i | awk -F, '{print $2}' | awk -F\/ '{sub (/[^0-9]+/, "", $NF); print "osd."$NF}')
basedev=$(basename $(echo $i | awk -F, '{print $1}' | sed -e 's/[0-9]//g'))
syspath=$(find /sys/devices/ -name $basedev)
hostpath=$(basename $(echo $syspath | awk -F\/host '{print $1}') | sed -e 's/^[0-9]*://')
if [ $(echo $hostpath | grep ata -c) -gt 0 ]; then
hostpath=$(basename $(dirname $(echo $syspath | awk -F\/host '{print $1}')) | sed -e 's/^[0-9]*://')
fi
hostdev=$(lspci | grep ^$hostpath)
echo "$osdid,$basedev,$hostdev" | sed -e 's/\ /,/'
done
@linuxkidd
Copy link
Author

The objective is to identify which storage controller each OSD is plugged into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment