sensu-plugins / sensu-plugins-sensu

This plugin provides monitoring and metrics for Sensu.
http://sensu-plugins.io
MIT License
12 stars 35 forks source link

handler-purge-stale-results.rb errors out when parsing options #47

Closed asachs01 closed 7 years ago

asachs01 commented 7 years ago

We've recently encountered an error when running a check using handler-purge-stale-results.rb. It appears as the following:

{ "timestamp": "2017-10-06T06:32:26.683000-0700", "level": "error", "message": "handler output", "handler": { "command": "handler-purge-stale-results.rb -s 3d", "type": "pipe", "filters": [], "severities": [ "critical" ], "handle_flapping": false, "handle_silenced": false, "name": "purge-stale-results" }, "event": { "id": "04b46eef-7645-4b8e-8a8d-ca3902f11a6e" }, "output": [ "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:23 0:in `parse_options': invalid option: -s (OptionParser::InvalidOption)\n\tfrom /opt/sen su/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-handler.rb:18:in `ini tialize'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/se nsu-handler.rb:96:in `new'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-p lugin-1.4.5/lib/sensu-handler.rb:96:in `block in '\n/opt/sensu/embedded/ lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-2.3.0/bin/handler-purge-stale-results.rb:3 4:in `': undefined local variable or method `required' for HandlerPurgeStaleResults:Class (NameError)\nDid you mean? require\n\tfrom /opt/sen su/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-2.3.0/bin/handler-purge-stale- results.rb:13:in `'\n\tfrom /opt/sensu/embedded/bin/handler-purge-stale -results.rb:22:in `load'\n\tfrom /opt/sensu/embedded/bin/handler-purge-stale-results.rb :22:in `'\n" ] }

Something that's perhaps a bit more readable:

[root@test bin]# /opt/sensu/embedded/bin/ruby handler-purge-stale-results.rb -s 3d
/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in `parse_options': invalid option: -s (OptionParser::InvalidOption)
        from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.0.1/lib/sensu-handler.rb:18:in `initialize'
        from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.0.1/lib/sensu-handler.rb:80:in `new'
        from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.0.1/lib/sensu-handler.rb:80:in `block in <class:Handler>'
handler-purge-stale-results.rb:34:in `<class:HandlerPurgeStaleResults>': undefined local variable or method `required' for HandlerPurgeStaleResults:Class (NameError)
Did you mean?  require
        from handler-purge-stale-results.rb:13:in `<main>'

I'd include some expected output here, but since we're not able to run the check successfully, we don't have any to provide.