titanium
By:
titanium

Use "monit" when Cloudflare gives timeout connection or site down, to reset apache2 service.

November 10, 2016 62 views
Apache Monitoring

Hi guys,
last three days my website shows as offline, and its going through Cloudflare servers. I dont know what exactly causes that but when i restart apache2 everything is back to normal. I saw the monit utility that can auto restart service in unix, but the question is how can i use it to check automatically and reset apache2 service when that happens. Also i have always online checked in Cloudflare.
Thanks in advance

2 Answers

Did you saw How To Install and Configure Monit? It's older one, but I think it should be still working.
It covers case you need - to automatically restart service if down.

You maybe want to trace root of problem. Logs are your best friend, it could give many informations.
You can start with checking syslog for Out Of Memory entries. To do it, open syslog:

  • sudo nano /var/log/syslog

Try to find any Out of memory entry. If you find it, that means it got killed because it ran out of memory. In this case, you can consider upgrading your Droplet or adding Swap.
There is Apache error log too. By default it should be located at /var/log/apache2/error.log. You can open it with text editor as usual:

  • sudo nano /var/log/apache2/error.log

Maybe it'll give you insight of error if it isn't OOM.

by Etel Sverdlov
Monit is a helpful program that automatically monitors and manages server programs to ensure that they not only stay online consistently, but that the file size, checksum, or permissions are always correct. This tutorial covers monit installation and provides an example of how to configure it for some common programs.

Hi and thanks for the answer,
the apache error log give

<^>
[core:notice] [pid 16249] AH00051: child pid 8935 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:25:37.481054 2016] [core:notice] [pid 16249] AH00051: child pid 8936 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:25:37.481207 2016] [core:notice] [pid 16249] AH00051: child pid 8951 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:25:47.506398 2016] [core:notice] [pid 16249] AH00051: child pid 9027 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:25:51.512591 2016] [core:notice] [pid 16249] AH00051: child pid 9033 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:16.557959 2016] [core:notice] [pid 16249] AH00051: child pid 8867 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:24.570603 2016] [core:notice] [pid 16249] AH00051: child pid 8961 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:33.586873 2016] [core:notice] [pid 16249] AH00051: child pid 9040 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:34.590083 2016] [core:notice] [pid 16249] AH00051: child pid 8910 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:34.590399 2016] [core:notice] [pid 16249] AH00051: child pid 9026 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:35.592309 2016] [core:notice] [pid 16249] AH00051: child pid 8940 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:36.594550 2016] [core:notice] [pid 16249] AH00051: child pid 8984 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:42.604424 2016] [core:notice] [pid 16249] AH00051: child pid 9011 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Fri Nov 11 23:26:52.654911 2016] [core:notice] [pid 16249] AH00051: child pid 8933 exit signal Segmentation fault (11), possible coredump in /etc/apache2
<^>

i was reading about xdebug and core dump and my head is spinning with all the new informations, in this moment i need to find quick fix, because this is happening random and only once in a day, and the problem is i dont have alarm or something to "send mail notify" when this is happening. For now can i use (monit) to restart apache2 when Segmentation fault happens?

Thanks

Have another answer? Share your knowledge.