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/auto_sender.rb,
lib/rubix/models/host.rb,
lib/rubix/models/item.rb,
lib/rubix/models/user.rb,
lib/rubix/associations.rb,
lib/rubix/models/model.rb,
lib/rubix/models/action.rb,
lib/rubix/models/medium.rb,
lib/rubix/models/script.rb,
lib/rubix/models/trigger.rb,
lib/rubix/models/template.rb,
lib/rubix/models/condition.rb,
lib/rubix/models/operation.rb,
lib/rubix/monitors/monitor.rb,
lib/rubix/models/host_group.rb,
lib/rubix/models/media_type.rb,
lib/rubix/models/user_group.rb,
lib/rubix/models/user_macro.rb,
lib/rubix/models/application.rb,
lib/rubix/models/time_series.rb,
lib/rubix/monitors/chef_monitor.rb,
lib/rubix/monitors/zabbix_monitor.rb,
lib/rubix/monitors/cluster_monitor.rb,
lib/rubix/associations/has_many_hosts.rb,
lib/rubix/associations/has_many_items.rb,
lib/rubix/associations/has_many_users.rb,
lib/rubix/associations/belongs_to_host.rb,
lib/rubix/associations/belongs_to_item.rb,
lib/rubix/associations/belongs_to_user.rb,
lib/rubix/associations/belongs_to_action.rb,
lib/rubix/associations/has_many_templates.rb,
lib/rubix/associations/belongs_to_template.rb,
lib/rubix/associations/has_many_conditions.rb,
lib/rubix/associations/has_many_host_groups.rb,
lib/rubix/associations/has_many_user_groups.rb,
lib/rubix/associations/has_many_user_macros.rb,
lib/rubix/associations/belongs_to_media_type.rb,
lib/rubix/associations/belongs_to_user_group.rb,
lib/rubix/associations/has_many_applications.rb
Defined Under Namespace
Modules: Associations, ChefMonitor, ClusterMonitor, Logs, ZabbixMonitor Classes: Action, Application, AutoSender, Condition, Connection, Host, HostGroup, Item, MediaType, Medium, Model, Monitor, Operation, Response, Script, Sender, Template, TimeSeries, Trigger, User, UserGroup, 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)
- ArgumentError =
Given an incorrect argument.
Class.new(Error)
Class Method Summary collapse
-
.authorized? ⇒ true, false
Is Rubix presently connected and authorized with a Zabbix server?.
-
.connect(server, username = nil, password = nil) ⇒ Rubix::Connection
Set up a
Connection
to a Zabbix API server. -
.connected? ⇒ true, false
Is Rubix presently connected to a Zabbix 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.
-
.version ⇒ String
Return the current Rubix version.
Class Method Details
.authorized? ⇒ true, false
Is Rubix presently connected and authorized with a Zabbix server?
55 56 57 |
# File 'lib/rubix.rb', line 55 def self. connection && connection. end |
.connect(server, username = nil, password = nil) ⇒ Rubix::Connection
30 31 32 |
# File 'lib/rubix.rb', line 30 def self.connect server, username=nil, password=nil self.connection = Connection.new(server, username, password) end |
.connected? ⇒ true, false
Is Rubix presently connected to a Zabbix server?
48 49 50 |
# File 'lib/rubix.rb', line 48 def self.connected? @connection && @connection. end |
.connection ⇒ Rubix::Connection
65 66 67 68 69 70 |
# File 'lib/rubix.rb', line 65 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')
41 42 43 |
# File 'lib/rubix.rb', line 41 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 |
.version ⇒ String
Return the current Rubix version.
75 76 77 78 79 80 81 |
# File 'lib/rubix.rb', line 75 def self.version @version ||= begin File.read(File.('../../VERSION', __FILE__)).chomp rescue => e 'unknown' end end |