Skip to main content

Hi,

I am trying to add a check on a web page to ensure it is up and running.
 

I tried with the HTTP plugin with the HTTP-Response-Time service template. By default it will fail only if the web server is not responding but it will be OK even with a 404 error for exemple. So I guess I have to use the option --critical-status to check that return code is 200. This gave me the following command

/usr/lib/centreon/plugins//centreon_protocol_http.pl

--plugin=apps::protocols::http::plugin

--mode=response

--hostname=myhostname

--proto='https'

--port='443'

--urlpath=''

--warning=''

--critical=''

--http-peer-addr='my_web_page_url'

--critical-status='%{http_code} != 200'

However when the web page URL returns a status different from 200 the test is still OK.

I guess I should use a different syntax for the --critical-status parameter? But all the exemples I found refers to this syntax.

I might have to use a different plugin or template to do what I seek? But I could not find which one then.

Your help or comments are welcome.

hello,

please run you command with “--debug” to see what is really happening, here fore example if I check google.com 

/usr/lib/centreon/plugins//centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=response --proto='https' --port='443' --http-peer-addr='www.google.com' --hostname=127.0.0.1 --critical-status='%{http_code} != 200' --urlpath='/' --debug

you can see 2 http code, there is a first 301 (redirect) then a 200

I tried using a false “path” and got a 404 error, which is returned as critical (even without the status)

 

there is an online website to test return code : httpstat.us

 /usr/lib/centreon/plugins//centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=response --proto='https' --port='443' --http-peer-addr='httpstat.us' --hostname=httpstat.us --critical-status='%{http_code} != 200' --urlpath='/200'

that returns ok with the status 200

 

the same command with the urlpath generating a 500 error code

 /usr/lib/centreon/plugins//centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=response --proto='https' --port='443' --http-peer-addr='httpstat.us' --hostname=httpstat.us --critical-status='%{http_code} != 200' --urlpath='/500'

that returns : CRITICAL: 500 Internal Server Error | 'time'=0.692s;;;0; 'size'=25B;;;0;

 

so i’m not really sure what is going on with your check, try with --debug to see what the curl command is generating and what you ca see in the inner http response.

also, use --help and you can see for example : 

 


Thank you for your quick reply and your recommendations. I was able to find the root issue.

Problem lies in my use of the option:

--http-peer-addr='my_web_page_url'

As I have a host serving different web URLs I though I could use http-peer-addr option to point to the URLs I wanted to test. But it turns out that I misunderstood the option the debug flag shows that only --hostname option is used to defined the tested URL. 

To clarify, lets say I have a web site at myjob1.com and another web site myjob2.com both hosted on the same IP. In centreon I created a host myjob1.com with 2 checks one for myjob1.com and the other for myjob2.com using the -http-peer-addr option when I thought I was testing myjob2.com I was in fact testing myjob1.com.

I guess I will have to define a separated host to test myjob2.com or define a check command using a different variable than hostname for the URL.

Anyhow thanks to ​@christophe.niel-ACT  for improving my knowledge of centreon.


Reply