nrpe’s check_http – POSTing a file

i needed to monitor some service available via HTTP, this service is expecting to get a file posted – as if it was submitted via HTML form. so the file’s content is in the POST body, wrapped in Content-Type: multipart/form-data and stored between boundaries. Is it possible to simulate via check_http? yes!

/usr/lib/nagios/plugins/check_http -k "Accept: */*" \
-T "multipart/form-data; boundary=------------------------aa638c05ec87be94" \
-P $'--------------------------aa638c05ec87be94\r\nContent-Disposition: form-data; name="file"; filename="x"\r\nContent-Type: application/octet-stream\r\n\r\n<html><body></body></html>\r\n\r\n--------------------------aa638c05ec87be94--\r\n' \
-H some.hostname -u /path/to/the/apiendpoint -s "phrase expected in the body of response"

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)