Created
June 27, 2013 20:19
-
-
Save mvam75/5880018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"C:/ruby/lib/ruby/gems/1.9.1/gems/sensu-plugin-0.1.7/lib/sensu-plugin/cli.rb:60:in `rescue in block in <class:CLI>': undefined method `critical' for nil:NilClass (NoMethodError)\n\tfrom C:/ruby/lib/ruby/gems/1.9.1/gems/sensu-plugin-0.1.7/lib/sensu-plugin/cli.rb:54:in `block in <class:CLI>'\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sensu-plugin/metric/cli' | |
require 'yajl' | |
require 'rest-client' | |
require 'facets' | |
class RMP2Limits < Sensu::Plugin::Metric::CLI::Graphite | |
option :host, | |
:short => "-h HOST", | |
:long => "--host HOST", | |
:description => "RMP Host to connect to", | |
:required => true | |
option :scheme, | |
:description => "Metric naming scheme, text to prepend to metric", | |
:short => "-s SCHEME", | |
:long => "--scheme SCHEME", | |
:default => "rmp" | |
def run | |
url = RestClient.get "http://#{config[:host]}:668/status/limits", :timeout => 10 | |
data = Yajl::Parser.new.parse(url) | |
limits_hash = data["limiters"][1]["limits"].mash {|n| [n["key"], n]} | |
limits_items = ['active', 'maximum', 'totalAttempts'] | |
limits_hash.each do |k,v| | |
limits_items.each do |item| | |
output "#{config[:scheme]}.#{k}.#{item}", v[item] | |
end | |
end | |
ok | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment