Class: Nagira::HostService

Inherits:
Object
  • Object
show all
Defined in:
lib/nagira/hostservice.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (HostService) initialize(hostname, servicename)

Returns a new instance of HostService



4
5
6
7
# File 'lib/nagira/hostservice.rb', line 4

def initialize(hostname,servicename)
  @hostname = hostname
  @servicename = servicename
end

Instance Attribute Details

- (Object) hostname (readonly)

Returns the value of attribute hostname



8
9
10
# File 'lib/nagira/hostservice.rb', line 8

def hostname
  @hostname
end

- (Object) servicename (readonly)

Returns the value of attribute servicename



8
9
10
# File 'lib/nagira/hostservice.rb', line 8

def servicename
  @servicename
end

Instance Method Details

- (Object) current_state



25
26
27
# File 'lib/nagira/hostservice.rb', line 25

def current_state
  status.slice('current_state')
end

- (Object) state



21
22
23
# File 'lib/nagira/hostservice.rb', line 21

def state
  status.slice('host_name', 'service_description', 'current_state')
end

- (Object) status Also known as: full



10
11
12
13
14
15
16
17
# File 'lib/nagira/hostservice.rb', line 10

def status
  begin
    $nagios[:status]
      .status['hosts'][hostname]['servicestatus'][servicename]
  rescue NoMethodError
    {  }
  end
end