Class: MuninManager::Plugins::StarlingOps

Inherits:
Object
  • Object
show all
Includes:
ActsAsMuninPlugin
Defined in:
lib/munin_manager/plugins/starling_ops.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActsAsMuninPlugin

included

Constructor Details

#initialize(host, port) ⇒ StarlingOps

Returns a new instance of StarlingOps.



12
13
14
15
16
# File 'lib/munin_manager/plugins/starling_ops.rb', line 12

def initialize(host, port)
  @host = "#{host}:#{port}"
  @starling = Starling.new(@host)
  @category = 'starling'
end

Class Method Details

.runObject



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/munin_manager/plugins/starling_ops.rb', line 64

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

#configObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/munin_manager/plugins/starling_ops.rb', line 38

def config
  graph_config = <<-END.gsub(/  +/, '')
  graph_title Starling Operations
  graph_args --base 1000
  graph_vlabel ops/${graph_period}
  graph_category #{@category}
  graph_order cmd_set cmd_get get_hits get_misses
  END

  stat_config = []
  ops_stats.each do |stat,config|
    config.each do |var,value|
      stat_config << "#{stat}.#{var} #{value}\n"
    end
  end
  return graph_config + stat_config.sort.join
end

#ops_statsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/munin_manager/plugins/starling_ops.rb', line 18

def ops_stats
  defaults = {
  'min' => 0,
  'max' => 5000,
  'type' => 'DERIVE',
  'draw' => 'LINE2',
  }
  stats = {
  'cmd_get' => {:label => 'GETs'},
  'cmd_set' => {:label => 'SETs'},
  'get_hits' => {:label => 'Hits'},
  'get_misses' => {:label => 'Misses'}
  }
  
  stats.each_key do |k|
    stats[k] = defaults.merge(stats[k])
  end
  return stats
end

#valuesObject



56
57
58
59
60
61
62
# File 'lib/munin_manager/plugins/starling_ops.rb', line 56

def values
  ret = ''
  ops_stats.each_key do |stat|
    ret << "#{stat}.value #{@starling.stats[@host][stat]}\n"
  end
  return ret
end