set alert you@gmail.com with mail-format {
from: my@gmail.com
subject: $SERVICE $EVENT at $DATE
message:
Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
Yours sincerely,
monit
}
set mailserver smtp.gmail.com port 587 username "my@gmail.com" password "mypassword" using tlsv1
check process httpd with pidfile /var/run/httpd.pid
start program ="/etc/init.d/httpd start"
stop program ="/etc/init.d/httpd stop"
if failed host www.example.com port 80
protocol HTTP request /alive.html then alert
group httpd
簡単に解説しておきます。
1行目 : alert 発生時のメールの送信先をyou@gmail.comとしています。
さらに続けて、メールのメッセージフォーマットを設定しています。
送信元 : my@gmail.comとしています。
タイトル : $SERVICE $EVENT at $DATEとしています。
※$が付いているものは、Monitで使える環境変数のようなものです。
$SERVICE : サービス名
$EVENT : イベント名
$DATE : 発生日時
メール内容 : Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION. …. としています。
※$が付いているものは、Monitで使える環境変数のようなものです。
$/usr/bin/monit-vIRuntime constants: Control file = /etc/monit.conf Log file = /var/log/monit Pid file = /var/run/monit.pid Debug = True Log = True Use syslog = False Is Daemon = True Use process engine = True Poll time = 60 seconds Mail server(s) = smtp.gmail.com:587(ssl) Mail from = (not defined) Mail subject = (not defined) Mail message = (not defined) Start monit httpd = False Alert mail to = you@gmail.com Alert on = All eventsThe service list contains the following entries:Process Name = httpd Group = httpd Pid file = /var/run/httpd.pid Monitoring mode = active Start program = '/etc/init.d/httpd start' timeout 1 cycle(s) Stop program = '/etc/init.d/httpd stop' timeout 1 cycle(s) Pid = if changed 1 times within 1 cycle(s) then alert Ppid = if changed 1 times within 1 cycle(s) then alert Port = if failed www.example.com:80/alive.html [HTTP via TCP] with timeout 5 seconds 1 times within 1 cycle(s) then alert else if passed 1 times within 1 cycle(s) then alertSystem Name = host.example.com Monitoring mode = active-------------------------------------------------------------------------------monit: pidfile '/var/run/monit.pid' does not existMonit startedMonit instance changed notification is sent to you@gmail.com'httpd' zombie check passed [status_flag=0000]'httpd' succeeded connecting to INET[www.example.com:80] via TCP'httpd' succeeded testing protocol [HTTP] at INET[www.example.com:80] via TCP
$/usr/bin/monit-vI...-------------------------------------------------------------------------------monit: pidfile '/var/run/monit.pid' does not existMonit startedMonit instance changed notification is sent to you@gmail.com'httpd' zombie check passed [status_flag=0000]'httpd' succeeded connecting to INET[www.example.com:80] via TCP'httpd' succeeded testing protocol [HTTP] at INET[www.example.com:80] via TCP...'httpd' zombie check passed [status_flag=0000]'httpd' succeeded connecting to INET[www.example.com:80] via TCPHTTP error: Server returned status 404'httpd' failed protocol test [HTTP] at INET[www.example.com:80] via TCPConnection failed notification is sent to you@gmail.com
ちゃんと送信されたみたいですね。
これでOKのはずです。
you@gmail.comの受信メッセージを確認してみてください。
Subject : httpd Connection failed at Mon, 20 Dec 2010 04:22:19 +0900
Monit alert httpd at Mon, 20 Dec 2010 04:22:19 +0900 on host.example.com: 'httpd' failed protocol test [HTTP] at INET[www.example.com:80] via TCP.
Yours sincerely,
monit
コメントを投稿 :