check_http string search problem

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rickwilson7425
Posts: 125
Joined: Tue Mar 18, 2014 3:20 pm

check_http string search problem

Post by rickwilson7425 »

I am trying to make sure that when I use either the -s or -R option with check_http I don't get a false positive return. My main concern is where I am looking for "0 CDM errors" on a page but there is the possibility that there might be "10 CDM errors", in which case it will still find the "0 CDM errors" string and return a false OK.

Can anyone tell me of a way to mitigate this situation?

Thanks
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: check_http string search problem

Post by tgriep »

Is there a space before the 0 CDM errors message? If so, try adding a space before the 0 in the testing string. See below

Code: Select all

" 0 CDM errors"
Be sure to check out our Knowledgebase for helpful articles and solutions!
rickwilson7425
Posts: 125
Joined: Tue Mar 18, 2014 3:20 pm

Re: check_http string search problem

Post by rickwilson7425 »

Unfortunately I don't think that will work. This is what the page looks like:

0 CDM errors detected

Cloud Data Management Publishing Service
Cloud Data Publishing Service version: 2.1.0.176
Cloud Data Publishing Service build date: 2015-01-20 10:57:22 -0700
Cloud Data Publishing Service built by: cdmbuild
Current Time: 2015-02-06T19:03:46Z
Bamboo Status: Passed
Bamboo Timing: 0.0817s
Perforce Status: Passed
Perforce Timing: 0.0076s
Publishing Progress Check: Passed
Publishing Progress Timing: 3.6559s
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_http string search problem

Post by abrist »

Well, is there any markup? check_http checks the entire returned html, so if there is markup, it would act like a "beginning of line" for that html element. You can see what check_http is applying the regex to with "-vvv":

Code: Select all

./check_http -H <hostname> -vvv
In my example below, "Nagios XI" is actually wrapped in a <title> tag, so the command looks like:

Code: Select all

./check_http -H localhost -r '<title>Nagios XI'
Edit:
Also, can you try using the following expression in your command?

Code: Select all

-r "[^1-9]0 CDM errors"
lmiltchev
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
rickwilson7425
Posts: 125
Joined: Tue Mar 18, 2014 3:20 pm

Re: check_http string search problem

Post by rickwilson7425 »

-R "[^1-9]0 CDM errors"

looks like it will work.

Thanks a lot.
Locked