Class: MuninManager::Plugins::ScribeNet
- Inherits:
-
Object
- Object
- MuninManager::Plugins::ScribeNet
- Includes:
- ActsAsMuninPlugin
- Defined in:
- lib/munin_manager/plugins/scribe_net.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(host, port) ⇒ ScribeNet
constructor
A new instance of ScribeNet.
- #values ⇒ Object
Methods included from ActsAsMuninPlugin
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
.run ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/munin_manager/plugins/scribe_net.rb', line 48 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
#config ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/munin_manager/plugins/scribe_net.rb', line 16 def config graph_config = " graph_title Scribe Traffic\n graph_args --base 1000\n graph_vlabel bits per second\n graph_category \#{@category}\n END\n\n\n \n graph_order = 'graph_order'\n counters.keys.each do |stat|\n stat_name = format_for_munin(stat)\n graph_order << \" \"+ stat_name\n stat_config = \"\#{stat_name}.label \#{stat_name}\" \n net_stats.each do |var,value|\n value = \"\#{stat_name},\" + value if var == :cdef\n stat_config << \"\#{stat_name}.\#{var} \#{value}\\n\"\n end\n end\n\n return graph_config + graph_order+\"\\n\" + stat_config\nend\n".gsub(/ +/, '') |
#values ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/munin_manager/plugins/scribe_net.rb', line 40 def values ret = "" @scribe.getCounters.each do |k, v| ret << "#{format_for_munin(k)}.value #{v}\n" end ret end |