2011-04-28 20 views
3

的解決方案是替代這一行:monit的在CentOS使未httpd.pid要創建

check process apache with pidfile /var/run/httpd.pid 

利用該行:

check process httpd with pidfile /var/run/httpd/httpd.pid 

我也除去「組阿帕奇」。

原帖:

在CentOS爲Apache(httpd的)服務安裝Monit,並設置警報後,該服務不再創建/var/run/httpd.pid文件。

httpd服務IS正常運行。

在它的上面,彷彿這還不夠,monit的報告作爲服務的狀態:執行失敗

當然,重新啓動這樣的服務的唯一途徑是通過殺死它,因爲「重啓」腳本沒有看到任何正在運行的進程。

這些都是/etc/monit.d/monitrc文件的內容:

set daemon 10 
set logfile syslog facility log_daemon 
set mailserver localhost 
set mail-format { from: [email protected] } 
set alert [email protected] 
set httpd port 2812 and 
#  SSL ENABLE 
#  PEMFILE /var/certs/monit.pem 
allow user:password 

check process apache with pidfile /var/run/httpd.pid 
group apache 
start program = "/etc/init.d/httpd start" 
stop program = "/etc/init.d/httpd stop" 
if cpu is greater than 180% for 1 cycles then alert 
if totalmem > 1200 MB for 2 cycles then restart 
if children > 250 then restart 

check process sshd with pidfile /var/run/sshd.pid 
start program "/etc/init.d/sshd start" 
stop program "/etc/init.d/sshd stop" 
if failed port 22 protocol ssh for 5 cycles then restart 
if 5 restarts within 25 cycles then timeout 

「服務的httpd重新啓動」 的輸出:

Stopping httpd:           [FAILED] 
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 
no listening sockets available, shutting down 
Unable to open logs 
                 [FAILED] 

任何幫助將不勝感激。

+0

難道你不是指「monit restart httpd」嗎?那麼「monit stop httpd」和「monit start httpd」呢? 是否monit停止/啓動/重新啓動sshd好嗎? – 2011-04-28 14:47:02

+0

謝謝abunetta。 當重新啓動時,停止,從Monit開始到httpd,沒有消息。但服務也沒有停止。 我不能試圖阻止sshd的,因爲它會離開我,在我的機器:-) – bizna 2011-04-29 13:38:31

+0

嘗試使用發現這裏的建議是:要http://stackoverflow.com/questions/3356476/debugging-monit/4439403#4439403當monit呼叫停止時,更好地瞭解發生了什麼。當我從命令行調用它時,我假設monitrc中的停止命令有效。關於「monit restart sshd」;我仍然建議嘗試它作爲一個完整性檢查。您將設法以某種方式回到機器中,如果它不起作用:-) – 2011-04-30 19:15:17

回答

5

嘗試用/usr/sbin/httpd -k stop更換停止程序。它適合我。

+0

在Fedora 8上爲我工作。謝謝 – ShadyKiller 2011-10-03 13:01:52

+1

也適用於CentOS 5 – alanthing 2013-07-03 21:22:17

0

我有同樣的問題,但/usr/sbin/httpd -k stop似乎並沒有幫助,因爲這仍然試圖從pid文件查找的進程ID。我選擇了stop program = "/usr/bin/killall httpd"。我不認爲這是非常優雅的(可能殺死打開的請求),但它是我能找到重新啓動apache並讓monit重新創建pid文件的唯一方法。

0

我認爲monit正在重新啓動,因爲'stop;開始「,並且在開始新進程之前不等待」停止「完成,並因此在不適當的時間刪除pid文件。至少,這是對所有這些做出修改後的結論。

我發現了一個參考的人誰被「停止」語句之後做出的monit睡眠修復了這個問題。

就個人而言,我發現,替換'重啓「開始」當HTTP服務器已關閉工作就好了。