Hi,

as mentioned, i suggest to check the environment variables.

You can catch the script output by modifying the monit configuration for apache 
this way:

  start program = "/bin/bash -c '/etc/init.d/httpd start > /tmp/apache.out 
2>&1'"

... this will save the output and errors to /tmp/apache.out - it should provide 
more informations about why apache couldn't start via monit in given machine's 
environment.

Martin



On Jun 29, 2010, at 2:57 PM, Tong Anh Quan wrote:

> Hi Martin,
> 
> The problem is, the next time when Apache reach the threshold, monit cannot 
> restart it, the monit.log says continously:
> 
> [ICT Jun 29 18:03:57] error    : 'apache' process is not running
> [ICT Jun 29 18:03:57] info     : 'apache' trying to restart
> [ICT Jun 29 18:03:57] info     : 'apache' start: /etc/init.d/httpd
> [ICT Jun 29 18:04:27] error    : 'apache' failed to start
> 
> and I... must manually restart Apache.
> 
> Do you have any suggestion?
> 
> On Thu, Jun 24, 2010 at 10:34 PM, Martin Pala <[email protected]> wrote:
> If apache is running and pidfile missing, then the problem is in apache or 
> its start script - not monit.
> 
> I have never get this situation when restart Apache from command line 
> (service httpd restart).
> 
>  
> 
> As mentioned, for example ubuntu sets pidfile in apache.conf this way:
> --8<--
> PidFile ${APACHE_PID_FILE}
> --8<--
> 
> The APACHE_PID_FILE environment variable is defined in /etc/apache2/envvars 
> this way:
> --8<--
> export APACHE_PID_FILE=/var/run/apache2.pid
> --8<--
> 
> ... and the variable sourced from envvars file in /etc/init.d/apache2 this 
> way:
> PIDFILE=`. /etc/apache2/envvars ; echo $APACHE_PID_FILE`
> 
> 
> You mentioned CentOS - it will have probably different apache configuration 
> hierarchy, but you have the idea where to look. The problem could be 
> environment variable (as mentioned monit purges environment variables so 
> unless you use envvars-like file you may have problem) or apache 
> configuration issue.
> 
> 
> 
> On Jun 24, 2010, at 5:10 PM, Tong Anh Quan wrote:
> 
>> On Thu, Jun 24, 2010 at 9:48 PM, Martin Pala <[email protected]> wrote:
>> The pidof shows pid of all matching processes - in case of apache there is 
>> one master httpd process (parent) which spawns number of child processes to 
>> handle particular requests - if apache is stopping it may take a while 
>> before they handle all pending requests and stop.
>> 
>> I know, obviously.
>> 
>>  
>> Since the pidfile doesn't exist i suppose apache is not running on your 
>> machine and only some child processes remain active (stopping) ... their 
>> parent pid will be most probably "1" (their original parent exited). You can 
>> verify apache's status for example using 'apachectl status' and also by 
>> trying to connect to the http service which should fail.
>> 
>> What a pity, you're wrong. I checked it before posting:
>> 
>> # ps -ef | grep httpd
>> root     21422     1  0 12:49 ?        00:00:00 /usr/sbin/httpd
>> apache   21424 21422  0 12:49 ?        00:01:29 /usr/sbin/httpd
>> apache   21425 21422  0 12:49 ?        00:02:01 /usr/sbin/httpd
>> apache   21426 21422  0 12:49 ?        00:01:46 /usr/sbin/httpd
>> apache   21427 21422  0 12:49 ?        00:03:33 /usr/sbin/httpd
>> apache   21428 21422  0 12:49 ?        00:02:01 /usr/sbin/httpd
>> apache   21429 21422  0 12:49 ?        00:01:49 /usr/sbin/httpd
>> apache   21431 21422  0 12:49 ?        00:02:45 /usr/sbin/httpd
>> apache   21432 21422  0 12:49 ?        00:00:58 /usr/sbin/httpd
>> apache   21443 21422  0 12:50 ?        00:02:22 /usr/sbin/httpd
>> apache   21444 21422  0 12:50 ?        00:01:32 /usr/sbin/httpd
>> apache   21445 21422  0 12:50 ?        00:01:35 /usr/sbin/httpd
>> 
>> and I can connect to my web page normally.
>> 
>> If despite missing pidfile apache is running and serving requests, then you 
>> have some problem with apache's startup script.
>> 
>> Until now, I have no problem.
>>  
>> 
>> Note that monit runs the script in "sandbox" and purges environment 
>> variables when starting the script (for security reasons). If you apache's 
>> startup depends on some variable, you will need to modify the start script 
>> to include it (apache usually uses "envvars" file which is should contain 
>> variables required for apache).
>> 
>> I use the Apache's default config file and it works fine when restart from 
>> command line.
> 
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe:
> http://lists.nongnu.org/mailman/listinfo/monit-general
> 
> 
> 
> -- 
> --- Hạnh phúc là một ly Cafe và nhạc Trịnh ---
> --
> To unsubscribe:
> http://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to