Module: Rubix
- Defined in:
- lib/rubix.rb,
lib/rubix/log.rb,
lib/rubix/models.rb,
lib/rubix/sender.rb,
lib/rubix/monitors.rb,
lib/rubix/response.rb,
lib/rubix/connection.rb,
lib/rubix/models/host.rb,
lib/rubix/models/item.rb,
lib/rubix/associations.rb,
lib/rubix/models/model.rb,
lib/rubix/models/template.rb,
lib/rubix/monitors/monitor.rb,
lib/rubix/models/host_group.rb,
lib/rubix/models/user_macro.rb,
lib/rubix/models/application.rb,
lib/rubix/monitors/chef_monitor.rb,
lib/rubix/monitors/cluster_monitor.rb,
lib/rubix/associations/has_many_hosts.rb,
lib/rubix/associations/belongs_to_host.rb,
lib/rubix/associations/has_many_templates.rb,
lib/rubix/associations/has_many_host_groups.rb,
lib/rubix/associations/has_many_user_macros.rb,
lib/rubix/associations/has_many_applications.rb
Defined Under Namespace
Modules: Associations, Logs
Classes: Application, ChefMonitor, ClusterMonitor, Connection, Host, HostGroup, Item, Model, Monitor, Response, Sender, Template, UserMacro
Constant Summary
collapse
- Error =
Class.new(RuntimeError)
- ConnectionError =
Class.new(Error)
- AuthenticationError =
Class.new(Error)
- RequestError =
Class.new(Error)
- ValidationError =
Class.new(Error)
Class Method Summary
collapse
Class Method Details
.connect(server, username = nil, password = nil) ⇒ Object
14
15
16
|
# File 'lib/rubix.rb', line 14
def self.connect server, username=nil, password=nil
self.connection = Connection.new(server, username, password)
end
|
.connection ⇒ Object
22
23
24
25
26
27
|
# File 'lib/rubix.rb', line 22
def self.connection
@connection ||= Connection.new('http://localhost/api_jsonrpc.php', 'admin', 'zabbix')
return @connection if @connection.authorized?
raise ConnectionError.new("Could not authorize with Zabbix API at #{@connection.uri}") unless @connection.authorize!
@connection
end
|
.connection=(connection) ⇒ Object
18
19
20
|
# File 'lib/rubix.rb', line 18
def self.connection= connection
@connection = connection
end
|
.default_log_path ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rubix/log.rb', line 37
def self.default_log_path
case
when defined?(Settings) && Settings[:log]
Settings[:log]
when ENV["RUBIX_LOG_PATH"] == '-'
$stdout
when ENV["RUBIX_LOG_PATH"]
ENV["RUBIX_LOG_PATH"]
else
$stdout
end
end
|
.default_log_severity ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rubix/log.rb', line 20
def self.default_log_severity
case
when defined?(Settings) && Settings[:log_level]
Logger.const_get(Settings[:log_level].to_s.strip)
when ENV["RUBIX_LOG_LEVEL"]
severity_name = ENV["RUBIX_LOG_LEVEL"].to_s.strip
else
severity_name = 'info'
end
begin
return Logger.const_get(severity_name.upcase)
rescue NameError => e
return Logger::INFO
end
end
|
.default_logger ⇒ Object
14
15
16
17
18
|
# File 'lib/rubix/log.rb', line 14
def self.default_logger
@logger = Logger.new(default_log_path)
@logger.level = default_log_severity
@logger
end
|
.logger ⇒ Object
9
10
11
12
|
# File 'lib/rubix/log.rb', line 9
def self.logger
return @logger unless @logger.nil?
@logger = default_logger
end
|
.logger=(l) ⇒ Object
5
6
7
|
# File 'lib/rubix/log.rb', line 5
def self.logger= l
@logger = l
end
|