Nagios not following redirect with check_http

Currently for testing I set the service check as follows:

define service{
use     generic-service 
host_name       <host>
service_description HTTP
check_command   check_http!-s "blablabla" -f follow
}

Note the string "blablabla" does not exist on the page, this is simply for testing.

Nagios is reporting

HTTP OK: HTTP/1.1 301 Moved Permanently - 294 bytes in 6.607 second response time
Performance Data:   time=6.606636s;;;0.000000 size=294B;;;0

However if I run the check_http plugin directly I get the following:

<user>@<nagiosbox>:/usr/lib/nagios/plugins# ./check_http -H <host> -s "blablabla" -f follow
HTTP CRITICAL: HTTP/1.1 200 OK - string 'blablabla' not found on 'http://<host>:80/' - 92654 bytes in 3.984 second response time |time=3.983636s;;;0.000000 size=92654B;;;0

Solution 1:

Are you sure you are calling the same plugin with the same arguments? It seems to me that you did not define the service correctly. Usually, the arguments are passed without options such as:

check_command   check_http!blablabla!follow

They are spearated by !. In the command definition, you can specify the correct options of the check_http plugin such as:

# 'check_http' command definition
define command{
        command_name    check_http
        command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -s '$ARG1$' -f '$ARG2$'
        }

The arguments $ARG1$ and $ARG2$ will be replaced with the real values you specified in the service definition.