sos 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sos/services.rb +13 -8
  3. data/lib/sos.rb +11 -11
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26dc01c8e7b2c3e12c88b1149b92cf2929de21a6
4
- data.tar.gz: 1c13e9ac17fdf66a863a98d6ab1c6f54d40f8ec6
3
+ metadata.gz: ad0885a599816659fb4e27200209a18edda7ac2c
4
+ data.tar.gz: 1811357a7edc155cd8bf09d6e08cb6935ed14350
5
5
  SHA512:
6
- metadata.gz: 27d8abf56d44180ce27565623a58e0ce3df29f73c21ea473150784b62b2394c57bcfa8ddf92bdac74154cb240b07d7c898878a661261dd5ba08702dda2cf8325
7
- data.tar.gz: 401e8211165f988a57078724c32ed72bfcf1b91366726b6faec0f9b4fd705a97d1e1c11565652021a45276eda7b38cd064687ceb4aad6e3bb8cf7cd0c708e7a9
6
+ metadata.gz: f750b1be36fb3eda4256995e5a891a114c95684a64e90880bc104f87c2ef2c948763dcd65f7f0847aa7c4d08a5dc298d54edebb69283b6547b8f145300177e05
7
+ data.tar.gz: c6c6493b1385cd954cb2d8d2432cc3507093d4da29b4fa4aff9a8c869cfa0e2f83432b83c19fdf7b7c3399e0d2f05c2b704674edee6c5689e423c9c898456e04
data/lib/sos/services.rb CHANGED
@@ -20,22 +20,27 @@ class Services
20
20
  def initialize(selector, run_level, filters, loglist)
21
21
  @services = []
22
22
 
23
- installed = %x{chkconfig --list | awk '#{selector} {print $1":"$#{run_level+2}}'}
24
- installed.each { |line|
23
+ list = %x{chkconfig --list | awk '#{selector} {print $1":"$#{run_level+2}}'}
24
+
25
+ if filters != []
26
+ filtered = ''
27
+ list.each { |line|
28
+ filters.each { |filter| filtered << line if line =~ /#{filter}/ }
29
+ }
30
+ list = filtered
31
+ end
32
+
33
+ list.each { |line|
25
34
  line_tab = line.chop.split(':')
26
35
  name = line_tab[0]
27
36
  state = line_tab[2]
28
37
  log = loglist[name] ? loglist[name] : ''
29
38
  @services << Service.new(name, state, log)
30
39
  }
31
-
32
- if filters
33
- services_all = @services
34
- @services = services_all.get_by_name(filters)
35
- end
36
40
  end
37
41
 
38
42
  def get_by_name(filters)
43
+ return @services
39
44
  list = []
40
45
  filters.each { |filter|
41
46
  @services.each { |service|
@@ -45,7 +50,7 @@ class Services
45
50
  list
46
51
  end
47
52
 
48
- def get_enabled
53
+ def enabled
49
54
  list = []
50
55
  @services.each { |service|
51
56
  list << service if service.state
data/lib/sos.rb CHANGED
@@ -12,13 +12,13 @@ require 'sos/openstack'
12
12
 
13
13
  SYNTAX =
14
14
  %s{Usage:
15
- os [-sr] list
16
- os [-sr] logs [<SERVICE>] ... [<SERVICE>]
17
- os [-sr] restart [<SERVICE>] ... [<SERVICE>]
18
- os [-sr] start [<SERVICE>] ... [<SERVICE>]
19
- os [-sr] satus [<SERVICE>] ... [<SERVICE>]
20
- os [-sr] stop [<SERVICE>] ... [<SERVICE>]
21
- os help
15
+ sos [-sr] list
16
+ sos [-sr] logs [<SERVICE>] ... [<SERVICE>]
17
+ sos [-sr] restart [<SERVICE>] ... [<SERVICE>]
18
+ sos [-sr] start [<SERVICE>] ... [<SERVICE>]
19
+ sos [-sr] satus [<SERVICE>] ... [<SERVICE>]
20
+ sos [-sr] stop [<SERVICE>] ... [<SERVICE>]
21
+ sos help
22
22
 
23
23
  Options:
24
24
  -r, --runlevel <RUNLEVEL> Change run-level. Default is level 3.
@@ -68,21 +68,21 @@ class Syntax
68
68
  end
69
69
 
70
70
  def run
71
- @services = Services.new(@options[:selector], @options[:runlevel], @arguments, OpenStack::LOGS)
71
+ services = Services.new(@options[:selector], @options[:runlevel], @arguments, OpenStack::LOGS)
72
72
 
73
73
  case @command
74
74
  when /status/i, /start/i, /stop/i, /restart/i
75
- @services.get_enabled.each { |service|
75
+ services.enabled.each { |service|
76
76
  system("service #{service.name} #{@command}")
77
77
  }
78
78
  when /logs/i
79
79
  logs = ''
80
- @services.get_enabled.each { |service|
80
+ services.enabled.each { |service|
81
81
  logs << service.logs.join(' ') + ' '
82
82
  }
83
83
  exec("tail -f #{logs}") if logs
84
84
  when /list/i
85
- @services.get_enabled.each { |service|
85
+ services.enabled.each { |service|
86
86
  puts service.name
87
87
  }
88
88
  when 'test'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil