1

サーバーを監視しようとしていますが、ダウンしたときにサーバーを再起動したいだけです。以下は私のモニターコントロールです

check process myserver with pidfile "/home/path/to/myserver.pid"
start program = "/etc/init.d/myserver start"
stop program = "/etc/init.d/myserver stop"
if failed host 127.0.0.1 port 8080 protocol http
then restart

ただし、サーバーが実行されている場合でも、monit は次のようなエラーを返します。

'myserver' process not running
trying to restart 'myserver'
failed to restart myserver.

これを修正するにはどうすればよいですか? 私はいくつかの間違いを犯していますか?

また、「send」と「expect」を使用しようとすると、次のようなエラーが発生します

Erro: syntax error 'send'.
4

1 に答える 1

2

monit が root として実行されるため、UID と GID を指定する必要がある場合があります。

check process myserver 
  with pidfile "/home/path/to/myserver.pid"
  start program = "/etc/init.d/myserver start"
    as uid myserver_uid and gid myserver_gid
  stop program = "/etc/init.d/myserver stop"
    as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart

デバッグするには、ファイルに出力し、このファイルをチェックして詳細を確認します。

check process myserver 
  with pidfile "/home/path/to/myserver.pid"
  start program = "/etc/init.d/myserver start >> /tmp/myserver.log 2>&1"
    as uid myserver_uid and gid myserver_gid
  stop program = "/etc/init.d/myserver stop  >> /tmp/myserver.log 2>&1"
    as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart

送信と期待の場合、http プロトコルがサポートされているため、http クエリには必要ない場合があります。

于 2013-09-26T17:10:58.540 に答える