Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_http_content

Rating
9 votes
Favoured:
0
Hits
157722
Files:
FileDescription
check_http_contentcheck_http_content
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
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.

It has no other dependencies than PERL itself and some libraries (Getopt::Std and LWP::UserAgent, latter with optional SSL support).
Reviews (7)
bygomatze, November 10, 2016
I changed the
as well.
Works! Thumbs up!
I added stripping the HTML:

in the use section:

use HTML::FormatText;

my @output_lines = split(/
/, $content);
# print "CONTENT ERROR: EXPR NOT FOUND (last: $output_lines[$#output_lines])
full output was:
$content";
my $text = HTML::FormatText->format_from_string($content);
print "CONTENT ERROR: EXPR NOT FOUND:
";
print "$text
";
$status = EXIT_CRITICAL;

With this change I found it more useful output for my client.
byadarsh, May 30, 2015
@Cloudmaster,

You missed the quotes. Your check_command supposed to be

check_command check_http_content -U http://64.20.36.132:82/xml -m "25388C85-A193-47DC-A7-1C-95-EB-92-EC-E9-28" -t 5

Thanks,
Addy
bygdr, June 14, 2013
@Cloudmaster you probably already figured it out but just in case, in service definition it should be as following:

check_command check_http_content!http://64.20.36.132:82/xml!25388C85-A193-47DC-A7-1C-95-EB-92-EC-E9-28!5
byCyber-Wizard, November 13, 2012
Has anyone any suggestions on making this a case-insensitive check?
Need a bit of handholding -

This is what I have in my commands.cfg -

define command{
command_name check_http_content
command_line $USER1$/check_http_content -U $ARG1$ -m $ARG2$ -t $ARG3$
}

This is what's in my host.cfg -

define service{
use generic-service
host_name Air SeaTac
service_description FSHost 2002
servicegroups front_end_services
check_command check_http_content -U http://64.20.36.132:82/xml -m 25388C85-A193-47DC-A7-1C-95-EB-92-EC-E9-28 -t 5
notifications_enabled 1
}

This is what happens when I run check_http_content manually -

[root@prometheus libexec]# ./check_http_content -U http://64.20.36.132:82/xml -m 25388C85-A193-47DC-A7-1C-95-EB-92-EC-E9-28 -t 5
CONTENT OK: EXPR FOUND[root@prometheus libexec]#

Trying to restart Nagios after config changes results in error
bypydubreucq, September 22, 2011
Hi,
This script works fine ;)
I've just modified a little on line 67 and add "\n"
The original line :
print "CONTENT OK: EXPR FOUND";
The modified libne :
print "CONTENT OK: EXPR FOUND\n";
With that, when I'm testing in bash it's better display.
Thanks a lot
bye