Monit Reinicie o Apache2 e o status do Apache

0

Estou praticando usando o linux / Ubuntu.

Eu instalei o apache2 no meu servidor de nuvem (Lightsail). Eu também instalei o Monit para monitorar o Apache2. O monitoramento está funcionando corretamente e o Monit reinicia o Apache2 quando ele está inativo (fiz o sudo /etc/init.d/apache2 parar para testá-lo). O IP (no navegador) ficou indisponível e voltou a ficar online.

O problema que estou enfrentando é que, quando o Monit reinicia o apache, o sudo /etc/init.d/apache2 status mostra o serviço como inativo, mas o apache está em execução (IP verificado no navegador).

ubuntu@webserver:~$ sudo /etc/init.d/apache2 status
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: inactive (dead) since Thu 2017-04-27 22:21:17 UTC; 2min 51s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 22026 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 20709 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 21958 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
    Tasks: 0
   Memory: 0B
      CPU: 125ms


Apr 27 22:17:25 webserver systemd[1]: Starting LSB: Apache2 web server...
Apr 27 22:17:25 webserver apache2[21958]:  * Starting Apache httpd web server apache2
Apr 27 22:17:26 webserver apache2[21958]:  *
Apr 27 22:17:26 webserver systemd[1]: Started LSB: Apache2 web server.
Apr 27 22:21:17 webserver systemd[1]: Stopping LSB: Apache2 web server...
Apr 27 22:21:17 webserver apache2[22026]:  * Stopping Apache httpd web server apache2
Apr 27 22:21:17 webserver apache2[22026]:  *
Apr 27 22:21:17 webserver systemd[1]: Stopped LSB: Apache2 web server.

Isto é o que o sudo vim / etc / monit / monitrc tem:

check process apache2 with pidfile /run/apache2/apache2.pid
    start program = "/etc/init.d/apache2 restart" with timeout 15 seconds
    stop program  = "/etc/init.d/apache2 stop"

Como posso ter certeza de que o Apache2 foi reiniciado corretamente para que o sudo /etc/init.d/apache2 status mostre o status correto?

Editar 1: Meu / etc / monit / monitrc é assim:

  set daemon 60
  set logfile /var/log/monit.log
  set idfile /var/lib/monit/id
  set statefile /var/lib/monit/state
set mailserver localhost
  set eventqueue
      basedir /var/lib/monit/events
      slots 100

set alert [email protected]
set alert [email protected]

set httpd port 2812 and
    use address localhost
    allow localhost
    allow admin:monit

check process apache2 with pidfile /run/apache2/apache2.pid
    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
    stop program  = "/etc/init.d/apache2 stop"

check process mysqld with pidfile /var/run/mysqld/mysqld.pid
    start program = "/etc/init.d/mysql start" with timeout 60 seconds
    stop program = "/etc/init.d/mysql stop"
    
por Waqas Tariq 28.04.2017 / 12:34

1 resposta

0

Alterar o código de monitora para o seguinte corrigiu o problema:

check process apache2 with pidfile /run/apache2/apache2.pid
    start program = "/bin/systemctl start apache2.service" with timeout 15 seconds
    stop program  = "/bin/systemctl stop apache2.service"
    restart program = "/bin/systemctl restart apache2.service"
    
por Waqas Tariq 03.05.2017 / 16:44