Tuesday, 5 December 2017

Using Nagios to monitor IBM HTTP Server and IBM WebSphere Liberty Profile

This ties up with a piece of work upon which I'm currently engaged.

I've configured Nagios 4.3.4 to test IBM HTTP Server (IHS) 8.5.5.12 and the MobileFirst Platform (MFP) runtime, which runs on WebSphere Liberty Profile 17.0.0.3.

This is using the out-of-the-box Nagios plugin called check_http: -

/usr/local/nagios/libexec/check_http

which can be invoked thusly: -

/usr/local/nagios/libexec/check_http -H mfp.uk.ibm.com -p 8443 -S

HTTP OK: HTTP/1.1 200 OK - 3710 bytes in 0.014 second response time |time=0.014478s;;;0.000000 size=3710B;;;0

/usr/local/nagios/libexec/check_http -H mfp.uk.ibm.com -p 8443 -S -u /index.html

HTTP OK: HTTP/1.1 200 OK - 3710 bytes in 0.029 second response time |time=0.028933s;;;0.000000 size=3710B;;;0

/usr/local/nagios/libexec/check_http -H mfp.uk.ibm.com -p 8443 -S -u /appcenterconsole/login.html

HTTP OK: HTTP/1.1 200 OK - 2781 bytes in 0.088 second response time |time=0.087591s;;;0.000000 size=2781B;;;0

In other words, the plugin has a few key parameters: -

-H hostname
-p port
-S HTTPS
-u URI

In brief, this is what I have configured in Nagios: -

sudo vi /usr/local/nagios/etc/servers/mfp.cfg

define host {
        use                             linux-server
        host_name                       mfp.uk.ibm.com
        alias                           MobileFirst Platform
        address                         192.168.153.131
        max_check_attempts              5
        check_period                    24x7
        notification_interval           30
        notification_period             24x7
}
define command {
        command_name                    check_http_with_args
        command_line                    $USER1$/check_http -H $HOSTADDRESS$ -S -p $ARG1$ -u $ARG2$
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             IHS_Welcome_Page
        check_command                   check_http_with_args!8443!/index.html
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             MFP_Login_Page
        check_command                   check_http_with_args!8443!/appcenterconsole
        notifications_enabled           0
}

You'll see that I've defined a new command - check_http_with_args - which reuses check_http, but adds arguments for -H, -p, -S and -u.

I've then defined two new services - IHS_Welcome_Page and MFP_Login_Page - which use this new command.

Finally, I reloaded the Nagios systemd service: -

sudo systemctl restart nagios.service

This is what I now see: -


 As you can see, the two new services on the MFP host both return HTTP 200 Success, which ties up with what I see in the IHS access_log: -

192.168.153.130 - - [05/Dec/2017:14:45:54 +0000] "GET /index.html HTTP/1.1" 200 3493
192.168.153.130 - - [05/Dec/2017:14:46:28 +0000] "GET /appcenterconsole/login.html HTTP/1.1" 200 2451
192.168.153.130 - - [05/Dec/2017:14:49:13 +0000] "GET /index.html HTTP/1.1" 200 3493
192.168.153.130 - - [05/Dec/2017:14:49:23 +0000] "GET /appcenterconsole HTTP/1.1" 302 -
192.168.153.130 - - [05/Dec/2017:14:51:38 +0000] "GET /appcenterconsole/login.html HTTP/1.1" 200 2451

If I change the MFP_Login_Page service to only use the /appcenterconsole URI, then I'll see the HTTP 302 Found response ( which is one of the Redirect response codes ).

If I stop IHS, Nagio shows me this: -

 

If I start IHS but stop MFP, Nagios shows me this: -


This is HTTP 500 Internal Server Error.

Source for check_http plugin here: -


and here: -


It's also worth noting that check_http has a number of other useful features, including the ability to check certificates: -


Again, this came from here -> http://linux.101hacks.com/unix/check-http/

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...