����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 3.14.248.120 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /usr/lib64/nagios/plugins/base/ |
Upload File : |
#!/usr/bin/perl #------------------------------------------------------------------------------ # check_http_content # retrieve an http/s url and checks its content for a given expression # if the expression is found exits with OK, otherwise exits with CRITICAL # # Copyright 2007, CAPSiDE SL http://www.capside.com # Licensed under GPLv2 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Opsview; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # ----------------------------------------------------------------------------- use strict; use Getopt::Std; use LWP::UserAgent; my $plugin_name = 'check_http_content'; my $VERSION = '0.01'; # getopt module config $Getopt::Std::STANDARD_HELP_VERSION = 1; # nagios exit codes use constant EXIT_OK => 0; use constant EXIT_WARNING => 1; use constant EXIT_CRITICAL => 2; use constant EXIT_UNKNOWN => 3; # parse cmd opts my %opts; getopts('vU:t:m:j', \%opts); $opts{t} = 60 unless (defined $opts{t}); if (not (defined $opts{U} and defined $opts{m})) { print "ERROR: INVALID USAGE\n"; HELP_MESSAGE(); exit EXIT_CRITICAL; } my ($response,$content); my $status = EXIT_OK; if ($opts{j}) { require Selenium::Firefox; my $driver = Selenium::Firefox->new( marionette_enabled => 1, binary => '/usr/local/sbin/geckodriver', extra_capabilities => { "moz:firefoxOptions" => { args => ['-headless'] } } ); $driver->get($opts{U}); $content = $driver->get_body(); $driver->shutdown_binary; } else { my $ua = LWP::UserAgent->new; $ua->timeout($opts{t}); $response = $ua->get($opts{U}); if (not $response->is_success) { print "ERROR: CANNOT RETRIEVE URL: ", $response->status_line, "\n"; $status = EXIT_UNKNOWN; } else { $content = $response->content; } } # retrieve url if ($content =~ m/$opts{m}/gsm) { print "CONTENT OK: EXPR FOUND"; $status = EXIT_OK; } else { my @output_lines = split(/\n/, $content); print "CONTENT ERROR: EXPR NOT FOUND (last: $output_lines[$#output_lines])\nfull output was:\n$content"; $status = EXIT_CRITICAL; } exit $status; sub HELP_MESSAGE { print <<EOHELP Retrieve an http/s URL and looks in its output for a given text. Returns CRITICAL is not found, OK if found, UNKNOWN otherwise. --help shows this message --version shows version information -U URL to retrieve (http or https) -m <text> Text to match in the output of the URL -t Timeout in seconds to wait for the URL to load. If the page fails to load, $plugin_name will exit with UNKNOWN state (default 60) -j Tests HTTP website using any mainstream JavaScript-enabled browser EOHELP ; } sub VERSION_MESSAGE { print <<EOVM $plugin_name v. $VERSION Copyright 2007, CAPSiDE SL - http://www.capside.com - Licensed under GPLv2 EOVM ; }