sensu-plugins / sensu-plugins-rabbitmq

This plugin provides native RabbitMQ instrumentation for monitoring and metrics collection, including: service health, message, consumer, and queue health/metrics via `rabbitmq_management`, and more.
http://sensu-plugins.io
MIT License
23 stars 67 forks source link

Cluster Health - Can't modify frozen String #86

Open TomaszUrugOlszewski opened 6 years ago

TomaszUrugOlszewski commented 6 years ago

Examples:

Correct servers:

/opt/sensu/embedded/bin/check-rabbitmq-cluster-health.rb -w 10.0.0.6 -u monitoring -p pass -n rabbit1,rabbit2,rabbit3
CheckRabbitMQCluster OK: 3 healthy cluster nodes

One server is invalid:

/opt/sensu/embedded/bin/check-rabbitmq-cluster-health.rb -w 10.0.0.6 -u monitoring -p pass -n rabbit1,rabbit2,incorrect
CheckRabbitMQCluster UNKNOWN: can't modify frozen String

Versions:

kalemeow commented 6 years ago

I ran into this today as well with check-rabbitmq-consumers.rb, same error (can't modify frozen String). I disabled the frozen_string_literal header and the heck was able to generate the appropriate output.

# frozen_string_literal: false

rtkmhart commented 6 years ago

I'm seeing the same with check-rabbitmq-node-usage.rb. Full stack trace is:

["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:315:inbuild_option_arguments'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:269:in block (2 levels) in opt_parser'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:268:ineach'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:268:in block in opt_parser'", "/opt/sensu/embedded/lib/ruby/2.4.0/optparse.rb:1062:ininitialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:263:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:263:inopt_parser'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in parse_options'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:13:ininitialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:inblock in '"]`

With both Sensu 1.2.1 and 1.3.1, and sensu-plugins-rabbitmq v4.1.1.

@kalemeow where did you disable that string?

kalemeow commented 6 years ago

@rtkmhart The header is set at the top of the check script itself, ie https://github.com/sensu-plugins/sensu-plugins-rabbitmq/blob/master/bin/check-rabbitmq-node-usage.rb#L2 . Set it to false to disable (and enable your check to alert properly).

matthewmedway commented 3 years ago

For anyone stumbling upon this issue years later I was able to work around this issue by modifying the #frozen_string_literal from true to false in this manor:

  1. Notice in my sensu console that the command being run is check-rabbitmq-node-usage.rb -u sensu -p sensu --type mem is failing with the similar error.

image

  1. Try to find the check-rabbitmq-node-usage.rb file to be modified from the command field of my error.
cd /opt/sensu
find . -name "*rabbitmq-node-usage*"

found two results:

./embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-rabbitmq-8.1.0/bin/check-rabbitmq-node-usage.rb
./embedded/bin/check-rabbitmq-node-usage.rb
  1. Examine found files.

looking at the file ./embedded/bin/check-rabbitmq-node-usage.rb it does not contain the # frozen_string_literal: falsesection looking at the file ./embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-rabbitmq-8.1.0/bin/check-rabbitmq-node-usage.rb it does have this.

  1. Change the frozen_string_literal value

Changed it from true to false, saved the file

  1. Manually verify its working

Ran the check to confirm its working with the following command. In my case it was memory:

/opt/sensu/embedded/bin/check-rabbitmq-node-usage.rb -u sensu -p sensu --type mem

output:

CheckRabbitMQNodeUsage OK: Memory usage is at: 2.96%
  1. Verify within sensu

Waited for the check to run via sensu and it worked: image

This was just a test to see if the suggested workaround does work. In my case im running in docker so ill need a to create a new image if i want these changes to persist. 👍