3

解決策は、次の行を置き換えることでした。

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

この行で:

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

また、「グループ apache」も削除しました。

元の投稿:

CentOS にMonitをインストールし、Apache (httpd) サービスのアラートを設定すると、サービスは /var/run/httpd.pid ファイルを作成しなくなります。

httpd サービス正常に実行されています。

さらに、それだけでは不十分であるかのように、Monit はサービスのステータスを次のように報告します。

当然のことながら、このようなサービスを再起動する唯一の方法は、強制終了することです。これは、「再起動」スクリプトが実行中のプロセスを認識しないためです。

/etc/monit.d/monitrc ファイルの内容は次のとおりです。

set daemon  10
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: me@server.com }
set alert bugs@server.com
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

「service httpd restart」の出力:

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]

どんな助けでも大歓迎です。

4

3 に答える 3

5

停止プログラムを に置き換えてみてください/usr/sbin/httpd -k stop。それは私のために働く。

于 2011-08-08T17:22:01.987 に答える
0

monit は 'stop;' として再起動を行っていると思います。新しいプロセスを開始する前に 'stop' が終了するのを待っていないため、pid ファイルが不適切な時間に削除されています。少なくとも、これがすべてをいじった後の私の結論です。

「stop」ステートメントの後に monit をスリープ状態にすることでこの問題を解決した人への言及を見つけました。

個人的には、http サーバーがダウンしているときに「restart」を「start」に置き換えると、問題なく機能することがわかりました。

于 2013-02-05T21:13:26.460 に答える
0

私は同じ問題を抱えていましたが/usr/sbin/httpd -k stop、これはまだpidファイルからプロセスIDを検索しようとするため、役に立たないようです。

私はを選びましたstop program = "/usr/bin/killall httpd"。これはあまりエレガントではないと思います (おそらくオープン リクエストを強制終了します) が、apache を再起動して pid ファイルを monit で再作成する唯一の方法でした。

于 2012-03-19T14:06:30.200 に答える