Class: Monitoring
- Inherits:
-
Object
- Object
- Monitoring
- Defined in:
- app/services/monitoring.rb
Constant Summary collapse
- CREATE_ACTIONS =
{ 'none' => _('None'), 'create' => _('Create Host Object') }.freeze
- DELETE_ACTIONS =
{ 'none' => _('None'), 'delete' => _('Delete Host Object'), 'downtime' => _('Set Downtime for Host') }.freeze
Instance Attribute Summary collapse
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#proxy_api ⇒ Object
readonly
Returns the value of attribute proxy_api.
Class Method Summary collapse
Instance Method Summary collapse
- #create_host(host) ⇒ Object
- #del_downtime_host(host, options = {}) ⇒ Object
- #delete_host(host) ⇒ Object
-
#initialize(opts) ⇒ Monitoring
constructor
A new instance of Monitoring.
- #query_host(host) ⇒ Object
- #set_downtime_host(host, options = {}) ⇒ Object
- #update_host(host) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Monitoring
Returns a new instance of Monitoring.
26 27 28 29 |
# File 'app/services/monitoring.rb', line 26 def initialize(opts) @proxy = opts.fetch(:monitoring_proxy) @proxy_api = ProxyAPI::Monitoring.new(:url => proxy.url) end |
Instance Attribute Details
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
16 17 18 |
# File 'app/services/monitoring.rb', line 16 def proxy @proxy end |
#proxy_api ⇒ Object (readonly)
Returns the value of attribute proxy_api.
16 17 18 |
# File 'app/services/monitoring.rb', line 16 def proxy_api @proxy_api end |
Class Method Details
.create_action?(action) ⇒ Boolean
18 19 20 |
# File 'app/services/monitoring.rb', line 18 def self.create_action?(action) Setting[:monitoring_create_action] == action.to_s end |
.delete_action?(action) ⇒ Boolean
22 23 24 |
# File 'app/services/monitoring.rb', line 22 def self.delete_action?(action) Setting[:monitoring_delete_action] == action.to_s end |
Instance Method Details
#create_host(host) ⇒ Object
39 40 41 |
# File 'app/services/monitoring.rb', line 39 def create_host(host) proxy_api.create_host(host.name, host.monitoring_attributes) end |
#del_downtime_host(host, options = {}) ⇒ Object
35 36 37 |
# File 'app/services/monitoring.rb', line 35 def del_downtime_host(host, = {}) proxy_api.remove_host_downtime(host.name, .merge()) end |
#delete_host(host) ⇒ Object
47 48 49 |
# File 'app/services/monitoring.rb', line 47 def delete_host(host) proxy_api.delete_host(host.name) end |
#query_host(host) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/services/monitoring.rb', line 51 def query_host(host) result = proxy_api.query_host(host.name) return {} unless result { :attrs => result } end |
#set_downtime_host(host, options = {}) ⇒ Object
31 32 33 |
# File 'app/services/monitoring.rb', line 31 def set_downtime_host(host, = {}) proxy_api.create_host_downtime(host.name, .merge()) end |
#update_host(host) ⇒ Object
43 44 45 |
# File 'app/services/monitoring.rb', line 43 def update_host(host) proxy_api.update_host(host.name, host.monitoring_attributes) end |