Skip to content

Instantly share code, notes, and snippets.

@linuxkidd
Last active August 8, 2019 13:01
Show Gist options
  • Select an option

  • Save linuxkidd/b54935324cc86be63db5a1e8628d8dad to your computer and use it in GitHub Desktop.

Select an option

Save linuxkidd/b54935324cc86be63db5a1e8628d8dad to your computer and use it in GitHub Desktop.
Mark each OSD down in a Ceph cluster, waiting for previous OSD to come up before downing the next.
#!/bin/bash
totalosds=$(ceph osd tree | grep -c osd\\.[0-9][0-9]*.*up)
osdcounter=1
for i in $(ceph osd tree | awk '/up/ {split($3,a,".");print a[2]}');do
echo -n "Currently at: $osdcounter / $totalosds == "
echo "scale=2; $osdcounter/$totalosds*100" | bc
isup=$(ceph osd dump | grep -c osd\\.$i\ up)
if [ $isup -eq 1 ]; then
ceph osd down osd.$i
while [ $(ceph osd dump | grep -c osd\\.$i\ up) -eq 0 ];do
echo -n .
sleep 1
done
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment