sos 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sos/openstack.rb +2 -0
- data/lib/sos/services.rb +14 -20
- data/lib/sos.rb +22 -24
- 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: 26dc01c8e7b2c3e12c88b1149b92cf2929de21a6
|
4
|
+
data.tar.gz: 1c13e9ac17fdf66a863a98d6ab1c6f54d40f8ec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d8abf56d44180ce27565623a58e0ce3df29f73c21ea473150784b62b2394c57bcfa8ddf92bdac74154cb240b07d7c898878a661261dd5ba08702dda2cf8325
|
7
|
+
data.tar.gz: 401e8211165f988a57078724c32ed72bfcf1b91366726b6faec0f9b4fd705a97d1e1c11565652021a45276eda7b38cd064687ceb4aad6e3bb8cf7cd0c708e7a9
|
data/lib/sos/openstack.rb
CHANGED
@@ -12,6 +12,7 @@ module OpenStack
|
|
12
12
|
'openstack-ceilometer-api' => ["#{VarLog}/ceilometer/api.log"],
|
13
13
|
'openstack-ceilometer-central' => ["#{VarLog}/ceilometer/central.log"],
|
14
14
|
'openstack-ceilometer-collector' => ["#{VarLog}/ceilometer/collector.log"],
|
15
|
+
'openstack-ceilometer-compute' => ["#{VarLog}/ceilometer/compute.log"],
|
15
16
|
'openstack-cinder-api' => ["#{VarLog}/cinder/api.log"],
|
16
17
|
'openstack-cinder-scheduler' => ["#{VarLog}/cinder/api.log"],
|
17
18
|
'openstack-cinder-volume' => ["#{VarLog}/cinder/api.log"],
|
@@ -27,6 +28,7 @@ module OpenStack
|
|
27
28
|
'openstack-nova-conductor' => ["#{VarLog}/nova/conductor.log"],
|
28
29
|
'openstack-nova-console' => ["#{VarLog}/nova/console.log"],
|
29
30
|
'openstack-nova-consoleauth' => ["#{VarLog}/nova/consoleauth.log"],
|
31
|
+
'openstack-nova-metadata-api' => ["#{VarLog}/nova/metadata-api.log"],
|
30
32
|
'openstack-nova-novncproxy' => [""],
|
31
33
|
'openstack-nova-scheduler' => ["#{VarLog}/nova/scheduler.log"],
|
32
34
|
}
|
data/lib/sos/services.rb
CHANGED
@@ -3,16 +3,12 @@ class Service
|
|
3
3
|
|
4
4
|
def initialize(name, state, logs)
|
5
5
|
@name = name
|
6
|
-
|
7
|
-
@state = true
|
8
|
-
else
|
9
|
-
@state = false
|
10
|
-
end
|
6
|
+
@state = state =~ /on/i ? true : false
|
11
7
|
@logs = logs
|
12
8
|
end
|
13
9
|
|
14
10
|
def has?(filter)
|
15
|
-
|
11
|
+
@name =~ /#{filter}/ ? true : false
|
16
12
|
end
|
17
13
|
|
18
14
|
def to_s
|
@@ -21,37 +17,35 @@ class Service
|
|
21
17
|
end
|
22
18
|
|
23
19
|
class Services
|
24
|
-
def initialize(
|
20
|
+
def initialize(selector, run_level, filters, loglist)
|
25
21
|
@services = []
|
26
22
|
|
27
|
-
|
28
|
-
|
23
|
+
installed = %x{chkconfig --list | awk '#{selector} {print $1":"$#{run_level+2}}'}
|
24
|
+
installed.each { |line|
|
29
25
|
line_tab = line.chop.split(':')
|
30
26
|
name = line_tab[0]
|
31
27
|
state = line_tab[2]
|
32
|
-
|
28
|
+
log = loglist[name] ? loglist[name] : ''
|
29
|
+
@services << Service.new(name, state, log)
|
33
30
|
}
|
31
|
+
|
32
|
+
if filters
|
33
|
+
services_all = @services
|
34
|
+
@services = services_all.get_by_name(filters)
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def get_by_name(filters)
|
37
39
|
list = []
|
38
40
|
filters.each { |filter|
|
39
41
|
@services.each { |service|
|
40
|
-
list << service
|
42
|
+
list << service if @service.has?(filter)
|
41
43
|
}
|
42
44
|
}
|
43
45
|
list
|
44
46
|
end
|
45
47
|
|
46
|
-
def
|
47
|
-
list = []
|
48
|
-
@services.each { |service|
|
49
|
-
list << service.name
|
50
|
-
}
|
51
|
-
list
|
52
|
-
end
|
53
|
-
|
54
|
-
def enabled
|
48
|
+
def get_enabled
|
55
49
|
list = []
|
56
50
|
@services.each { |service|
|
57
51
|
list << service if service.state
|
data/lib/sos.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
=begin
|
2
|
-
* Name:
|
1
|
+
=begin rdoc
|
2
|
+
* Name: sos
|
3
3
|
* Description: OpenStack services and logs tool for Red Hat OSes familly
|
4
|
-
* URL: https://github.com/gildub/
|
4
|
+
* URL: https://github.com/gildub/sos
|
5
5
|
* Date: 29 Nov 2013
|
6
6
|
* Author: Gilles Dubreuil <gilles@redhat.com>
|
7
|
-
* License:
|
8
|
-
=end
|
9
|
-
|
10
|
-
=begin rdoc
|
7
|
+
* License: GNU GPLv3
|
11
8
|
=end
|
12
9
|
|
13
10
|
require 'sos/services'
|
@@ -15,12 +12,12 @@ require 'sos/openstack'
|
|
15
12
|
|
16
13
|
SYNTAX =
|
17
14
|
%s{Usage:
|
18
|
-
os [-
|
19
|
-
os [-
|
20
|
-
os [-
|
21
|
-
os [-
|
22
|
-
os [-
|
23
|
-
os [-
|
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>]
|
24
21
|
os help
|
25
22
|
|
26
23
|
Options:
|
@@ -40,10 +37,10 @@ Commands:
|
|
40
37
|
|
41
38
|
class Syntax
|
42
39
|
def initialize(line)
|
43
|
-
@command =
|
40
|
+
@command = ''
|
44
41
|
@options = {
|
45
42
|
:runlevel => 3,
|
46
|
-
:
|
43
|
+
:selector => '/neutron|openstack/',
|
47
44
|
:all => false }
|
48
45
|
@arguments = []
|
49
46
|
|
@@ -51,9 +48,9 @@ class Syntax
|
|
51
48
|
case line[0]
|
52
49
|
when '-a', '--all'
|
53
50
|
@options[:all] = true
|
54
|
-
when '-
|
51
|
+
when '-s', '--selector'
|
55
52
|
line.shift
|
56
|
-
@options[:
|
53
|
+
@options[:selector] = line[0]
|
57
54
|
when '-r', '--run_level'
|
58
55
|
line.shift
|
59
56
|
@options[:runlevel] = line[0].to_i
|
@@ -67,26 +64,27 @@ class Syntax
|
|
67
64
|
end
|
68
65
|
line.shift
|
69
66
|
end
|
67
|
+
self.usage unless @command
|
70
68
|
end
|
71
69
|
|
72
70
|
def run
|
73
|
-
@services = Services.new(@options[:
|
71
|
+
@services = Services.new(@options[:selector], @options[:runlevel], @arguments, OpenStack::LOGS)
|
74
72
|
|
75
73
|
case @command
|
76
74
|
when /status/i, /start/i, /stop/i, /restart/i
|
77
|
-
@services.
|
75
|
+
@services.get_enabled.each { |service|
|
78
76
|
system("service #{service.name} #{@command}")
|
79
|
-
|
77
|
+
}
|
80
78
|
when /logs/i
|
81
79
|
logs = ''
|
82
|
-
@services.
|
80
|
+
@services.get_enabled.each { |service|
|
83
81
|
logs << service.logs.join(' ') + ' '
|
84
|
-
|
82
|
+
}
|
85
83
|
exec("tail -f #{logs}") if logs
|
86
84
|
when /list/i
|
87
|
-
@services.
|
85
|
+
@services.get_enabled.each { |service|
|
88
86
|
puts service.name
|
89
|
-
|
87
|
+
}
|
90
88
|
when 'test'
|
91
89
|
p self
|
92
90
|
end
|