Class: GRI::Collector

Inherits:
Object show all
Defined in:
lib/gri/collector.rb

Direct Known Subclasses

ExecCollector, SNMPCollector, TraCollector

Constant Summary collapse

TYPES =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, options, fake_descr_hash, &cb) ⇒ Collector

Returns a new instance of Collector.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gri/collector.rb', line 21

def initialize host, options, fake_descr_hash, &cb
  @host = host
  @options = options
  @cname = @options['cname']
  @hostname = @options['hostname'] || @options['alias']
  @fake_descr_hash = fake_descr_hash || {}
  @cb = cb
  @buffers = []
  @results = []
  @on_error = nil
  @on_retry = nil
  on_init
end

Instance Attribute Details

#attached_atObject (readonly)

Returns the value of attribute attached_at.



12
13
14
# File 'lib/gri/collector.rb', line 12

def attached_at
  @attached_at
end

#hostObject (readonly)

Returns the value of attribute host.



11
12
13
# File 'lib/gri/collector.rb', line 11

def host
  @host
end

#intervalObject

Returns the value of attribute interval.



13
14
15
# File 'lib/gri/collector.rb', line 13

def interval
  @interval
end

#loopObject (readonly)

Returns the value of attribute loop.



12
13
14
# File 'lib/gri/collector.rb', line 12

def loop
  @loop
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/gri/collector.rb', line 11

def options
  @options
end

#timeoutObject

Returns the value of attribute timeout.



13
14
15
# File 'lib/gri/collector.rb', line 13

def timeout
  @timeout
end

Class Method Details

.create(col_type, host, options, fake_descr_hash = {}, &cb) ⇒ Object



15
16
17
18
19
# File 'lib/gri/collector.rb', line 15

def self.create col_type, host, options, fake_descr_hash={}, &cb
  if (klass = TYPES[col_type])
    klass.new host, options, fake_descr_hash, &cb
  end
end

Instance Method Details

#attach(loop) ⇒ Object



40
41
42
43
# File 'lib/gri/collector.rb', line 40

def attach loop
  @loop = loop
  on_attach
end

#on_attachObject



45
46
# File 'lib/gri/collector.rb', line 45

def on_attach
end

#on_detachObject



48
49
# File 'lib/gri/collector.rb', line 48

def on_detach
end

#on_error(&block) ⇒ Object



54
55
56
# File 'lib/gri/collector.rb', line 54

def on_error &block
  @on_error = block
end

#on_initObject



37
38
# File 'lib/gri/collector.rb', line 37

def on_init
end

#on_retry(&block) ⇒ Object



58
59
60
# File 'lib/gri/collector.rb', line 58

def on_retry &block
  @on_retry = block
end

#on_timeoutObject



51
52
# File 'lib/gri/collector.rb', line 51

def on_timeout
end

#sync?Boolean

Returns:

  • (Boolean)


35
# File 'lib/gri/collector.rb', line 35

def sync?; true; end