Class: NetAtlas::Plugin::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/netatlas/plugin/base.rb

Direct Known Subclasses

Nagios, SNMP

Constant Summary collapse

SEVERITIES =
[:ok, :warning, :critical, :unknown, :error]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.argumentsObject



41
42
43
# File 'lib/netatlas/plugin/base.rb', line 41

def arguments
  self.plugin_args
end

.method_missing(meth, *args) ⇒ Object



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

def (self.plugin_args).method_missing(meth, *args)
  meth = meth.to_s.gsub("=",'').to_sym
  return self[meth] unless args
  arg = args.first
  self[meth] = if arg.kind_of? Class
    case arg.to_s
    when 'Integer', 'String'
      {:type => arg, :default => nil}
    end
  else
    case arg
    when true, false
      {:type => 'Boolean', :default => arg}
    when Integer, String
      {:type => arg.class, :default => arg}
    when Array
      {:type => arg.class, :options => arg}
    end
  end
end

.plugin_arguments(&block) ⇒ Object

voodoo



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/netatlas/plugin/base.rb', line 16

def plugin_arguments &block
  def (self.plugin_args).method_missing(meth, *args)
    meth = meth.to_s.gsub("=",'').to_sym
    return self[meth] unless args
    arg = args.first
    self[meth] = if arg.kind_of? Class
      case arg.to_s
      when 'Integer', 'String'
        {:type => arg, :default => nil}
      end
    else
      case arg
      when true, false
        {:type => 'Boolean', :default => arg}
      when Integer, String
        {:type => arg.class, :default => arg}
      when Array
        {:type => arg.class, :options => arg}
      end
    end
  end

  self.plugin_args.instance_eval(&block)
end

Instance Method Details

#pollObject



47
48
49
# File 'lib/netatlas/plugin/base.rb', line 47

def poll
  raise "Must override this method"
end