Class: Nagira::ResourceStatusController

Inherits:
Object
  • Object
show all
Includes:
HostStatusNameConcerneable, OutputTypeable
Defined in:
app/controllers/resource_status_controler.rb

Instance Attribute Summary

Attributes included from HostStatusNameConcerneable

#hostname, #resource, #service_name

Instance Method Summary collapse

Methods included from HostStatusNameConcerneable

#status, #with_service_name

Methods included from OutputTypeable

#body_with_list, #full?, #list?, #state?

Constructor Details

#initialize(nagios_status, output: nil, hostname: nil, service_name: nil, resource: "servicestatus") ⇒ ResourceStatusController

Returns a new instance of ResourceStatusController.

Parameters:

  • nagios_status (Hash)

    output of the Nagios status file parser

  • output (Symbol(:state, :list)) (defaults to: nil)

    Output data: full, short state or list

  • hostname (String) (defaults to: nil)
  • service_name (String) (defaults to: nil)
  • resource (String) (defaults to: "servicestatus")

    Resource to be reported. Currently supported ‘servicestatus’, ‘servicecomments’, ‘hostcomments’



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/resource_status_controler.rb', line 13

def initialize(nagios_status, output: nil, hostname: nil, service_name: nil, resource: "servicestatus")

  @nagios_status = nagios_status
  @output = output
  @hostname = hostname
  @service_name = service_name
  @resource = if resource == 'services'
                "servicestatus"
              else
                resource
              end
end

Instance Method Details

#getObject

Return status of the resource



27
28
29
30
31
32
33
34
# File 'app/controllers/resource_status_controler.rb', line 27

def get
  case
  when state?; then  slice
  when list?; then  list
  else
    with_service_name
  end
end