Class: Services

Inherits:
Object
  • Object
show all
Defined in:
lib/sos/services.rb

Instance Method Summary collapse

Constructor Details

#initialize(filter, run_level, logs) ⇒ Services

Returns a new instance of Services.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sos/services.rb', line 24

def initialize(filter, run_level, logs)
  @services = []

  list = %x{chkconfig --list | awk '#{filter} {print $1":"$#{run_level+2}}'}
  list.each  { |line|
    line_tab = line.chop.split(':')
    name = line_tab[0]
    state = line_tab[2]
    @services << Service.new(name, state, logs[name])
  }
end

Instance Method Details

#enabledObject



54
55
56
57
58
59
60
# File 'lib/sos/services.rb', line 54

def enabled
  list = []
  @services.each { |service|
    list << service if service.state
  }
  list
end

#get_by_name(filters) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/sos/services.rb', line 36

def get_by_name(filters)
  list = []
  filters.each { |filter|
    @services.each { |service|
      list << service.name if @service.has?(filter)
    }
  }
  list
end

#get_by_name_allObject



46
47
48
49
50
51
52
# File 'lib/sos/services.rb', line 46

def get_by_name_all
  list = []
  @services.each { |service|
    list << service.name
  }
  list
end