-
Notifications
You must be signed in to change notification settings - Fork 4
/
ceph-daemon-discovery.sh
61 lines (58 loc) · 1.41 KB
/
ceph-daemon-discovery.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -o nounset
set -o errexit
PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
export PATH
#GET OSD DAEMONS
DAEOSD=`ceph osd tree |grep osd.|awk '{print $3}'`
#GET MON DAEMONS
#DAEMON=`ceph -s |grep quorum| awk -F "quorum" '{print $2}'|cut -d' ' -f3|cut -d',' -f 1- --output-delimiter=$'\n'`
DAEMON=`ceph mon dump 2>/dev/null|grep mon|awk '{print $3}'`
#GET MDS DAEMONS
DAEMDS=`ceph fs dump 2>/dev/null|grep seq|awk '{print $4}'`
if [[ -n $DAEOSD ]]; then
echo -e "{\n";
echo -e "\t\"data\":[\n\n";
first=1
for DMN in $DAEOSD; do
if [ $first == 0 ]; then
echo -e "\t,\n"
else
first=0
fi
echo -e "\t{\n"
echo -e "\t\t\"{#DMNOSD}\":\"$DMN\"\n"
echo -e "\n\t}\n"
done
echo -e "\t,\n"
fi
if [[ -n $DAEMON ]]; then
first=1
for DMN in $DAEMON; do
if [ $first == 0 ]; then
echo -e "\t,\n"
else
first=0
fi
echo -e "\t{\n"
echo -e "\t\t\"{#DMNMON}\":\"$DMN\"\n"
echo -e "\n\t}\n"
done
echo -e "\t,\n"
fi
if [[ -n $DAEMDS ]]; then
first=1
for DMN in $DAEMDS; do
if [ $first == 0 ]; then
echo -e "\t,\n"
else
first=0
fi
echo -e "\t{\n"
echo -e "\t\t\"{#DMNMDS}\":\"$DMN\"\n"
echo -e "\n\t}\n"
done
echo -e "\n\t]\n"
echo -e "}\n";
fi
exit 0