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

Re: [hobbit] Hobbit regular expression problem in macros



Has anyone been able to confirm or reproduce this?

-Charles

Charles Jones wrote:
I am again being bitten by regex problems. I am able to reproduce it with the following entries in hobbit-alerts.cfg:

$IGNORE_HOSTS=%prod-web-(1|2|3|4|9|10|11)$
HOST=$IGNORE_HOSTS service=*
IGNORE

If I then check the "info" column of a host that is *not* supposed to be ignored, such as prod-web-12. It shows that it is indeed ignored. This is a serious problem as I have already missed alerts for some production hosts because of this problem.

According to pcretest (Henriks recommended method of testing a Hobbit regex), there is nothing wrong with the regular expression that I am using:
$ pcretest
PCRE version 6.6 06-Feb-2006
re> /prod-web-(1|2|3|4|9|10|11)$/
data> prod-web-12 (*correctly not matching*)
No match
data> prod-web-19 (*correctly not matching*)
No match
data> prod-web-10 (*correctly matching*)
0: prod-web-10
1: 10


From the above tests you can see that prod-web-12 does not match the regex when using pcretest, yet Hobbit is matching it for some reason. A possible work-around could be to not use a regex at all, such as $IGNORE_HOSTS=prod-web-1,prod-web-2,prod-web-3... but that is not really a solution if you have hundreds of hosts, and my main point is that regular expressions are not working as they are documented.

I've also tried other undocumented ways of using the regex, including:

No hosts matched at all
$IGNORE_HOSTS=%prod-web-(1|2|3|4|9|10|11)$
HOST="IGNORE_HOSTS"

No hosts matched at all
$IGNORE_HOSTS="%prod-web-(1|2|3|4|9|10|11)$"
HOST=$IGNORE_HOSTS

All hosts match (both web-12 and web-11)
$IGNORE_HOSTS=prod-web-(1|2|3|4|9|10|11)$
HOST=%$IGNORE_HOSTS

If anyone else can verify or reproduce this, it would be helpful in at least convincing Henrik to add it to the list of things to fix in the next version. I honestly hope that it's not a problem with Hobbit and instead something I am doing wrong - if so please enlighten me.

-Charles