Module: Zabbix

Defined in:
lib/zabbix/host.rb,
lib/zabbix/item.rb,
lib/zabbix/event.rb,
lib/zabbix/proxy.rb,
lib/zabbix/connect.rb,
lib/zabbix/trigger.rb,
lib/zabbix/version.rb,
lib/zabbix/function.rb

Defined Under Namespace

Classes: Event, Function, Host, Item, Proxy, Trigger

Constant Summary collapse

Version =
VERSION = '0.1.5'

Class Method Summary collapse

Class Method Details

.connect(config = nil, logger = nil) ⇒ Object

Expects ‘config` (unimplemented optional) as a `Hash` with

:adapter
:host
:database
:username
:password

Expects ‘logger` (optional) to be a standard logger



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/zabbix/connect.rb', line 16

def self.connect( config = nil, logger = nil )
  
  @logger = logger
  
  @logger.info( 
  
    "CONNECT: Zabbix::connect({:host => '#{config[:host]}',:database => '#{config[:database]}'})"
  
  ) unless @logger.nil?
  
  if config.nil?
    
    config = load_standard_rails_things_for_db__and_feel_free_to_rename_this_function
    
  end
  
  begin

    if config[:port].nil?

      ActiveRecord::Base.establish_connection(

        :adapter => config[:adapter],
        :host => config[:host],
        :database => config[:database],
        :username => config[:username],
        :password => config[:password]

      )

    else 

      ActiveRecord::Base.establish_connection(

        :adapter => config[:adapter],
        :host => config[:host],
        :database => config[:database],
        :username => config[:username],
        :password => config[:password],
        :port => config[:port]

      )

   end

  rescue Exception => e
    
    #
    # Intercept to log error
    #
    
    @logger.error( 

      "ERROR: in Zabbix::connect() #{e.to_s}"

    ) unless @logger.nil?
    
    #
    # Re-Raise  (STILL WANT TO BRING THE DAEMON DOWN)
    #
    
    raise e
    
  end
    
end

.load_standard_rails_things_for_db__and_feel_free_to_rename_this_functionObject



84
85
86
87
88
89
90
91
92
# File 'lib/zabbix/connect.rb', line 84

def self.load_standard_rails_things_for_db__and_feel_free_to_rename_this_function
  
  #  
  #
  #  
  # 
  #   
  
end