sos 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sos/services.rb +13 -8
- data/lib/sos.rb +11 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad0885a599816659fb4e27200209a18edda7ac2c
|
4
|
+
data.tar.gz: 1811357a7edc155cd8bf09d6e08cb6935ed14350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
24
|
-
|
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
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
75
|
+
services.enabled.each { |service|
|
76
76
|
system("service #{service.name} #{@command}")
|
77
77
|
}
|
78
78
|
when /logs/i
|
79
79
|
logs = ''
|
80
|
-
|
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
|
-
|
85
|
+
services.enabled.each { |service|
|
86
86
|
puts service.name
|
87
87
|
}
|
88
88
|
when 'test'
|