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 =
Base class for Rubix errors.
Class.new(RuntimeError)
- ConnectionError =
Errors with connecting to a Zabbix API.
Class.new(Error)
- AuthenticationError =
Error authenticating with a Zabbix API.
Class.new(Error)
- RequestError =
Error in a request to a Zabbix API.
Class.new(Error)
- ValidationError =
Error detected locally in an API resource that will prevent it from being saved by the Zabbix API (i.e. - no host group for a host).
Class.new(Error)
Class Method Summary collapse
-
.connect(server, username = nil, password = nil) ⇒ Rubix::Connection
Set up a
Connection
to a Zabbix API server. -
.connection ⇒ Rubix::Connection
Return the current connection to a Zabbix API.
-
.connection=(connection) ⇒ Rubix::Connection
Explicitly set the connection using a
Rubix::Connection
object. -
.default_log_path ⇒ Object
The default logger’s path.
-
.default_log_severity ⇒ Fixnum
The default logger’s severity.
-
.default_logger ⇒ Logger
The default logger.
-
.logger ⇒ Logger?
The current Rubix logger.
-
.logger=(l) ⇒ Object
Set the Rubix logger.
Class Method Details
.connect(server, username = nil, password = nil) ⇒ Rubix::Connection
29 30 31 |
# File 'lib/rubix.rb', line 29 def self.connect server, username=nil, password=nil self.connection = Connection.new(server, username, password) end |
.connection ⇒ Rubix::Connection
50 51 52 53 54 55 |
# File 'lib/rubix.rb', line 50 def self.connection @connection ||= Connection.new('http://localhost/api_jsonrpc.php', 'admin', 'zabbix') return @connection if @connection. raise ConnectionError.new("Could not authorize with Zabbix API at #{@connection.uri}") unless @connection. @connection end |
.connection=(connection) ⇒ Rubix::Connection
Explicitly set the connection using a Rubix::Connection
object.
Rubix.connection = Rubix::Connection.new('http://localhost/api_jsonrpc.php', 'admin', 'zabbix')
40 41 42 |
# File 'lib/rubix.rb', line 40 def self.connection= connection @connection = connection end |
.default_log_path ⇒ Object
The default logger’s path.
Will attempt to read from
-
Settings[:log]
ifSettings
is defined (see Configliere) -
the
RUBIX_LOG_PATH
environment variable if defined
Defaults to writing stdout
.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rubix/log.rb', line 64 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 ⇒ Fixnum
The default logger’s severity.
Will attempt to read from
-
Settings[:log_level]
ifSettings
is defined (see Configliere) -
the
RUBIX_LOG_LEVEL
environment variable if defined
The default is ‘info’.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rubix/log.rb', line 39 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 ⇒ Logger
The default logger.
23 24 25 26 27 |
# File 'lib/rubix/log.rb', line 23 def self.default_logger @logger = Logger.new(default_log_path) @logger.level = default_log_severity @logger end |
.logger ⇒ Logger?
The current Rubix logger.
15 16 17 18 |
# File 'lib/rubix/log.rb', line 15 def self.logger return @logger unless @logger.nil? @logger = default_logger end |
.logger=(l) ⇒ Object
Set the Rubix logger. Set to nil
to disable all logging.
8 9 10 |
# File 'lib/rubix/log.rb', line 8 def self.logger= l @logger = l end |