[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check that text does not exist on a page on a name-based virtual hos
From: |
Mark Feeney |
Subject: |
Re: Check that text does not exist on a page on a name-based virtual host |
Date: |
Tue, 5 Oct 2010 11:09:26 -0400 |
Thanks for the info, Martin.
Just to finish up this thread, here's what I ended up doing:
My ancient version of monit (4.10, November 2007) is apparently
lacking any name-based virtual host support: 'man monit' talks only
about IP-based, and hostheader is not mentioned at all (and fails to
parse). So instead, I hacked things:
For my site foo.com, I added an entry in /etc/hosts:
127.0.0.1 foo.com.localhost
And added this rule to monit:
check host production-box with address 127.0.0.1
if failed host foo.com.localhost port 81 proto http
request "/bar"
then alert
This seems to send 'foo.com.localhost' as the http Host header, and my
server can thread 'foo.com.localhost' the same as 'foo.com', so it
works. It seems to fire if I get a non-200 error from the server, so
that'll do fine for now.
Thanks for the help. I really need to get an updated monit!
On Mon, Oct 4, 2010 at 9:05 AM, Martin Pala <address@hidden> wrote:
> The send/expect supports posix regular expression, so it should be possible
> to define negative match.
>
>
> On Oct 4, 2010, at 2:30 PM, Mark Feeney wrote:
>
>> Hi, Martin.
>>
>> Thank you for your reply. I can probably find a way to make the
>> second example work, but what would be ideal for my particular case
>> would be a "negative expect". i.e. something like this:
>>
>> if failed host cave.persia.ir port 4040
>> send "Open, Sesame!\r\n"
>> expect anything but "sorry, the cave door is broken!"
>> then restart
>>
>> I didn't see anything in the docs supporting this idea with
>> send/expect. Wondering if I missed something.
>>
>> Related question: does the regex library monit uses support
>> negative-lookahead matching?
>>
>> Thanks,
>>
>>
>> Mark.
>>
>>
>>
>> On Mon, Oct 4, 2010 at 6:51 AM, Martin Pala <address@hidden> wrote:
>>> Hi,
>>>
>>> you can use the "hostheader" option with the http protocol test (requires
>>> monit 5.1.1 or newer) - unfortunately this syntax doesn't support the
>>> "content" check.
>>>
>>> Example:
>>> --8<--
>>> check host production with address 127.0.0.1
>>> if failed port 9999 protocol http request "/some_page" hostheader
>>> "foo.com" then alert
>>> --8<--
>>>
>>> We should consolidate the url test to support hostheader + the http
>>> protocol test to support content check.
>>>
>>>
>>> As a workaround, you can define the whole HTTP request and expected
>>> response using generic send/expect test. Example:
>>> --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 2, 2010, at 10:28 PM, Mark Feeney wrote:
>>>
>>>> Greetings.
>>>>
>>>> First: I love monit. Excellent tool. Very simple and effective.
>>>> Thanks to all involved.
>>>>
>>>> I have come up with something I can't figure out how to monitor,
>>>> though: I want to check that a web page does not contain certain text
>>>> and the page is on a name-based virtual host.
>>>>
>>>> This almost works for me:
>>>>
>>>> check host production with address 127.0.0.1
>>>> if failed url
>>>> http://foo.com/some_page
>>>> and content != 'BAD'
>>>> then restart
>>>>
>>>> However, it's incorrect for me to use "http://foo.com" since it's a
>>>> cluster, so restarting the current server isn't necessarily going to
>>>> help.
>>>>
>>>> What I want is something like:
>>>>
>>>> check host production with address 127.0.0.1
>>>> if failed url
>>>> http://127.0.0.1:9999/some_page
>>>> use host header "foo.com" # not real syntax
>>>> and content != 'BAD'
>>>> then restart
>>>>
>>>> Is there a way to achieve this? proto http and SEND/EXPECT seemed a
>>>> possibility, but I'm not sure how to write the EXPECT part.
>>>>
>>>> I'm using monit 4.10.1.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> Mark.
>>>>
>>>> --
>>>> To unsubscribe:
>>>> http://lists.nongnu.org/mailman/listinfo/monit-general
>>>
>>>
>>> --
>>> To unsubscribe:
>>> http://lists.nongnu.org/mailman/listinfo/monit-general
>>>
>>
>> --
>> To unsubscribe:
>> http://lists.nongnu.org/mailman/listinfo/monit-general
>
>
> --
> To unsubscribe:
> http://lists.nongnu.org/mailman/listinfo/monit-general
>