Hi - Relatively new to NagiosXI and strugling with one url check. Details are:
NagiosXI 5.6.13
(nagios-plugins 2.2.1)
Using the Website URL check to monitor a url and match content this works fine on all the urls that only have one redirect. Redirect is set to follow and content match to look for text found on a terms and conditions page. If I run the check, it fails and the page appears to look for the text in is is actually the 1st redirect of 2 to the actual site (No idea why it was set this way it's somebody elses creation).
So without posting the url in here for privacy reasons is there any way to force the check_xiservice_http to hang in there until it gets to the page it needs to read the content from?
the check in $ARG1$ looks like the below if that helps
-s "This website does" -f follow -I x.x.x.x -u "/hxxxx/xxx-xxx-game" -S --sni -p 443
the error I get looks like the below (makes no difference if I use port 80 on the end or 443)
HTTP CRITICAL: HTTP/1.1 200 OK - string 'This website does' not found on 'http://www.xxxxx.com:80/hxxxx/404Redire ... x.com/xxxx' - 11847 bytes in 0.360 second res
Is a Url content check with more than one redirect possible?
Re: Is a Url content check with more than one redirect possi
I'm able to replicate that behavior, I don't see a solution with check_http, it's likely a bug as the code looks like it's supposed to support up to 15 redirects by default.
I've filed a bug report here:
Feel free to add any additional info.
You would likely need to find another plugin to check it, something like this should work:
https://exchange.nagios.org/directory/P ... tp/details
I've filed a bug report here:
Code: Select all
https://github.com/nagios-plugins/nagios-plugins/issues/540You would likely need to find another plugin to check it, something like this should work:
https://exchange.nagios.org/directory/P ... tp/details
Re: Is a Url content check with more than one redirect possi
We tried a few of the curl plugins but we did not have much luck so what we did was to create a custom check ourselves and stored it in the path /usr/local/nagios/libexec
I presume it is ok to post the details of the script here as it may help others in the future?
I presume it is ok to post the details of the script here as it may help others in the future?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Is a Url content check with more than one redirect possi
Sure please do, this may help others in the future until the bug is resolvedtechgeek wrote:We tried a few of the curl plugins but we did not have much luck so what we did was to create a custom check ourselves and stored it in the path /usr/local/nagios/libexec
I presume it is ok to post the details of the script here as it may help others in the future?
Thanks!
Re: Is a Url content check with more than one redirect possi
To make your own command to use curl (you may need to have curl installed on your server ) to follow redirects and then look for specific text at the destination site to confirm it is up:
Step 1
Create a command in Core Config Manager?Commands using the following
Command Name
check_mycustom_curl
Command Line
$USER1$/check_mycustom_curl $ARG1$
command type
Check command
Active
Check the box
Save
Step 2
Login to Nagios XI server via ssh (change to root) and create the following script using the command
vi /usr/local/nagios/libexec/check_mycustom_curl
Save the file and exit
Add the same permissions as all the other checks in same path
chmod 775 /usr/local/nagios/libexec/check_mycustom_curl
chown apache:nagios /usr/local/nagios/libexec/check_mycustom_curl
Step 3
Then use the Configuration wizard to create a website monior - fill in the boxes you want as normal and save at the end.
Step 4
Go back to Core Config Manager and then click services and find the url check you just created and edit it.
Change the "Check Command" to select the new "check_mycustom_curl" command you made earlier.
In the $ARG1$ box paste in the website you want to monitor plus a space and then the text you expect to find when the site is up in ""
e.g.
http://www.mysite.com "text to match"
Save and test as needed.
Step 1
Create a command in Core Config Manager?Commands using the following
Command Name
check_mycustom_curl
Command Line
$USER1$/check_mycustom_curl $ARG1$
command type
Check command
Active
Check the box
Save
Step 2
Login to Nagios XI server via ssh (change to root) and create the following script using the command
vi /usr/local/nagios/libexec/check_mycustom_curl
Code: Select all
#!/bin/bash
URL=$1
SEARCH=$2
RESULT=$(curl -L $URL | grep -i "$SEARCH" | wc -l)
RESULT1=$(curl -L $URL | grep -i '$SEARCH')
if [ "$RESULT" -ge 1 ]; then
echo Site is UP $URL
exit 0
else
if [ "$RESULT" -lt 1 ] ; then
echo Site is Down $URL
echo $RESULT1
exit 2
fi
fiSave the file and exit
Add the same permissions as all the other checks in same path
chmod 775 /usr/local/nagios/libexec/check_mycustom_curl
chown apache:nagios /usr/local/nagios/libexec/check_mycustom_curl
Step 3
Then use the Configuration wizard to create a website monior - fill in the boxes you want as normal and save at the end.
Step 4
Go back to Core Config Manager and then click services and find the url check you just created and edit it.
Change the "Check Command" to select the new "check_mycustom_curl" command you made earlier.
In the $ARG1$ box paste in the website you want to monitor plus a space and then the text you expect to find when the site is up in ""
e.g.
http://www.mysite.com "text to match"
Save and test as needed.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Is a Url content check with more than one redirect possi
Thanks for sharing!
Locking thread as resolved
Locking thread as resolved