monit 在 [localhost]:8080 处失败了协议测试

monit 在 [localhost]:8080 处失败了协议测试

我经常会收到错误“monit failed protocol test [HTTP] at [localhost]:8080”。应用程序 tomcat 并未停止,仍在正常运行。我知道端口 8080 已打开,因为我可以在个人电脑的浏览器中访问它(因此不是 localhost)。我还可以检查什么来查看发生了什么?

一些回答别人问题的日志:

今天早上 3 点 26 分或 3 点 27 分又发生了这种情况,因此,首先,这里是当时的监控日志:

[EDT May 19 03:26:01] info     : Reinitializing monit daemon
[EDT May 19 03:26:01] info     : 'newapp.turnsmith.com' Monit reloaded
[EDT May 19 03:26:01] error    : 'tomcat' failed protocol test [HTTP] at [localhost]:8080 [TCP/IP] -- HTTP error: Server returned status 404
[EDT May 19 03:26:01] info     : 'tomcat' start: '/etc/init.d/tomcat start'
[EDT May 19 03:26:01] error    : 'tomcat' failed protocol test [HTTP] at [localhost]:8080 [TCP/IP] -- HTTP error: Server returned status 404
[EDT May 19 03:27:01] error    : 'tomcat' failed protocol test [HTTP] at [localhost]:8080 [TCP/IP] -- HTTP error: Server returned status 404
[EDT May 19 03:27:01] info     : 'tomcat' start: '/etc/init.d/tomcat start'

以下是来自 http 的日志 error_log:

[Sun May 19 03:26:01.573204 2019] [auth_digest:notice] [pid 3625] AH01757: generating secret for digest authentication ...
[Sun May 19 03:26:01.573817 2019] [lbmethod_heartbeat:notice] [pid 3625] AH02282: No slotmem from mod_heartmonitor
[Sun May 19 03:26:01.573856 2019] [mpm_prefork:notice] [pid 3625] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Sun May 19 03:26:01.573859 2019] [core:notice] [pid 3625] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

实际上,错误发生得更多,但我们只收到一次“警报”电子邮件。

另外,我不知道这是否有帮助,但这里是 tomcat 的 monit 配置( /etc/monit.d/tomcat ):

check host tomcat with address localhost
 stop program = "/etc/init.d/tomcat stop"
 start program = "/etc/init.d/tomcat start"
 if failed port 8080 and protocol http then alert
 if failed port 8080 and protocol http then start

更新于 2019/5/20:根据 @asktyagi 的建议,我将配置更改为以下内容,看看是否有效:

check host tomcat with address localhost
 stop program = "/etc/init.d/tomcat stop"
 start program = "/etc/init.d/tomcat start"
 if failed port 8080 and protocol http retry 5 then alert
 if failed port 8080 and protocol http retry 5 then start

答案1

你能在警报发生时检查 monit 和 http 日志吗?一些可能性是:http 端口耗尽或 http 处于压力/繁忙状态。如果是这样,请尝试使用重试。编辑:您也可以尝试删除协议并使用如下所示 if failed port {port number} then restart

答案2

根据@asktyagi 的建议,我使用以下配置使其运行得更好:

check host tomcat with address localhost
 stop program = "/etc/init.d/tomcat stop"
 start program = "/etc/init.d/tomcat start"
 ## if failed port 8080 and protocol http for 20 cycles then alert
 if failed port 8080 then alert
 ##if failed port 8080 and protocol http for 40 cycles then start
 if failed port 8080 then start

就我而言,“重试”虽然减少了发生次数,但并没有起到作用。此外,根据这里,我尝试了“for x cycles”的想法,实际上将其从每分钟多次减少到每分钟仅一次。显然,我坚持 @asktyagi 的想法,因为到目前为止,它消除了这个问题,但我确实想告诉人们我的想法。

相关内容