私はMariaDB
モニターが欲しいですmonit tools
。私monit script
のもの:
check process mariadb_pid with pidfile /var/lib/mysql/db1.pid
check program telnet with path "/root/telnet.sh"
if status eq 99 then exec "/usr/bin/systemctl restart mariadb.service"
そしてtelnet script
:
#!/bin/bash
cat /root/ips | \
while read host port; do
result=$(bash -c 'exec 3<> /dev/tcp/'$host'/'$port';echo $?' 2>/dev/null)
echo $result
if [ "$result" != "0" ]; then
exit 99
fi
done
ips
ファイルは次のようになります。
192.168.10.10 3306
192.168.10.20 3306
これで、ipsファイルのmariadb ip1とip2が閉じられたときに実行されることが予想されます。
if status eq 99 then exec "/usr/bin/systemctl restart mariadb.service"
でも走らないでください。監視ログを確認してください。
[EST Mar 5 00:34:19] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:24] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:29] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:34] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:39] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:44] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:49] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:54] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:34:59] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:04] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:09] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:14] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:19] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:24] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:29] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:34] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:39] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:44] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:49] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:35:54] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:00] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:05] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:10] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:15] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:20] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:25] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:30] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:35] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:40] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:45] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:50] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:36:55] error : 'telnet' status failed (99) -- 1
また、この行は monit の再起動時に初めて実行されます。
[EST Mar 5 00:39:05] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:10] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:15] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:20] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:25] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:26] info : Reinitializing monit daemon
[EST Mar 5 00:39:26] info : Reinitializing Monit -- control file '/etc/monitrc
[EST Mar 5 00:39:26] info : 'db1' Monit reloaded
[EST Mar 5 00:39:31] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:31] info : 'telnet' exec: '/usr/bin/systemctl restart mariadb.service'
[EST Mar 5 00:39:36] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:41] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:46] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:51] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:39:56] error : 'telnet' status failed (99) -- 1
[EST Mar 5 00:40:01] error : 'telnet' status failed (99) -- 1
誰でもこれの経験がありますか?