sensu-plugins-http icon indicating copy to clipboard operation
sensu-plugins-http copied to clipboard

read postbody as a string argument and not as a file in check-http-json.rb

Open oryband opened this issue 9 years ago • 1 comments

See this line. Forcing the sensu-client to have a file with the body when using -b argument is limiting. I would prefer the server to be able to send the body as a string argument. I've tried to hack around this by using the <(..) bash statement in order to create an on-the-fly file descriptor and pass it as the body argument instead:

// sensu-server checks conf.d:
"check-gcm-service-health": {
    "command": "check-http-json.rb -u 'http://gcm-http.googleapis.com/gcm/send' -m POST -H 'Content-Type: application/json,Authorization: key=my-key' -b <(echo '{\"to\": \"my-device-token\"}') -K 'results' -v '[{\"error\"=>\"NotRegistered\"}]'",
        // other options

This however doesn't work, since sensu-client is using /bin/sh and not /bin/bash (I think), thus the <(..) statement returns a sh: 1: Syntax error: "(" unexpected.

It would've been a lot easier (and simpler) if the body could be passed as a string argument instead of a file. You can easily stay backward compatible by using:

check-http-json.rb -b `cat body.txt`

oryband avatar Nov 15 '15 16:11 oryband

I'd gladly merge a backwards-compatible PR.

analytically avatar Nov 15 '15 17:11 analytically