check_http_content query

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
s.diwakar1
Posts: 44
Joined: Thu Feb 27, 2020 9:45 am

check_http_content query

Post 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!
Thanks & Regards,
Diwakar Sharma
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: check_http_content query

Post 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
s.diwakar1
Posts: 44
Joined: Thu Feb 27, 2020 9:45 am

Re: check_http_content query

Post 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.
Thanks & Regards,
Diwakar Sharma
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_http_content query

Post 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.
Former Nagios employee
https://www.mcapra.com/
s.diwakar1
Posts: 44
Joined: Thu Feb 27, 2020 9:45 am

Re: check_http_content query

Post by s.diwakar1 »

Thank you so much @mcapra! for detailed clarification. I got my answer. Thank you again!
Thanks & Regards,
Diwakar Sharma
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: check_http_content query

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked