Problem with plugins with command line argument(s) specified

Hi I am trying to use the disk check plugin

I’m using sensu version 6.0.0+ee, enterprise edition

It works fine if use the defaults using this check definition:

type: CheckConfig
  command: "metrics-disk-usage.rb"
  handlers: []
  high_flap_threshold: 0
  interval: 10
  low_flap_threshold: 0
  publish: true
  - sensu-plugins/sensu-plugins-disk-checks
  - sensu/sensu-ruby-runtime
  - linux
  output_metric_format: graphite_plaintext
  - influx-db

If I add any command line options (for example command: "metrics-disk-usage.rb -w 80 -c 90") the check fail with this error on all subscribed hosts

Invalid check argument(s): invalid option: -w, ["/var/cache/sensu/sensu-agent/63f8d2c2c597270cc82217bd609e6f3068247416bc623dc076ef62b20a12d893424b9b0b3118628a5290f3ddfe3318e38ce36c9502acce956bb774bb96f18609/lib/ruby/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in parse_options’", “/var/cache/sensu/sensu-agent/63f8d2c2c597270cc82217bd609e6f3068247416bc623dc076ef62b20a12d893424b9b0b3118628a5290f3ddfe3318e38ce36c9502acce956bb774bb96f18609/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:16:in initialize'", "/var/cache/sensu/sensu-agent/63f8d2c2c597270cc82217bd609e6f3068247416bc623dc076ef62b20a12d893424b9b0b3118628a5290f3ddfe3318e38ce36c9502acce956bb774bb96f18609/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:58:in new’”, "/var/cache/sensu/sensu-agent/63f8d2c2c597270cc82217bd609e6f3068247416bc623dc076ef62b20a12d893424b9b0b3118628a5290f3ddfe3318e38ce36c9502acce956bb774bb96f18609/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:58:in block in <class:CLI>'"]

it looks like the options are being incorrectly intercepted. I have tried no quotes on the command definition and quotes aroud the whole thing, and even quoting both the options together and then it complains that both are not recogised at least.

when I add the ruby env to the path on the node and run it with the options all is good:

[root@n001 sensu-agent]# ruby 63f8d2c2c597270cc82217bd609e6f3068247416bc623dc076ef62b20a12d893424b9b0b3118628a5290f3ddfe3318e38ce36c9502acce956bb774bb96f18609/bin/check-disk-usage.rb -x -w 15 -c 25
CheckDisk CRITICAL: / 28.04% bytes usage (2.20 GiB/7.83 GiB), / 28.04% bytes usage (2.20 GiB/7.83 GiB)

I am running on CentOS7.8 VMs.

Any ideas? I’m stuck!

Case of “can’t see the wood for the trees”

when testing on the node I was typing check-disk-usage.rb which works

but I have configured sensu to run “metrics-disk-usage.rb” which does not have a -w option and it it telling me so very very clearly.

when I use the right check command in sensu it does the right thing and works perfectly