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
|
|
|
|
|
2018-02-22 12:22:02 +00:00
|
|
|
set -e
|
2018-02-22 12:19:40 +00:00
|
|
|
|
2018-03-08 13:14:01 +00:00
|
|
|
depends="cephrundir"
|
2018-02-23 07:25:46 +00:00
|
|
|
conf="/etc/monit/conf.d/$to_monitor"
|
2018-02-22 13:30:23 +00:00
|
|
|
|
2021-02-07 12:01:48 +00:00
|
|
|
daemon=$(echo $to_monitor | awk -F . '{ print $1 }')
|
|
|
|
id=$(echo $to_monitor | awk -F . '{ print $2 }')
|
2018-03-08 13:14:01 +00:00
|
|
|
|
2020-07-02 19:42:46 +00:00
|
|
|
|
2021-02-07 12:01:48 +00:00
|
|
|
case "$daemon" in
|
|
|
|
osd)
|
|
|
|
depends="${depends}, ${to_monitor}-whoami"
|
2021-09-05 09:24:40 +00:00
|
|
|
cat > "$conf" <<EOF
|
2021-02-07 12:01:48 +00:00
|
|
|
check file ${to_monitor}-whoami with path /var/lib/ceph/osd/ceph-${id}/whoami
|
|
|
|
if content != "${id}" then alert
|
2020-07-02 19:42:46 +00:00
|
|
|
EOF
|
|
|
|
|
2021-02-07 12:01:48 +00:00
|
|
|
;;
|
2021-02-07 12:04:21 +00:00
|
|
|
esac
|
2020-07-02 19:42:46 +00:00
|
|
|
|
|
|
|
cat >> "$conf" <<EOF
|
2021-02-07 12:01:48 +00:00
|
|
|
# Generated by $0
|
|
|
|
check process ${to_monitor} with pidfile /var/run/ceph/${to_monitor}.pid
|
2021-02-07 12:27:51 +00:00
|
|
|
start program = "/usr/bin/ceph-${daemon} -i ${id} --pid-file /var/run/ceph/${daemon}.${id}.pid -c /etc/ceph/ceph.conf --cluster ceph --setuser ceph --setgroup ceph" with timeout 3600 seconds
|
2021-02-07 12:01:48 +00:00
|
|
|
stop program = "/usr/bin/pkill -f '/usr/bin/ceph-${daemon} -i ${id}'"
|
2018-02-22 13:31:53 +00:00
|
|
|
|
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-05-24 18:22:58 +00:00
|
|
|
/etc/init.d/monit restart
|
|
|
|
# monit reload
|
2018-02-22 12:22:02 +00:00
|
|
|
sleep 1
|
2018-02-22 13:32:49 +00:00
|
|
|
monit start "${to_monitor}"
|