monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [monit] regex in http tests


From: Jan-Henrik Haukeland
Subject: Re: [monit] regex in http tests
Date: Mon, 17 May 2010 21:17:49 +0200

On May 17, 2010, at 10:58 AM, Edmunds wrote:

> if failed url http://local/test.php
>     and content != '^OK$'
>     then alert
> 
> never triggers an alert. I tried with content "OK", "ERR is not OK"
> and just "ERR" - monit always displays "online with all services".
> Anyway I believe it works the other way around:
> 
> and countent == "something"
> 
> if this test fails an alert is triggered

Yes, you are right. I just tested this and it works fine. However, what is 
happening here is probably that your editor adds a new line so what the server 
really sends is "OK\n" which causes the test to not trigger as the regex does 
not match just "OK". If you remove the new line char '\n' it works fine. It 
seems that something is fishy with $ in a POSIX regex, at least on my machine. 
In my book ^OK$ should match "OK\n" but apparently it does not. An alternative 
to write "OK" with no text behind and that works is to use '^OK[:space:]*'. 
Otherwise, just make sure that the new-line char is not included in the 
response from the server.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]