Install Check_HTTP_Content
Install Check_HTTP_Content
How do I go about installing check_http_content plugin on core? I have the normal nagios plugins installed but I don't know how to install the extra ones I find that I want.
I've been searching the net for over an hour and haven't found any useful tips
I've been searching the net for over an hour and haven't found any useful tips
Re: Install Check_HTTP_Content
Running this on my vanilla Nagios Core 4 machine produces this error:It has no other dependencies than PERL itself and some libraries (Getopt::Std and LWP::UserAgent, latter with optional SSL support).
Code: Select all
[root@core4 tmp]# ./check_http_content
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi /root/perl5/lib/perl5/5.16.3 /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_http_content line 28.
BEGIN failed--compilation aborted at ./check_http_content line 28.
Code: Select all
yum install 'perl(LWP::UserAgent)'
Code: Select all
[root@core4 tmp]# ./check_http_content
ERROR: INVALID USAGE
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,
check_http_content will exit with UNKNOWN state (default 60)
https://www.monitoring-plugins.org/doc/ ... _http.html
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Install Check_HTTP_Content
This kilt it. @mcapra is right, why not just use the string or regex matching with check_http?mcapra wrote:Running this on my vanilla Nagios Core 4 machine produces this error:It has no other dependencies than PERL itself and some libraries (Getopt::Std and LWP::UserAgent, latter with optional SSL support).
So, it appears as though my machine is missing the LWP::UserAgent Perl module. I install it via yum (you could also install it via cpan):Code: Select all
[root@core4 tmp]# ./check_http_content Can't locate LWP/UserAgent.pm in @INC (@INC contains: /root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi /root/perl5/lib/perl5/5.16.3 /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_http_content line 28. BEGIN failed--compilation aborted at ./check_http_content line 28.
And everything appears to work just fine after that:Code: Select all
yum install 'perl(LWP::UserAgent)'
It's worth mentioning that the check_http plugin included in nagios-plugins can also check a page's content for specific strings:Code: Select all
[root@core4 tmp]# ./check_http_content ERROR: INVALID USAGE 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, check_http_content will exit with UNKNOWN state (default 60)
https://www.monitoring-plugins.org/doc/ ... _http.html
Code: Select all
-r, --regex, --ereg=STRING
Search page for regex STRING
Former Nagios Employee
Re: Install Check_HTTP_Content
As a general answer to the "How do I install this?" question, you will need to place the plugin in the same directory as the rest, make sure it is executable by the nagios user, and then create a command for it: https://assets.nagios.com/downloads/nag ... ml#command
Former Nagios employee
Re: Install Check_HTTP_Content
I'm running Nagios 4.1.1 on a Raspberry PI using Raspberian as the OS.
I'm pretty new to linux and don't quite understand the check_http string that you pointed out above.
What would the host command look like in the .cfg file?
I'm pretty new to linux and don't quite understand the check_http string that you pointed out above.
What would the host command look like in the .cfg file?
Re: Install Check_HTTP_Content
For example if I try this..
I get this error code
Code: Select all
define service{
use generic-service ; Name of service template to use
host_name snapgeek.com
service_description HTTP
check_command check_http -H snapgeek.com -u https://snapgeek.com/meet-matt/
notifications_enabled 1
}
Code: Select all
Checking objects...
Error: Service check command 'check_http -H snapgeek.com -u https://snapgeek.com/meet-matt/' specified in service 'HTTP' for host 'snapgeek.com' not defined anywhere!
Checked 51 services.
Checked 27 hosts.
Checked 2 host groups.
Checked 0 service groups.
Checked 2 contacts.
Checked 1 contact groups.
Checked 25 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 27 hosts
Checked 0 service dependencies
Checked 15 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 1
***> One or more problems was encountered while running the pre-flight check...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Install Check_HTTP_Content
You need to define the command separately.
For example:
So, your service looks like
This is not a particular good example, because it isn't reusable, but it should get you going until you get a chance to look over https://assets.nagios.com/downloads/nag ... tions.html
The above assumes you actually have a host named snapgeek.com. Each service must be attached to a host, but a host need not have a service (since there is a separate host check).
For example:
Code: Select all
define command {
command_name WhateverYouWantButNeedToUseThisWhenYouCallIt
command_line check_http -H snapgeek.com -u https://snapgeek.com/meet-matt/
}
Code: Select all
define service{
use generic-service ; Name of service template to use
host_name snapgeek.com
service_description HTTP
check_command WhateverYouWantButNeedToUseThisWhenYouCallIt
notifications_enabled 1
}
The above assumes you actually have a host named snapgeek.com. Each service must be attached to a host, but a host need not have a service (since there is a separate host check).
Re: Install Check_HTTP_Content
That works but lets say I want several websites to do the same check but with different urls. Do I have to define the command for each website differently in command.cfg or can i do it with arguments some other way?dwhitfield wrote:You need to define the command separately.
For example:So, your service looks likeCode: Select all
define command { command_name WhateverYouWantButNeedToUseThisWhenYouCallIt command_line check_http -H snapgeek.com -u https://snapgeek.com/meet-matt/ }
This is not a particular good example, because it isn't reusable, but it should get you going until you get a chance to look over https://assets.nagios.com/downloads/nag ... tions.htmlCode: Select all
define service{ use generic-service ; Name of service template to use host_name snapgeek.com service_description HTTP check_command WhateverYouWantButNeedToUseThisWhenYouCallIt notifications_enabled 1 }
The above assumes you actually have a host named snapgeek.com. Each service must be attached to a host, but a host need not have a service (since there is a separate host check).
FYI, I'm looking through that link you sent too to try to get a better understanding.
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Install Check_HTTP_Content
This is just a guess, but since you are running 4.3.1, you probably compiled from source. Is that correct? If that is correct, you should have the following file on your system: https://github.com/NagiosEnterprises/na ... nds.cfg.in
If you don't have that file, you could obviously look at the file on github to see various examples.
Below is a sample from that file. You'll see it really depends on the command how many ARGs it takes.
If you don't have that file, you could obviously look at the file on github to see various examples.
Below is a sample from that file. You'll see it really depends on the command how many ARGs it takes.
Code: Select all
# 'check_local_procs' command definition
define command{
command_name check_local_procs
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}
# 'check_local_users' command definition
define command{
command_name check_local_users
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}
# 'check_local_swap' command definition
define command{
command_name check_local_swap
command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$
}
# 'check_local_mrtgtraf' command definition
define command{
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
}
Re: Install Check_HTTP_Content
I'm running Nagios 4.1.1 which I haven't updated to 4.3 but I did compile it from source. I haven't bothered to try to update to 4.3 because I haven't had a huge desire to break what I currently worked so hard to get working which is more or less how i want it minus the ability to use keywords on website checks.
Last edited by t3dus on Mon May 08, 2017 2:02 pm, edited 1 time in total.