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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e28dbed2c23e3c687979de1935f3af789c9149bb
4
- data.tar.gz: d2e1c03f241f4e240096e9b13afcc7795084a6fe
3
+ metadata.gz: 26dc01c8e7b2c3e12c88b1149b92cf2929de21a6
4
+ data.tar.gz: 1c13e9ac17fdf66a863a98d6ab1c6f54d40f8ec6
5
5
  SHA512:
6
- metadata.gz: d792f0a6a1c714e1342676ccc78b9a371c728c9b8b073f90d7fb7fef76b51d2c66beafa2d9993ea110eb3bf8df18b7943132fee5a35c0619165694633c1e4da0
7
- data.tar.gz: 4495b940bf93e2303d1a4226597ca27421c0c916d4dfe999cc8edfd606f7a2cee827c3a9b837d45104042b18da906373e44d97bf7212f687b1f59999dd93ed99
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
- if state =~ /on/i
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
- true if @name =~ /#{filter}/
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(filter, run_level, logs)
20
+ def initialize(selector, run_level, filters, loglist)
25
21
  @services = []
26
22
 
27
- list = %x{chkconfig --list | awk '#{filter} {print $1":"$#{run_level+2}}'}
28
- list.each { |line|
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
- @services << Service.new(name, state, logs[name])
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.name if @service.has?(filter)
42
+ list << service if @service.has?(filter)
41
43
  }
42
44
  }
43
45
  list
44
46
  end
45
47
 
46
- def get_by_name_all
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 header
2
- * Name: os
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/os
4
+ * URL: https://github.com/gildub/sos
5
5
  * Date: 29 Nov 2013
6
6
  * Author: Gilles Dubreuil <gilles@redhat.com>
7
- * License: Copyright 2011, 2013 Gilles Dubreuil
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 [-fr] list
19
- os [-fr] logs [<SERVICE>] ... [<SERVICE>]
20
- os [-fr] restart [<SERVICE>] ... [<SERVICE>]
21
- os [-fr] start [<SERVICE>] ... [<SERVICE>]
22
- os [-fr] satus [<SERVICE>] ... [<SERVICE>]
23
- os [-fr] stop [<SERVICE>] ... [<SERVICE>]
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
- :filter => '/neutron|openstack/',
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 '-f', '--filter'
51
+ when '-s', '--selector'
55
52
  line.shift
56
- @options[:filter] = line[0]
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[:filter], @options[:runlevel], OpenStack::LOGS)
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.enabled.each do |service|
75
+ @services.get_enabled.each { |service|
78
76
  system("service #{service.name} #{@command}")
79
- end
77
+ }
80
78
  when /logs/i
81
79
  logs = ''
82
- @services.enabled.each do |service|
80
+ @services.get_enabled.each { |service|
83
81
  logs << service.logs.join(' ') + ' '
84
- end
82
+ }
85
83
  exec("tail -f #{logs}") if logs
86
84
  when /list/i
87
- @services.enabled.each do |service|
85
+ @services.get_enabled.each { |service|
88
86
  puts service.name
89
- end
87
+ }
90
88
  when 'test'
91
89
  p self
92
90
  end
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil