Hi, Ok i am trying use a check file .
Thanks 2012/11/8 Martin Pala <[email protected]> > You can print (mirror) in the status script's output whatever you want > (even the response code) - the output will be attached to the event. The > exit status however need to match the test - your script returned 0, but > the test was checking for 502 => it didn't match > > > On Nov 8, 2012, at 7:22 PM, "Houssan A. Hijazi" <[email protected]> > wrote: > > Hi, > > thanks, Martin.. but i need get the output from bash script. > > Thanks > > 2012/11/8 Martin Pala <[email protected]> > >> Your script prints the http response code to standard output - but monit >> checks only the exist status, not the output. >> >> You need to modify the script to return the http code like this: >> >> --8<-- >> #!/bin/bash >> exit `curl -sL -w "%{http_code}\\n" "http://www.mysite.com" -o /dev/null` >> --8<-- >> >> >> On Nov 8, 2012, at 12:57 PM, "Houssan A. Hijazi" <[email protected]> >> wrote: >> >> Hi, >> >> >> my monit configuration: >> >> check program webserverresponse with path >> /home/myhome/webserver_response.sh >> if status == 502 then exec "/etc/init.d/nginx restart" >> if status == 502 then alert >> depends on nginx >> >> webserver_response.sh content: >> >> #!/bin/bash >> curl -sL -w "%{http_code}\\n" "http://www.mysite.com" -o /dev/null >> exit $? >> >> output: >> user@ps90700:~$ ./webserver_response.sh >> 502 >> -- >> user@ps90700:~$ ./webserver_response.sh echo $? >> 502 >> >> and in log file: >> >> [PST Nov 8 03:53:29] debug : 'webserverresponse' status check >> succeeded >> >> thanks, Martin >> >> >> >> >> >> >> 2012/11/8 Martin Pala <[email protected]> >> >>> It seems that the test script doesn't return the 502 then. >>> >>> Can you provide output of this?: >>> --8<-- >>> /home/myhome/webserver_response.sh >>> echo $? >>> --8<-- >>> >>> >>> >>> On Nov 6, 2012, at 12:55 PM, Houssan A. Hijazi <[email protected]> >>> wrote: >>> >>> Hi, >>> >>> in a logs i have always: >>> >>> [PST Nov 6 03:53:13] debug : 'nginx' zombie check succeeded >>> [status_flag=0000] >>> [PST Nov 6 03:53:13] debug : 'nginx' succeeded connecting to INET[ >>> www.mysite.org:80 <http://www.mysite.org/>] via TCP >>> [PST Nov 6 03:53:13] debug : 'nginx' succeeded testing protocol >>> [HTTP] at INET[www.mysite.org:80 <http://www.mysite.org/>] via TCP >>> [PST Nov 6 03:53:13] debug : 'webserverresponse' status check >>> succeeded >>> >>> is always succeded the status of webserverresponse. My configuration are >>> ok? >>> >>> >>> Thanks >>> 2012/11/6 Martin Pala <[email protected]> >>> >>>> Hi, >>>> >>>> can you run monit in debug mode ("-v" option) and check the logs? >>>> >>>> Regards, >>>> Martin >>>> >>>> >>>> On Nov 5, 2012, at 6:09 PM, Houssan A. Hijazi <[email protected]> >>>> wrote: >>>> >>>> Hi, >>>> >>>> my config file: >>>> >>>> check process nginx >>>> with pidfile /dh/nginx/servers/httpd-ps93737/var/logs/nginx.pid #Pid >>>> file for nginx in my case it located in /opt/nginx/logs/ >>>> start program = "/etc/init.d/nginx start" >>>> stop program = "/etc/init.d/nginx stop" >>>> if failed host www.mysite.com port 80 protocol HTTP then restart >>>> #set your server IP that runs nginx >>>> if 5 restarts with 5 cycles then alert >>>> check program webserverresponse with path >>>> /home/myhome/webserver_response.sh >>>> # if status == 502 then restart >>>> if status == 502 then exec "/usr/local/bin/monit restart nginx" >>>> depends on nginx >>>> >>>> My /home/myhome/webserver_response.sh return 502, but not work, not >>>> restart nginx. >>>> >>>> I did something wrong? >>>> >>>> thanks >>>> >>>> 2012/11/2 Martin Pala <[email protected]> >>>> >>>>> You can keep the "depends on nginx" as well (if the parent nginx >>>>> service will be restarted, it will suppress the child service test during >>>>> the restart). >>>>> >>>>> >>>>> On Nov 2, 2012, at 10:16 PM, "Houssan A. Hijazi" < >>>>> [email protected]> wrote: >>>>> >>>>> Hi, >>>>> >>>>> thanks for your hint. >>>>> >>>>> i don't need put: depends on nginx ? >>>>> >>>>> Thanks >>>>> >>>>> >>>>> >>>>> 2012/11/2 Martin Pala <[email protected]> >>>>> >>>>>> I'm sorry i provided wrong hint - the child service restart action >>>>>> doesn't trigger the parent's service restart (the action cascades from >>>>>> parents to children but bot vice versa). >>>>>> >>>>>> The correct way to restart the nginx and prevent th race condition >>>>>> between the two checks is: >>>>>> >>>>>> check program webserverresponse with path >>>>>> /home/myhome/webserver_response.sh >>>>>> if status == 502 then exec "/usr/bin/monit restart nginx" >>>>>> >>>>>> Regards, >>>>>> Martin >>>>>> >>>>>> >>>>>> >>>>>> On Nov 1, 2012, at 6:19 PM, "Houssan A. Hijazi" < >>>>>> [email protected]> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> this rule is not work: >>>>>> >>>>>> check program webserverresponse with path >>>>>> /home/myhome/webserver_response.sh >>>>>> if status == 502 then restart >>>>>> depends on nginx >>>>>> >>>>>> if i run /home/myhome/webserver_response.sh in terminal it print 502 >>>>>> but the monit not restart. >>>>>> >>>>>> Can you help me? >>>>>> >>>>>> thanks >>>>>> >>>>>> 2012/11/1 Houssan A. Hijazi <[email protected]> >>>>>> >>>>>>> Thanks, Martin >>>>>>> >>>>>>> >>>>>>> 2012/11/1 Martin Pala <[email protected]> >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> the "check program" was added in Monit 5.3 ... you need to upgrade >>>>>>>> monit. >>>>>>>> >>>>>>>> Regards, >>>>>>>> Martin >>>>>>>> >>>>>>>> >>>>>>>> On Nov 1, 2012, at 2:59 PM, "Houssan A. Hijazi" < >>>>>>>> [email protected]> wrote: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> i created the file like this: >>>>>>>> >>>>>>>> #!/bin/bash >>>>>>>> curl -o /dev/null --silent --head --write-out '%{http_code}\n' >>>>>>>> http://www.mysite.org >>>>>>>> >>>>>>>> it return the http response code. >>>>>>>> >>>>>>>> in monit configuration i do: >>>>>>>> >>>>>>>> check process nginx >>>>>>>> with pidfile /dh/nginx/servers/httpd-myserver/var/logs/nginx.pid >>>>>>>> start program = "/etc/init.d/nginx start" >>>>>>>> stop program = "/etc/init.d/nginx stop" >>>>>>>> if failed host www.mysite.org port 80 protocol HTTP then >>>>>>>> restart #set your server IP that runs nginx >>>>>>>> if 5 restarts with 5 cycles then alert >>>>>>>> check program webserverresponse with path >>>>>>>> /home/myhome/webserver_response.sh >>>>>>>> if content == "502" then restart >>>>>>>> depends on nginx >>>>>>>> >>>>>>>> When i try start monit: >>>>>>>> >>>>>>>> $ sudo /etc/init.d/monit start >>>>>>>> Starting daemon monitor: Syntax error: >>>>>>>> /etc/monit/conf.d/nginx.conf:7: Error: syntax error >>>>>>>> 'webserverresponse' >>>>>>>> >>>>>>>> Monit version: 1:5.1.1-1 >>>>>>>> >>>>>>>> thanks >>>>>>>> >>>>>>>> >>>>>>>> 2012/10/31 Martin Pala <[email protected]> >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> the default HTTP protocol test returns just failure if the HTTP >>>>>>>>> code is error. >>>>>>>>> >>>>>>>>> You can use the "check program" test with custom script and use >>>>>>>>> curl/wget to get the http response code, for example (not tested): >>>>>>>>> /usr/local/bin/myhttptest.sh: >>>>>>>>> --8<-- >>>>>>>>> #!/bin/bash >>>>>>>>> exit `curl -sL -w "%{http_code}\\n" "http://mymachine" -o >>>>>>>>> /dev/null` >>>>>>>>> --8<-- >>>>>>>>> >>>>>>>>> and then connect it to Monit like this: >>>>>>>>> --8<-- >>>>>>>>> check process apache with pidfile /var/run/apache.pid >>>>>>>>> start program = ... >>>>>>>>> stop program = ... >>>>>>>>> >>>>>>>>> check program myhttptest with path /usr/local/bin/myhttptest.sh >>>>>>>>> if status == 502 then restart >>>>>>>>> depends on apache >>>>>>>>> --8<-- >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Another option is to use the generic send/expect test to write >>>>>>>>> simple HTTP check and test the 502 response - generic example from the >>>>>>>>> monit manual: >>>>>>>>> --8<-- >>>>>>>>> if failed host cave.persia.ir port 4040 >>>>>>>>> send "Open, Sesame!\r\n" >>>>>>>>> expect "Please enter the cave\r\n" >>>>>>>>> send "Shut, Sesame!\r\n" >>>>>>>>> expect "See you later [A-Za-z ]+\r\n" >>>>>>>>> then restart >>>>>>>>> --8<-- >>>>>>>>> >>>>>>>>> >>>>>>>>> Regards, >>>>>>>>> Martin >>>>>>>>> >>>>>>>>> >>>>>>>>> On Oct 30, 2012, at 1:57 PM, Houssan A. Hijazi < >>>>>>>>> [email protected]> wrote: >>>>>>>>> >>>>>>>>> > Hi, >>>>>>>>> > >>>>>>>>> > i am on dreamhost using nginx with fastcgi, i need use monit to >>>>>>>>> monitoring the nginx error, if error is 502 so restart. >>>>>>>>> > >>>>>>>>> > in my monit.log i have: >>>>>>>>> > >>>>>>>>> > HTTP error: Server returned status 502 >>>>>>>>> > >>>>>>>>> > How i can see if host returned 502 error ? >>>>>>>>> > >>>>>>>>> > Thanks >>>>>>>>> > >>>>>>>>> > -- >>>>>>>>> > To unsubscribe: >>>>>>>>> > https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> To unsubscribe: >>>>>>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> -- >>>>>>>> *Houssan A. Hijazi * >>>>>>>> Analista de Sistemas >>>>>>>> www.lojasnoparaguai.com.br / www.libanovivo.org >>>>>>>> -- >>>>>>>> To unsubscribe: >>>>>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> To unsubscribe: >>>>>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> -- >>>>>>> *Houssan A. Hijazi * >>>>>>> Analista de Sistemas >>>>>>> www.lojasnoparaguai.com.br / www.libanovivo.org >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> -- >>>>>> *Houssan A. Hijazi * >>>>>> Analista de Sistemas >>>>>> www.lojasnoparaguai.com.br / www.libanovivo.org >>>>>> -- >>>>>> To unsubscribe: >>>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> To unsubscribe: >>>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> -- >>>>> *Houssan A. Hijazi * >>>>> Analista de Sistemas >>>>> www.lojasnoparaguai.com.br / www.libanovivo.org >>>>> -- >>>>> To unsubscribe: >>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>> >>>>> >>>>> >>>>> -- >>>>> To unsubscribe: >>>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>>> >>>> >>>> >>>> >>>> -- >>>> -- >>>> *Houssan A. Hijazi * >>>> Analista de Sistemas >>>> www.lojasnoparaguai.com.br / www.libanovivo.org >>>> -- >>>> To unsubscribe: >>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>> >>>> >>>> >>>> -- >>>> To unsubscribe: >>>> https://lists.nongnu.org/mailman/listinfo/monit-general >>>> >>> >>> >>> >>> -- >>> -- >>> *Houssan A. Hijazi * >>> Analista de Sistemas >>> www.lojasnoparaguai.com.br / www.libanovivo.org >>> -- >>> To unsubscribe: >>> https://lists.nongnu.org/mailman/listinfo/monit-general >>> >>> >>> >>> -- >>> To unsubscribe: >>> https://lists.nongnu.org/mailman/listinfo/monit-general >>> >> >> >> >> -- >> -- >> *Houssan A. Hijazi * >> Analista de Sistemas >> www.lojasnoparaguai.com.br / www.libanovivo.org >> -- >> To unsubscribe: >> https://lists.nongnu.org/mailman/listinfo/monit-general >> >> >> >> -- >> To unsubscribe: >> https://lists.nongnu.org/mailman/listinfo/monit-general >> > > > > -- > -- > *Houssan A. Hijazi * > Analista de Sistemas > www.lojasnoparaguai.com.br / www.libanovivo.org > -- > To unsubscribe: > https://lists.nongnu.org/mailman/listinfo/monit-general > > > > -- > To unsubscribe: > https://lists.nongnu.org/mailman/listinfo/monit-general > -- -- *Houssan A. Hijazi * Analista de Sistemas www.lojasnoparaguai.com.br / www.libanovivo.org
-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general
