ungleich-tools/monit-ceph-create-start

48 lines
953 B
Text
Raw Permalink Normal View History

2018-02-22 12:19:40 +00:00
#!/bin/sh
# Nico Schottelius, 2018-02-22
# Copyright ungleich glarus ag
if [ $# -ne 1 ]; then
echo "$0: to monitor"
echo "f.i. osd.17 or mon.server4"
exit 1
fi
to_monitor=$1
set -e
2018-02-22 12:19:40 +00:00
2018-03-08 13:14:01 +00:00
depends="cephrundir"
2018-02-22 13:30:23 +00:00
osd=""
conf="/etc/monit/conf.d/$to_monitor"
2018-02-22 13:30:23 +00:00
if echo $to_monitor | grep ^osd; then
2018-03-08 13:14:01 +00:00
depends="${depends}, ${to_monitor}-whoami"
2018-02-22 13:30:23 +00:00
osd="yes"
osdid=$(echo $to_monitor | cut -d. -f2)
fi
2018-03-08 13:14:01 +00:00
2018-02-22 13:30:23 +00:00
cat > "$conf" <<EOF
# Generated by $0
2018-02-22 13:32:49 +00:00
check process ${to_monitor} with pidfile /var/run/ceph/${to_monitor}.pid
2018-02-22 12:19:40 +00:00
start program = "/etc/init.d/ceph start ${to_monitor}" with timeout 60 seconds
stop program = "/etc/init.d/ceph stop ${to_monitor}"
2018-02-22 13:31:53 +00:00
2018-02-22 13:30:23 +00:00
group ceph
2018-03-08 13:14:01 +00:00
depends on $depends
2018-02-22 13:30:23 +00:00
EOF
2018-02-22 12:19:40 +00:00
2018-02-22 13:30:23 +00:00
if [ "$osd" ]; then
cat >> "$conf" <<EOF
check file ${to_monitor}-whoami with path /var/lib/ceph/osd/ceph-${osdid}/whoami
if content != "${osdid}" then alert
2018-02-22 12:19:40 +00:00
EOF
2018-02-22 13:31:06 +00:00
fi
2018-02-22 13:30:23 +00:00
2018-05-24 18:22:58 +00:00
/etc/init.d/monit restart
# monit reload
sleep 1
2018-02-22 13:32:49 +00:00
monit start "${to_monitor}"