我正在尝试使用monit,并使用gmail设置电子邮件服务器。 configuration文件是这样的:
set mailserver smtp.gmail.com port 587 username "[email protected]" password "password" using tlsv1 with timeout 30 seconds
我设置了一个警报来testing:
check file alerttest with path /.nonexistent alert [email protected] with reminder on 500 cycles
但是当我使用monitvalidation时,我得到的错误信息是这样的:
Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable Alert handler failed, retry scheduled for next cycle 'alerttest' file doesn't exist Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable 'alerttest' trying to restart
任何人有任何想法? 非常感谢
除非您有实际的帐户,否则您不能configuration其他公司的电子邮件服务器来传送电子邮件。 即使你有一个帐户监控不是最好的scheme来处理提交电子邮件。 我会build议只安装一个本地MTA来监听127.0.0.1,然后像这样configuration监听:
set mailserver 127.0.0.1
在这种情况下,monit会将电子邮件交付给实际的MTA,然后他们可以把它发送出去,MTA完全有能力处理远程服务器不可用,不像monit(因为它不是这样做的)。
如何设置和configurationMTA超出了这个问题的范围,但是如果你想直接发送邮件,最好是有一个静态IP,rDNS和mxlogging。 或者您可以使用远程智能主机/网关。
编辑:简要说明如何安装postfix
跑:
apt-get install postfix
select:
互联网网站
系统邮件名称:
无论你的系统有什么主机名
您现在将configurationpostfix来发送和接收来自互联网的电子邮件。 现在,如上所述configurationmonit时,您将能够发送电子邮件。
重要的是 ,为了提高传输能力,您需要确保您的IP地址具有反向DNSlogging,以parsing您的域名。
例如,如果你的域名是example.org,你的服务器是monit.example.org,那么它应该解决这样的问题:
host monit.example.org monit.example.org has address 192.0.43.10 host 192.0.43.10 10.43.0.192.in-addr.arpa domain name pointer monit.example.org
虽然它可以parsing到一个不同的主机名,只要域是相同的。 这是因为许多电子邮件服务器将检查您是否有有效的rDNS。 您可以请求您的ISP(在这种情况下是亚马逊)为您更改rDNS。
您可以使用远程邮件服务器。 这里是我的示例configuration工作。 它通过远程smtp服务器发送警报给我的Gmail。 我想你还是使用Gmail作为smtp中继。
的/ etc / monit的/ monitrc
设置邮件服务器mail.yourmailserver.com端口587
用户名“[email protected]”密码“mypassword”
使用tlsv1
超时30秒
设置邮件格式{from:[email protected]}
// /etc/monit/conf.d/monit.services
检查进程Apache的pidfile /var/run/apache2/apache2.pid警报[email protected]只有在{超时,非主机,资源,PID,连接}启动程序=“/etc/init.d/apache2开始”超时60秒停止程序=“/etc/init.d/apache2停止”