forked from ryanblack/zabbix_ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceph-data.sh
66 lines (63 loc) · 1.35 KB
/
ceph-data.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
62
63
64
65
66
#!/bin/bash
ceph_bin="/usr/bin/ceph"
# Return the value
case $1 in
daemon_osd_status)
status=$($ceph_bin osd dump | grep $2 | awk '{print $2}')
case $status in
up)
echo 1
;;
down)
echo 0
;;
*)
echo 2
;;
esac
;;
daemon_mon_status)
status=$(ssh root@$(echo $2 | cut -d'.' -f2) "sudo systemctl status ceph-osd@*" |grep Active:|awk '{print $2}')
case $status in
active)
echo 1
;;
inactive)
echo 0
;;
*)
echo 2
;;
esac
;;
daemon_mds_status)
status=$($ceph_bin fs dump 2>/dev/null|grep $2|cut -d':' -f3|awk '{print $4}')
case $status in
up)
echo 1
;;
down)
echo 0
;;
*)
echo 2
;;
esac
;;
spacetotal)
echo $($ceph_bin df |awk '{print $1}'|grep G|sed '1d'|cut -d"G" -f1|bc)
;;
spaceavail)
echo $($ceph_bin df |awk '{print $2}'|grep G|cut -d"G" -f1)
;;
poolspaceavail)
poolspaceavail=$($ceph_bin df|grep $2 |awk '{print $5}'|cut -d"M" -f1)
#poolspaceavail=$(echo "scale=2; $poolspaceavail/1000"|bc)
echo $(echo "scale=2; $poolspaceavail/1000"|bc)
;;
osdspaceavail)
echo $(ssh root@$2 "sudo df -h" |grep ceph|awk '{print $4}'|cut -d'G' -f1)
;;
osdcount)
echo $($ceph_bin osd dump |grep max_osd|awk '{print $2}')
esac