check_http_content query

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

check_http_content query

Postby s.diwakar1 » Thu Sep 30, 2021 11:25 am

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

Re: check_http_content query

Postby gormank » Thu Sep 30, 2021 1:54 pm

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
gormank
 
Posts: 913
Joined: Tue Dec 02, 2014 12:00 pm

Re: check_http_content query

Postby s.diwakar1 » Fri Oct 01, 2021 9:43 pm

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

Re: check_http_content query

Postby mcapra » Mon Oct 04, 2021 8:54 am

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/
User avatar
mcapra
 
Posts: 3729
Joined: Thu May 05, 2016 3:54 pm

Re: check_http_content query

Postby s.diwakar1 » Mon Oct 04, 2021 9:49 am

Thank you so much @mcapra! for detailed clarification. I got my answer. Thank you again!
Thanks & Regards,
Diwakar Sharma
s.diwakar1
 
Posts: 31
Joined: Thu Feb 27, 2020 9:45 am

Re: check_http_content query

Postby benjaminsmith » Wed Oct 13, 2021 4:47 pm

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!
User avatar
benjaminsmith
 
Posts: 5229
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul


Return to Community Support

Who is online

Users browsing this forum: phelaniclinic, tzimmermanFSU and 19 guests