sensu-plugins / sensu-plugins-haproxy

This plugin provides native HAProxy instrumentation for monitoring and metrics collection, including: service health and backend server metrics.
http://sensu-plugins.io
MIT License
11 stars 37 forks source link

CSV Gem Issues Using Embedded Ruby 2.3.0 #17

Closed johnnystarr closed 7 years ago

johnnystarr commented 8 years ago

I've pulled down the master branch of this gem, and integrated the plugins to my organization's monitoring cookbook. This deploys the sensu plugins to the clients, and uses the embedded Ruby binary at /opt/chef/embedded/bin/ruby. The current version deployed with Chef Client 12.* is Ruby 2.3.0

I'm getting the following feedback

action: create
command: /opt/chef/embedded/bin/ruby /etc/sensu/plugins/metrics-haproxy.rb -c 10.0.2.15
duration: 0.367
executed: 2016-11-18 15:28:18
handlers: slack
history: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2
interval: 300
issued: 2016-11-18 15:28:18
name: haproxy_metrics
occurrences: 1
output: Check failed to run: Illegal quoting in line 2., ["/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1883:in
 `block (2 levels) in shift'", "/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1845:in `each'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1845:in `block in shift'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1805:in `loop'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1805:in `shift'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1747:in `each'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1761:in `to_a'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1761:in `read'", 
"/opt/chef/embedded/lib/ruby/2.3.0/csv.rb:1307:in `parse'", "/etc/sensu/plugins/metrics-
haproxy.rb:145:in `run'", "/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.3/lib/sensu-
plugin/cli.rb:58:in `block in <class:CLI>'"]

standalone: true
status: 2
total_state_change: 0

The above is complaining about metrics-haproxy.rb line 145: https://github.com/sensu-plugins/sensu-plugins-haproxy/blob/master/bin/metrics-haproxy.rb#L145

It should be noted that I'm getting the same error here: https://github.com/sensu-plugins/sensu-plugins-haproxy/blob/master/bin/check-haproxy.rb#L201

So far, the only conclusion I can come to is that Ruby 2.3.0 is not yet supported by this plugin, or there is a bug in this use of CSV for this version. Or, possibly this implementation does not support the latest CSV class itself. Any feedback is much appreciated.

-Johnny Starr

eheydrick commented 8 years ago

I tried repro'ing this using both the Ruby 2.3.0 included with sensu and the one in Chef you are using and was unable to hit the error. I suspect there's something about your haproxy stats output tripping up the CSV parser, possibly an extra quote or space. Would you mind pasting line 2 of haproxy's CSV stats so we can see what's being parsed.

majormoses commented 7 years ago

closing due to inactivity, if you still need help feel free to reply and we can re-open.