Page 1 of 1

check_http_content query

Posted: Thu Sep 30, 2021 11:25 am
by s.diwakar1
Dear All,

I am using subjected script to monitor URLs with specific content/Expression.

Recently, One of the URL was being monitored properly with an Expression. But as of now, it is giving error "Expr not found".

Can anyone please confirm if this script searches the Expression within the source code or how this script works?

Thanks in advance!

Re: check_http_content query

Posted: Thu Sep 30, 2021 1:54 pm
by gormank
From the documentation on exchange:
"check_http_content is a web content monitor written in perl. Checks a URL for specific text.
It retrieves an URL through http or https and looks in its output for a given text. If the text is found returns OK, if not found returns CRITICAL plus the last line of text received (and the full text as additional output data), and UNKNOWN otherwise (connection error,...) plus a brief error description."

So it fetches a URL and looks for the expression in the returned text.

https://exchange.nagios.org/directory/P ... nt/details

Re: check_http_content query

Posted: Fri Oct 01, 2021 9:43 pm
by s.diwakar1
Hi @gormank,

Thanks for your detailed clarification.

But my query is still not resolved. I am monitoring some of my URLs to check specific text. Few days back, I was getting correct output. But now I am getting error, "Expr not found" with the complete source code of that URL as additional output data.

I want to know, Do this script check the text within the source code itself?

Sometimes what happened is, a URL has one or more links available or some variable within the source code from which it gets the data also. So, do this script check those links as well?

What I understood from the output is, it checks the specific text within the source code of that URL itself and if the specific text which I am trying to search is coming from another link or through a variable from the database, it is not searching there, because that specific text is not available in the source code of that URL.

Re: check_http_content query

Posted: Mon Oct 04, 2021 8:54 am
by mcapra
s.diwakar1 wrote:I want to know, Do this script check the text within the source code itself?
That is exactly how it works. By parsing the raw HTML returned by the HTTP request.
s.diwakar1 wrote:Sometimes what happened is, a URL has one or more links available or some variable within the source code from which it gets the data also. So, do this script check those links as well?
I suppose that would be a question of how LWP::UserAgent works, but I can't imagine it's doing things like fully rendering iframes or allowing Javascript to fully execute. curl doesn't do that.
s.diwakar1 wrote:the specific text which I am trying to search is coming from another link or through a variable from the database
You'd probably need a custom plugin, or something like Selenium or PhantomJS or some other full-fat browser driver, to get dynamic content that doesn't exist in the DOM until after the initial page load.

Re: check_http_content query

Posted: Mon Oct 04, 2021 9:49 am
by s.diwakar1
Thank you so much @mcapra! for detailed clarification. I got my answer. Thank you again!

Re: check_http_content query

Posted: Wed Oct 13, 2021 4:47 pm
by benjaminsmith
Thank you so much @mcapra! for detailed clarification. I got my answer. Thank you again!
Excellent! And thanks, Matt.

We'll go ahead and close this.

Thank you for using the Nagios Community Forum