Class: Nosey::Munin::Graph
- Inherits:
-
Object
- Object
- Nosey::Munin::Graph
- Defined in:
- lib/nosey/munin.rb
Overview
Parse a Nosey socket for Munin
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#data ⇒ Object
Returns the value of attribute data.
-
#filter(&block) ⇒ Object
Setup a filter from the graphing DSL so that we can grep out specific probes.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#probe_set ⇒ Object
Default to the first probeset if nothing is specified.
-
#title ⇒ Object
Returns the value of attribute title.
-
#vertical_label ⇒ Object
Returns the value of attribute vertical_label.
Instance Method Summary collapse
-
#configure ⇒ Object
Munin calls this to setup the title and labels for the chart graph_title THE TITLE OF YOUR GRAPH graph_category THE CATEGORY / GROUP OF YOUR GRAPH graph_vlabel Count total.label Total other.label Other.
-
#initialize(data = nil) {|_self| ... } ⇒ Graph
constructor
A new instance of Graph.
- #munin_hash(root_key = nil, hash = self.probe_set) ⇒ Object
-
#sample ⇒ Object
Munin calls this to set the values in the chart total.value 0 other.value 2.
Constructor Details
#initialize(data = nil) {|_self| ... } ⇒ Graph
Returns a new instance of Graph.
30 31 32 33 34 35 |
# File 'lib/nosey/munin.rb', line 30 def initialize(data=nil) @data = data @category = 'App' # Default it to app duuude yield self if block_given? self end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
27 28 29 |
# File 'lib/nosey/munin.rb', line 27 def category @category end |
#data ⇒ Object
Returns the value of attribute data.
27 28 29 |
# File 'lib/nosey/munin.rb', line 27 def data @data end |
#filter(&block) ⇒ Object
Setup a filter from the graphing DSL so that we can grep out specific probes
97 98 99 |
# File 'lib/nosey/munin.rb', line 97 def filter @filter end |
#labels ⇒ Object
Returns the value of attribute labels.
27 28 29 |
# File 'lib/nosey/munin.rb', line 27 def labels @labels end |
#probe_set ⇒ Object
Default to the first probeset if nothing is specified
88 89 90 |
# File 'lib/nosey/munin.rb', line 88 def probe_set report[@probe_set ||= report.keys.first] end |
#title ⇒ Object
Returns the value of attribute title.
27 28 29 |
# File 'lib/nosey/munin.rb', line 27 def title @title end |
#vertical_label ⇒ Object
Returns the value of attribute vertical_label.
27 28 29 |
# File 'lib/nosey/munin.rb', line 27 def vertical_label @vertical_label end |
Instance Method Details
#configure ⇒ Object
Munin calls this to setup the title and labels for the chart graph_title THE TITLE OF YOUR GRAPH graph_category THE CATEGORY / GROUP OF YOUR GRAPH graph_vlabel Count total.label Total other.label Other
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nosey/munin.rb', line 43 def configure body = StringIO.new body.puts "graph_title #{title}" body.puts "graph_category #{category}" body.puts "graph_vlabel #{vertical_label}" (@labels || {}).each do |field, label| body.puts "#{field}.label #{label}" end body.rewind body.read end |
#munin_hash(root_key = nil, hash = self.probe_set) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/nosey/munin.rb', line 69 def munin_hash(root_key=nil,hash=self.probe_set) # TODO perform processing for more complicated probes, like samplers, etc hash.reduce({}) do |memo, (name, value)| # If there's NOt a filter OR we have a filter and it filters... if !filter or (filter and filter.call(name)) case value when Hash # Its nested, go deep! Oooo yeah! munin_hash(format_field(root_key, name), value).each do |name, value| memo[format_field(root_key, name)] = value.to_a end else # Its cool, return this mmmkay? Sheesh man memo[format_field(root_key, name)] = [name, value] end end memo end end |
#sample ⇒ Object
Munin calls this to set the values in the chart total.value 0 other.value 2
60 61 62 63 64 65 66 67 |
# File 'lib/nosey/munin.rb', line 60 def sample body = StringIO.new munin_hash.each do |field, (label, value)| body.puts "#{field}.value #{value}" end body.rewind body.read end |