Page 1 of 1

URL monitoring in Nagios cor from command prompt

Posted: Thu Aug 31, 2017 5:59 am
by jyoti22
Hi Team,
I am new to Nagios core. And want to monitor urls I have created service like below on nagios server

define service {
host_name DMSAPS01
service_description URL: http://10.0.1.8:9500/dsearch
check_command check_http!http://10.0.1.8:9500/dsearch
}

When I run check_http I get below command. Please help me on it

[root@DMSAMON01 libexec]# ./check_http -H 10.0.0.8 -u http://10.0.0.8:9500/dsearch
connect to address 10.0.0.8 and port 80: Connection refused
HTTP CRITICAL - Unable to open TCP socket

Thanks.

Re: URL monitoring in Nagios cor from command prompt

Posted: Thu Aug 31, 2017 9:02 am
by scottwilkerson
jyoti22 wrote:Hi Team,
I am new to Nagios core. And want to monitor urls I have created service like below on nagios server

define service {
host_name DMSAPS01
service_description URL: http://10.0.1.8:9500/dsearch
check_command check_http!http://10.0.1.8:9500/dsearch
}

When I run check_http I get below command. Please help me on it

[root@DMSAMON01 libexec]# ./check_http -H 10.0.0.8 -u http://10.0.0.8:9500/dsearch
connect to address 10.0.0.8 and port 80: Connection refused
HTTP CRITICAL - Unable to open TCP socket

Thanks.

It should be more like this

Code: Select all

./check_http -H 10.0.0.8 -u /dsearch -p 9500

Re: URL monitoring in Nagios cor from command prompt

Posted: Thu Aug 31, 2017 10:56 pm
by jyoti22
[[email protected]@DMSAZPLMON01 libexec]$ ./check_http -H 10.0.0.8 -u /dsearch -p 9500
HTTP WARNING: HTTP/1.1 404 Not Found - 246 bytes in 0.004 second response time |time=0.004413s;;;0.000000 size=246B;;;0

Please let me know what should be syntax of service.cfg file

Thanks.

Re: URL monitoring in Nagios cor from command prompt

Posted: Fri Sep 01, 2017 9:00 am
by scottwilkerson
Are you sure this URL exists and is accessible from the nagios XI server?

From the command line can you run

Code: Select all

curl -vvv http://10.0.1.8:9500/dsearch

Re: URL monitoring in Nagios cor from command prompt

Posted: Mon Sep 04, 2017 5:39 am
by jyoti22
URL takes time to load, I guess due to this I get warning message. I tried to increase timeout to 500 (-t 500) but still I get same error.
Kindly help

Re: URL monitoring in Nagios cor from command prompt

Posted: Tue Sep 05, 2017 7:51 am
by scottwilkerson
jyoti22 wrote:URL takes time to load, I guess due to this I get warning message. I tried to increase timeout to 500 (-t 500) but still I get same error.
Kindly help
A This error

Code: Select all

404 Not Found
is something the web server returns if you have an incorrect URL, not when it times out.

Lets run the command with a -v and please post the output

Code: Select all

./check_http -H 10.0.0.8 -u /dsearch -p 9500 -v

Re: URL monitoring in Nagios cor from command prompt

Posted: Wed Sep 06, 2017 3:04 am
by jyoti22
Please find the output.
[root@DMSAZPLMON01 libexec]# ./check_http -I 10.0.0.70 -u '/D2/#d2' -p 8080 -v
GET /D2/#d2 HTTP/1.0
User-Agent: check_http/v2.1.2 (nagios-plugins 2.1.2)
Connection: close
Accept: */*


http://10.0.0.70:8080/D2/#d2 is 1225 characters
STATUS: HTTP/1.1 404 Not Found
**** HEADER ****
Server: Apache-Coyote/1.1
X-UA-Compatible: chrome=1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1006
Date: Wed, 06 Sep 2017 07:58:37 GMT
Connection: close

**** CONTENT ****
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.37 - Error report</title><st yle type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;backgrou nd-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color: white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,san s-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family: Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Taho ma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma ,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black; }A.name {color : black;}.line {height: 1px; background-color: #525D76; border: n one;}</style> </head><body><h1>HTTP Status 404 - /D2/#d2</h1><div class="line">< /div><p><b>type</b> Status report</p><p><b>message</b> <u>/D2/#d2</u></p><p><b>d escription</b> <u>The requested resource is not available.</u></p><hr class="lin e"><h3>Apache Tomcat/8.0.37</h3></body></html>
HTTP WARNING: HTTP/1.1 404 Not Found - 1225 bytes in 0.006 second response time |time=0.006242s;;;0.000000 size=1225B;;;0


When I ran same url with IE, I get desired page. Please help. Thanks.

Re: URL monitoring in Nagios cor from command prompt

Posted: Wed Sep 06, 2017 8:46 am
by scottwilkerson
jyoti22 wrote:Please find the output.
[root@DMSAZPLMON01 libexec]# ./check_http -I 10.0.0.70 -u '/D2/#d2' -p 8080 -v
GET /D2/#d2 HTTP/1.0
User-Agent: check_http/v2.1.2 (nagios-plugins 2.1.2)
Connection: close
Accept: */*


http://10.0.0.70:8080/D2/#d2 is 1225 characters
STATUS: HTTP/1.1 404 Not Found
**** HEADER ****
Server: Apache-Coyote/1.1
X-UA-Compatible: chrome=1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1006
Date: Wed, 06 Sep 2017 07:58:37 GMT
Connection: close

**** CONTENT ****
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.37 - Error report</title><st yle type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;backgrou nd-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color: white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,san s-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family: Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Taho ma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma ,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black; }A.name {color : black;}.line {height: 1px; background-color: #525D76; border: n one;}</style> </head><body><h1>HTTP Status 404 - /D2/#d2</h1><div class="line">< /div><p><b>type</b> Status report</p><p><b>message</b> <u>/D2/#d2</u></p><p><b>d escription</b> <u>The requested resource is not available.</u></p><hr class="lin e"><h3>Apache Tomcat/8.0.37</h3></body></html>
HTTP WARNING: HTTP/1.1 404 Not Found - 1225 bytes in 0.006 second response time |time=0.006242s;;;0.000000 size=1225B;;;0


When I ran same url with IE, I get desired page. Please help. Thanks.
Well this is clearly a 404, which leads me to believe that the web server is only serving the page to certain hosts or IP's.

It shouldn't matter but in a URL items after and including # are never sent to a web server.

For clarity, this loads in your browser?
http://10.0.0.70:8080/D2/

If so, you may need to speak to the person who setup the web server to determine if they have some type of filtering going on that they can add your Nagios server to as allowed.

Re: URL monitoring in Nagios cor from command prompt

Posted: Wed Sep 13, 2017 11:42 pm
by jyoti22
It is working now. Please mark it as solved. Thanks a lot! :)