Page 1 of 3

check_http

Posted: Mon Apr 29, 2019 1:19 pm
by nickanderson1982
I'm having trouble developing an http check for my domains.
I've tested it out and it works:
/usr/local/nagios/libexec/check_http -H xxxx.xxxx.com

But I want to check for a more finite site:
/usr/local/nagios/libexec/check_http -H xxxx.xxxx.com/api/api.asmx

But how would I setup the .cfg file for the checks? Do I just add the URL's where localhost is located? What is the local-service?
define host {

use linux-server ; Name of host template to use
; This host definition will inherit all variables
that are defined
; in (or inherited by) the linux-server host
template definition.
host_name localhost
alias localhost
address 127.0.0.1
}





define service {

use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 0
}

Re: check_http

Posted: Mon Apr 29, 2019 2:24 pm
by npolovenko
Hello, @nickanderson1982. First, let's get the command to work from the command line:
Did this command give you the desired output?
/usr/local/nagios/libexec/check_http -H xxxx.xxxx.com/api/api.asmx
Also, try this command:
/usr/local/nagios/libexec/check_http -H xxxx.xxxx.com -u "/api/api.asmx"
If the above commands don't work for you, please describe what the /api/api.asmx page does and what kind of protocol is being used?

After we get the command to work from the command line, I'll help you with the service definition in Core.

Re: check_http

Posted: Mon Apr 29, 2019 2:57 pm
by nickanderson1982
[XXXX objects]# /usr/local/nagios/libexec/check_http -H xxxxx.xxxx.com -u "/api/api.asmx"
HTTP OK: HTTP/1.0 301 Moved Permanently - 137 bytes in 0.002 second response time |time=0.001581s;;;0.000000 size=137B;;;0

Was that successful to that complete url xxxx.xxx.com/api/api.asmx ?

What does the -u mean? I am not understanding <uri>

Re: check_http

Posted: Mon Apr 29, 2019 3:02 pm
by nickanderson1982
Also how would I set up the .cfg file ?

Re: check_http

Posted: Mon Apr 29, 2019 3:35 pm
by npolovenko
@nickanderson1982, -u allows you to specify a relative path instead of just the host address.
HTTP OK: HTTP/1.0 301 Moved Permanently
This means that the web server is down but the web page doesn't exist at the destination. It could be that it's auto-redirecting to another page so lets try this command:
/usr/local/nagios/libexec/check_http -H xxxxx.xxxx.com -f follow -u "/api/api.asmx"

Code: Select all

define host {
    host_name                myWebServerHost
    use                           generic-host
    address                  www.xxxxxxx.com
    check_command            check_tcp!80!
    max_check_attempts       5
    check_interval           5
    retry_interval           1
    contacts                 nagiosadmin
    notification_interval    60
    notification_period      24x7
      check_period             24x7
    register                 1
}

define command {
    command_name    check_service_http
    command_line    $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}


define service {
    host_name                myWebServerHost
    service_description      URL Status
    use                            generic-service
    check_command            check_service_http! -f ok  -u '/api/api.asmx' 
    max_check_attempts       5
    check_interval           5
    retry_interval           1
    check_period             24x7
    notification_interval    60
    notification_period      24x7
    contacts                 nagiosadmin
    register                 1
}
But the command needs to work from the command line. If it doesn't, no point to implement this config in the cfg file yet.

Re: check_http

Posted: Mon Apr 29, 2019 3:35 pm
by npolovenko
@nickanderson1982, -u allows you to specify a relative path instead of just the host address.
HTTP OK: HTTP/1.0 301 Moved Permanently
This means that the web server is down but the web page doesn't exist at the destination. It could be that it's auto-redirecting to another page so lets try this command:
/usr/local/nagios/libexec/check_http -H xxxxx.xxxx.com -f follow -u "/api/api.asmx"

Code: Select all

define host {
    host_name                myWebServerHost
    use                           generic-host
    address                  www.xxxxxxx.com
    check_command            check_tcp!80!
    max_check_attempts       5
    check_interval           5
    retry_interval           1
    contacts                 nagiosadmin
    notification_interval    60
    notification_period      24x7
      check_period             24x7
    register                 1
}

define command {
    command_name    check_service_http
    command_line    $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}


define service {
    host_name                myWebServerHost
    service_description      URL Status
    use                            generic-service
    check_command            check_service_http! -f ok  -u '/api/api.asmx' 
    max_check_attempts       5
    check_interval           5
    retry_interval           1
    check_period             24x7
    notification_interval    60
    notification_period      24x7
    contacts                 nagiosadmin
    register                 1
}
But the command needs to work from the command line. If it doesn't, no point to implement this config in the cfg file yet.

Re: check_http

Posted: Tue Apr 30, 2019 9:03 am
by nickanderson1982
[root@]# /usr/local/nagios/libexec/check_http -H xxx.xxxx.com -f follow -u "/api/api.asmx"
connect to address xxx.xxx.com and port 443: Connection refused
HTTP CRITICAL - Unable to open TCP socket

Do I need to allow port 443 connections from this server?
Its going to a loadbalancer. I'm not sure what to do next or what to request.

Re: check_http

Posted: Tue Apr 30, 2019 2:37 pm
by npolovenko
@nickanderson1982, Can you nmap the server xxxxx.xxxx.com and show me the output with the list of listening posts?
nmap xxxxx.xxxx.com
This command needs to be executed from the nagios server.

Are you able to access the URL from different servers on the same network? From the nagios server console run:
curl -v xxxx.xxxx.com/api/api.asmx
And show me the output.

Re: check_http

Posted: Tue Apr 30, 2019 9:41 pm
by nickanderson1982
[root@]# nmap xxxx.xxxx.com

Starting Nmap 6.40 ( http://nmap.org ) at 2019-04-30 21:37 CDT
Nmap scan report for xxxx.xxxx.com (172.xx.xx.xxx)
Host is up (0.00070s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
80/tcp open http

Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds
[root@]# curl -v xxx.xxx.com/api.api.asmx
* About to connect() to prod.kdswitch.com port 80 (#0)
* Trying 172.xx.xx.xxx...
* Connected to prod.kdswitch.com (172.xx.xx.xxx) port 80 (#0)
> GET /api.api.asmx HTTP/1.1
> User-Agent: curl/7.29.0
> Host: xxx.xxxx.com
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
< location: https://xxx.xxx.com/api.api.asmx
< Server: BigIP
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
* Connection #0 to host xxx.xxx.com left intact

Re: check_http

Posted: Wed May 01, 2019 9:41 am
by npolovenko
@nickanderson1982, According to the nmap command, the ssl port is not listening. You can work with your networking team to find out why it's not working or use http instead of https in your URL.
/usr/local/nagios/libexec/check_http -H xxx.xxxx.com -f follow -u "/api/api.asmx" -p 80