Class: Nagira::Servicegroup

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

Defined Under Namespace

Classes: Member

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Servicegroup) initialize(name)

Returns a new instance of Servicegroup



30
31
32
# File 'lib/nagira/servicegroup.rb', line 30

def initialize(name)
  @name = name
end

Instance Attribute Details

- (Object) name (readonly)

Returns the value of attribute name



33
34
35
# File 'lib/nagira/servicegroup.rb', line 33

def name
  @name
end

Instance Method Details

- (Object) by_hostname Also known as: list



49
50
51
52
53
54
55
# File 'lib/nagira/servicegroup.rb', line 49

def by_hostname
  members.inject({ }) do |memo,item|
    memo[item.hostname] ||= []
    memo[item.hostname] << item.servicename
    memo
  end
end

- (Object) members



43
44
45
46
47
# File 'lib/nagira/servicegroup.rb', line 43

def members
  servicegroup[:members].split(/\s+/).map do |mem|
    Member.new(mem)
  end
end

- (Object) objects



35
36
37
# File 'lib/nagira/servicegroup.rb', line 35

def objects
  @objects ||= $nagios[:objects].objects
end

- (Object) output(type)



58
59
60
61
62
63
64
65
# File 'lib/nagira/servicegroup.rb', line 58

def output(type)
  members.reduce({  }) do |memo,member|
    h,s = member.hostname, member.servicename
    memo[h] ||= {  }
    memo[h][s] = member.send(type)
    memo
  end
end

- (Object) servicegroup



39
40
41
# File 'lib/nagira/servicegroup.rb', line 39

def servicegroup
  objects[:servicegroup][name]
end

- (Object) state

Shortened status informaation. Only :host_name, :service_description, :current_state



75
76
77
# File 'lib/nagira/servicegroup.rb', line 75

def state
  output(:state)
end

- (Object) status Also known as: normal



67
68
69
# File 'lib/nagira/servicegroup.rb', line 67

def status
  output(:status)
end