Coder Social home page Coder Social logo

sensu-plugins / sensu-plugins-haproxy Goto Github PK

View Code? Open in Web Editor NEW
11.0 9.0 37.0 120 KB

This plugin provides native HAProxy instrumentation for monitoring and metrics collection, including: service health and backend server metrics.

Home Page: http://sensu-plugins.io

License: MIT License

Ruby 100.00%
sensu-plugins haproxy metrics monitoring

sensu-plugins-haproxy's Introduction

Sensu-Plugins-haproxy

Build Status Gem Version Code Climate Test Coverage Dependency Status Sensu Bonsai Asset

Sensu Asset

The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator or handler), make sure you include the corresponding Sensu Ruby runtime asset in the list of assets needed by the resource. The current ruby-runtime assets can be found here in the Bonsai Asset Index.

Functionality

Files

  • bin/check-haproxy.rb
  • bin/metrics-haproxy.rb

Usage

Metrics

$ /opt/sensu/embedded/bin/metrics-haproxy.rb --help
Usage: /opt/sensu/embedded/bin/metrics-haproxy.rb (options)
    -f BACKEND1[,BACKEND2],          comma-separated list of backends to fetch stats from. Default is all backends
        --backends
    -c HOSTNAME|SOCKETPATH,          HAproxy web stats hostname or path to stats socket (required)
        --connect
    -a, --expose-all                 Expose all possible metrics, includes "--server-metrics", "--backends" will still in effect
    -p, --pass PASSWORD              HAproxy web stats password
    -q, --statspath STATUSPATH       HAproxy web stats path (the / will be prepended to the STATUSPATH e.g stats)
    -P, --port PORT                  HAproxy web stats port
    -r, --retries RETRIES            Number of times to retry fetching stats from haproxy before giving up.
    -i, --retry_interval SECONDS     Interval (seconds) between retries
    -s, --scheme SCHEME              Metric naming scheme, text to prepend to metric
        --server-metrics             Gathers additional frontend metrics, i.e. total requests
        --use-explicit-names         Use explicit names for frontend, backend, server, listener
        --use-haproxy-names          Use raw names as used in haproxy CSV format definition rather than human friendly names
    -S, --use-ssl                    Use SSL to connect to HAproxy web stats
    -u, --user USERNAME              HAproxy web stats username
$

Installation

Installation and Setup

Notes

sensu-plugins-haproxy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-plugins-haproxy's Issues

2.0.1 checks doesn't work properly with '# frozen_string_literal: true'

both check-haproxy.rb and metrics-haproxy.rb doesn't work properly with # frozen_string_literal: true

sensu-plugins-haproxy: 2.0.1
sensu-version: 1.0.2-1~xenial
ruby: embedded

/opt/sensu/embedded/bin/check-haproxy.rb -S /tmp/haproxy.sock -c 100 -b 75 -B 90 -X1 -s '^.*_noop$'
Check failed to run: can't modify frozen String, ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:315:in `build_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:in `each'", "/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:in `initialize'", "/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:in `opt_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-4.0.0/lib/sensu-plugin/cli.rb:16:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:58:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]

It works fine after changing true to false.
Is there any other way how to run the checks other then editing check files?

CSV Gem Issues Using Embedded Ruby 2.3.0

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

Unable to fetch stats from haproxy after 3 attempts

Command: metrics-haproxy.rb -c /var/lib/haproxy/stats

Even when I provide username and password the result is still:
Unable to fetch stats from haproxy after 3 attempts

When I run the metrics command on the command line it gives me stats perfectly fine, the socket is chmod 755.

Any suggestions? Literally all sensu checks work on this server except this one.

Does not work for HAProxy 2.3.0

Plugin works fine for 2.2.4 but stopped working after upgrade to 2.3.0.

Check failed to run: undefined method `[]' for nil:NilClass, ["/opt/gems/sensu-plugins-haproxy/gems/sensu-plugins-haproxy-2.0.2/bin/check-haproxy.rb:226:in `block in acquire_services'", "/opt/gems/sensu-plugins-haproxy/gems/sensu-plugins-haproxy-2.0.2/bin/check-haproxy.rb:226:in `map'", "/opt/gems/sensu-plugins-haproxy/gems/sensu-plugins-haproxy-2.0.2/bin/check-haproxy.rb:226:in `acquire_services'", "/opt/gems/sensu-plugins-haproxy/gems/sensu-plugins-haproxy-2.0.2/bin/check-haproxy.rb:141:in `run'", "/opt/gems/sensu-plugins-haproxy/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:59:in `block in <class:CLI>'"]

req_rate and req_rate_max are only available on FRONTEND metrics

According to the HAProxy manual for 1.5+:

 46. req_rate [.F..]: HTTP requests per second over last elapsed second
 47. req_rate_max [.F..]: max number of HTTP requests per second observed

The [.F..] indicates these stats are only available for FRONTENDs, and as such, never get rendered since metrics-haproxy.rb uses:

      if line[1] == 'BACKEND'
        ...
        unless line[46].nil?
          output "#{config[:scheme]}.#{line[0]}.requests_per_second", line[46]
        end
        unless line[47].nil?
          output "#{config[:scheme]}.#{line[0]}.requests_per_second_max", line[47]
        end
        ...

It appears that metrics-haproxy.rb don't check any FRONTEND metrics. Is this intentional?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.