Check POST variable with check_http


I’m using icinga2 with nagios plugins for several years and is really great. Thanks for that!

I’m having trouble to setup a check_http plugin with post data. I 'don’t know what I’m doing wrong.

I’ve spend several days trying to make http_check works to post data to check a web service. Php server variable $_POST is empty.

In curl it works like this:

curl -H X-Api-Key:xxxxxxxxxxxxxxxxxxxxxx -H "Content-Type: multipart/form-data" -X POST -F 'dni=22222222' -F 'action=consultar'

I 'm trying to replicate curl behavior calling check_http plugin like this:

/usr/lib/nagios/plugins/check_http -S -H -k 'X-Api-Key:xxxxxxxxxxxxxxxxxxxxxx' -u "/ws/dniconsultar.php" -P "dni%3D22222222%3B%20action%3Dconsultar" -T "multipart/form-data" -v

But always _POST server variable in server side is empty.

¿What I’m missing to post data be sent to the server?

Best regards

Hi @marianoacc

Welcome to the community!

I moved your post to a new topic, as the “Ask me Anything” thread is not suitable for that.

I also added some code formatting :slight_smile:
See Create topics and master Markdown formatting for formatting tips for future posts :slight_smile:

Best regards

1 Like

You may need to explicitly specify the method to check_http, can you try it with -j POST?

 -j, --method=STRING  (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)
    Set HTTP method.

since you are familiar with curl you could use check_curl

Hi Lee

Thanks a lot by your response. I tried to add “-j POST” and the result is the same thing, the _POST variable is empty on server.

Thanks regards

Thanks Moreamazingnick for your response, as I understand by de syntax of check_curl2:

    -U URL (s)
    -A Agent (s)(default: Mozilla/5.0 ... )
    -G Grep page on STRING (s)
    -L Show page (-)
    -F Follow redirects (-)
    -I Ignore SSL certificate errors (-)
    -X Exclude performance data (default: include)
    -Tc Ccritical page return time (i)
    -Tw Warning page return time (i)
    -Sbc Critical page size below SIZE (i)
    -Soc Critical page size over SIZE (i)
    -Sbw Warning page size below SIZE (i)
    -Sow Warning page size over SIZE (i)
    -S Find string between ARG1 and ARG2, return first match (s s) (example: value=\" \" )
    -T Timeout (i)(default: 10sec)
    -O Output Driven Check - Page Should respond with \"Status: OK\" or otherwise
\n\n Example:
  check_curl.php -U\n\n";

It not include the posibility to add post form data.


yes but since it’s php you can modify the code and add new parameters to check_curl

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,