Class: Nagira::ServiceStatusController
- Inherits:
-
Object
- Object
- Nagira::ServiceStatusController
- Includes:
- HostStatusNameConcerneable, OutputTypeable
- Defined in:
- app/controllers/service_status_controler.rb
Instance Attribute Summary
Attributes included from HostStatusNameConcerneable
#hostname, #resource, #service_name
Instance Method Summary collapse
-
#get ⇒ Object
Read all statuses of the hosts’ services.
-
#initialize(nagios_status, output: nil, hostname: nil, service_name: nil) ⇒ ServiceStatusController
constructor
A new instance of ServiceStatusController.
- #put(params) ⇒ Object
- #with_service_and_host(params) ⇒ Object
Methods included from HostStatusNameConcerneable
Methods included from OutputTypeable
#body_with_list, #full?, #list?, #state?
Constructor Details
#initialize(nagios_status, output: nil, hostname: nil, service_name: nil) ⇒ ServiceStatusController
Returns a new instance of ServiceStatusController.
10 11 12 13 14 15 16 17 |
# File 'app/controllers/service_status_controler.rb', line 10 def initialize(nagios_status, output: nil, hostname: nil, service_name: nil) @nagios_status = nagios_status @output = output @hostname = hostname @service_name = service_name @resource = "servicestatus" end |
Instance Method Details
#get ⇒ Object
Read all statuses of the hosts’ services. Format output: full service state hash, or state only: name and state.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/service_status_controler.rb', line 21 def get case when state? with_service_name .values .first .slice("host_name", "current_state") else with_service_name end end |
#put(params) ⇒ Object
33 34 35 |
# File 'app/controllers/service_status_controler.rb', line 33 def put(params) Writer.new(:PROCESS_SERVICE_CHECK_RESULT).put with_service_and_host(params) end |
#with_service_and_host(params) ⇒ Object
37 38 39 40 41 42 |
# File 'app/controllers/service_status_controler.rb', line 37 def with_service_and_host(params) params.merge({ 'service_description' => @service_name, 'host_name' => @hostname }) end |