-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathceph-maintenance
More file actions
46 lines (37 loc) · 1.31 KB
/
ceph-maintenance
File metadata and controls
46 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
ceph_health=$(ceph -s 2>/dev/null | awk '$1 ~ /(noout,norebalance,norecover)/ {print $0}')
ceph2=$(echo $ceph_health)
ID=$(awk -F= '/^ID=/{gsub(/"/, "", $2); print $2}' /etc/os-release)
# Check for supported OS and ceph-common package
if [[ "$ID" == "ubuntu" ]]; then
# Check for ceph-common using apt
if ! apt list --installed 2>/dev/null | grep -qi ceph-common; then
echo "ceph-common not installed on Ubuntu"
exit 1
fi
elif [[ "$ID" == "rocky" || "$ID" == "rhel" ]]; then
# Check for ceph-common using dnf
if ! dnf list installed ceph-common &>/dev/null; then
echo "ceph-common not installed on $ID"
exit 1
fi
else
echo "Unsupported OS: $ID"
exit 1
fi
ceph -s >/dev/null 2>&1
if [ $? != 0 ]; then
echo you do not have permission to enable this
exit 1
fi
if [[ "$ceph_health" != *"noout,norebalance,norecover flag(s) set"* ]]; then
ceph osd set noout
ceph osd set norebalance
ceph osd set norecover
echo -e "ceph maintenance options: \e[1;35mnoout,norebalance,norecover\e[0m \e[1;32menabled\e[0m"
else
ceph osd unset noout
ceph osd unset norebalance
ceph osd unset norecover
echo -e "ceph maintenance options: \e[1;35mnoout,norebalance,norecover\e[0m \e[1;31mdisabled\e[0m"
fi