Centos7

監控失敗的協議測試H噸噸磷H噸噸磷HTTP在loclhost_l這C一種lH這s噸localhost:8080

  • May 23, 2019

我收到錯誤“監控失敗的協議測試

$$ HTTP $$在$$ localhost $$:8080" 每隔一段時間。應用程序,tomcat,並沒有停止,仍然執行得很好。我知道埠 8080 是打開的,因為我可以在我的個人 PC 上的瀏覽器中訪問它(所以不是 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 的監控配置( /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

您可以在警報時檢查 monit 和 http 日誌嗎?一些可能性是:http 埠用盡或 http 處於壓力/忙碌狀態。如果是這樣,請嘗試使用RETRY。編輯:您也可以嘗試刪除協議並使用如下 if failed port {port number} then restart

根據@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 個週期”的想法,實際上將其從每分鐘多次減少到每分鐘僅一次。顯然,我堅持使用@asktyagi 的想法,因為到目前為止,它消除了問題,但確實想告訴人們我的發現。

引用自:https://serverfault.com/questions/967918