Class: MuninManager::Plugins::StarlingAge
- Inherits:
-
Object
- Object
- MuninManager::Plugins::StarlingAge
- Includes:
- ActsAsMuninPlugin
- Defined in:
- lib/munin_manager/plugins/starling_age.rb
Class Method Summary collapse
Instance Method Summary collapse
- #age_stats ⇒ Object
- #config ⇒ Object
-
#initialize(host, port) ⇒ StarlingAge
constructor
A new instance of StarlingAge.
- #values ⇒ Object
Methods included from ActsAsMuninPlugin
Constructor Details
#initialize(host, port) ⇒ StarlingAge
Returns a new instance of StarlingAge.
12 13 14 15 16 |
# File 'lib/munin_manager/plugins/starling_age.rb', line 12 def initialize(host, port) @host = "#{host}:#{port}" @starling = Starling.new(@host) @category = 'starling' end |
Class Method Details
.run ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/munin_manager/plugins/starling_age.rb', line 56 def self.run host = ENV['HOST'] || '127.0.0.1'; port = ENV['PORT'] || 22122; starling = new(host, port) allowed_commands = ['config'] if cmd = ARGV[0] and allowed_commands.include? cmd then puts starling.send(cmd.to_sym) else puts starling.values end end |
Instance Method Details
#age_stats ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/munin_manager/plugins/starling_age.rb', line 18 def age_stats defaults = { :type => 'GAUGE', :draw => 'AREA' } stats = @starling.available_queues.inject({}) do |stats, queue_name| queue,item = queue_name.split(/:/, 2) stats["queue_#{queue_name}_age"] = defaults.merge({ :label => "#{queue}[#{item}] age" }) stats end end |
#config ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/munin_manager/plugins/starling_age.rb', line 33 def config graph_names = age_stats.keys.map{|n| n.to_s.tr(':', '_')} graph_config = " graph_title Starling Queues Age\n graph_vlabel seconds in queue\n graph_category \#{@category}\n graph_order \#{graph_names.sort.join(' ')}\n END\n\n age_stats.inject(graph_config) do |stat_config, stat|\n stat[1].each do |var,value|\n graph_config << \"\#{format_for_munin(stat[0])}.\#{var} \#{value}\\n\"\n end\n graph_config\n end\nend\n".gsub(/ +/, '') |
#values ⇒ Object
50 51 52 53 54 |
# File 'lib/munin_manager/plugins/starling_age.rb', line 50 def values age_stats.inject("") do |ret, stat| ret << "#{format_for_munin(stat[0])}.value #{@starling.stats[@host][stat[0]]/1000.0}\n" end end |