Apache, MySQL 및 Postfix에 대한 Monit 구성

Apache, MySQL 및 Postfix에 대한 Monit 구성

아래 구성을 사용하여 프로덕션 서버에서 Monit을 활성화할 계획입니다. 저는 Monit을 처음 접했고, 귀하의 경험을 바탕으로 모니터링 스크립트를 강화하기 위해 고려해야 할 다른 지침이나 팁에 대해 다른 사람들의 의견을 듣고 싶었습니다.

내 서버는 CentOS 5.6입니다.

감사해요!

#httpd----
check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if 5 restarts within 5 cycles then timeout

#mysqld----
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if 5 restarts within 5 cycles then timeout

#postfix----
check process postfix with pidfile /var/spool/postfix/pid/master.pid
start program = "/etc/init.d/postfix start"
stop program  = "/etc/init.d/postfix stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if 5 restarts within 5 cycles then timeout

답변1

Monit에 대한 Postfix 섹션에 추가 줄이 있습니다.

if failed port 25 protocol smtp then restart

Apache에서 제공하는 항목에 따라 request "/monit_token"일반 HTTP 응답 대신 요청(예: )을 테스트할 수 있습니다. 요청은 단순한 정적 파일이 아니라 앱에 직접 전달되는 것일 수 있습니다. 다시 말하지만, 그것은 당신이 하고 있는 일에 달려 있습니다.

거기에 Postfix가 있으므로 Postfix가 다운된 경우 Monit 경고가 실제로 어떻게 상자에서 벗어날 것인지 고려해야 합니다. 내 경우에는 set mailserver gmail-smtp-in.l.google.comGmail 계정으로 메일을 보내 알림 이메일을 받기 위해 내 메일 서버의 기능에 의존하지 않습니다. 또한 경고 메시지를 SMS 게이트웨이로 전달하는 Gmail 필터가 있어서 문자를 받습니다.

또한 다음과 같은 구성이 있습니다.

check file alerttest with path /.monit_is_running
  alert [email protected] with reminder on 1440 cycles

파일이 없으므로 /.monit_is_running이 경고는 항상 하루에 한 번씩 실행됩니다. 이것은 monit 자체의 하트비트이므로 실행 중이라는 것을 알 수 있습니다(일종의 "감시자를 감시하는 사람"). 이것은 실제로 Serverfault의 누군가로부터 얻은 아이디어이지만 누구인지 기억이 나지 않습니다.

관련 정보