{"id":3374,"date":"2022-09-09T19:21:22","date_gmt":"2022-09-09T18:21:22","guid":{"rendered":"https:\/\/kudzia.eu\/b\/?p=3374"},"modified":"2022-09-09T19:21:23","modified_gmt":"2022-09-09T18:21:23","slug":"nrpes-check_http-posting-a-file","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2022\/09\/nrpes-check_http-posting-a-file\/","title":{"rendered":"nrpe&#8217;s check_http &#8211; POSTing a file"},"content":{"rendered":"\n<p>i needed to monitor some service available via HTTP, this service is expecting to get a file posted &#8211; as if it was submitted via HTML form. so the file&#8217;s content is in the POST body, wrapped in <em>Content-Type: multipart\/form-data <\/em>and stored between boundaries. Is it possible to simulate via check_http? yes!<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/nagios\/plugins\/check_http -k \"Accept: *\/*\" \\\n-T \"multipart\/form-data; boundary=------------------------aa638c05ec87be94\" \\\n-P $'--------------------------aa638c05ec87be94\\r\\nContent-Disposition: form-data; name=\"file\"; filename=\"x\"\\r\\nContent-Type: application\/octet-stream\\r\\n\\r\\n&lt;html>&lt;body>&lt;\/body>&lt;\/html>\\r\\n\\r\\n--------------------------aa638c05ec87be94--\\r\\n' \\\n-H some.hostname -u \/path\/to\/the\/apiendpoint -s \"phrase expected in the body of response\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>i needed to monitor some service available via HTTP, this service is expecting to get a file posted &#8211; as if it was submitted via HTML form. so the file&#8217;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!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-3374","post","type-post","status-publish","format-standard","hentry","category-unimportant"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=3374"}],"version-history":[{"count":1,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3374\/revisions"}],"predecessor-version":[{"id":3375,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3374\/revisions\/3375"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=3374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=3374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=3374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}