Class: MuninManager::Plugins::ScribeNet

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActsAsMuninPlugin

included

Constructor Details

#initialize(host, port) ⇒ ScribeNet

Returns a new instance of ScribeNet.



11
12
13
14
# File 'lib/munin_manager/plugins/scribe_net.rb', line 11

def initialize(host, port)
  @scribe = FB303::Client.new(host, port)
  @category = 'scribe'
end

Class Method Details

.runObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/munin_manager/plugins/scribe_net.rb', line 49

def self.run
  host = ENV['SCRIBE_HOST'] || 'localhost';
  port = ENV['SCRIBE_PORT'] || 1463;
  scribe = new(host, port)
  allowed_commands = ['config']

  if cmd = ARGV[0] and allowed_commands.include? cmd then
    puts scribe.send(cmd.to_sym)
  else
    puts scribe.values
  end
end

Instance Method Details

#configObject



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

def config
  graph_config = <<-END.gsub(/  +/, '')
    graph_title Scribe Traffic
    graph_args --base 1000
    graph_vlabel bits per second
    graph_category #{@category}
  END


  
  graph_order = 'graph_order'
  stat_config = ''
  counters.keys.each do |stat|
    stat_name = format_for_munin(stat)
    graph_order << " "+ stat_name
    stat_config = "#{stat_name}.label #{stat_name}"  
    net_stats.each do |var,value|
      value = "#{stat_name}," + value if var == :cdef
      stat_config << "#{stat_name}.#{var} #{value}\n"
    end
  end

  return graph_config + graph_order+"\n" + stat_config
end

#valuesObject



41
42
43
44
45
46
47
# File 'lib/munin_manager/plugins/scribe_net.rb', line 41

def values
  ret = ""
  @scribe.getCounters.each do |k, v|
    ret << "#{format_for_munin(k)}.value #{v}\n"
  end
  ret
end