mool 3.0.1 → 3.0.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
- ---
2
- SHA512:
3
- data.tar.gz: 83945122ab24e7570389494da0c0bb08edc9b539491abceb5e323d4bcdbe3778ed906e36386057cb8d5ef67ef59d60ad350df9003347049157dfea14e41dd146
4
- metadata.gz: 82afc99c49a49973608bb159f3ca1a18f1b413508bec179865b25bce6ccb3401b85fb13ec52160c43cb8550bb4de4480bceadfb62d28d7d1329a63e2b3fa3be9
5
- SHA1:
6
- data.tar.gz: ac1de01482a2aee4316ab061c0a7f34c8647d5ad
7
- metadata.gz: 1d753d3999e131e0c44b335b618fc6f7d81d431c
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c3812464b6a61004cb50688f19270a955bbe0f3
4
+ data.tar.gz: e7f68f5ee541f334c461b85b9bf229f5fb9d3d1c
5
+ SHA512:
6
+ metadata.gz: 465d925aa31816cc4996bfe07666a0791796c49ab211cc414aebbc89896d20f0cf1ff961d8c4535cd4bda1e83626dc21091d37d31e68d6b1932f8a15aeb3dd7a
7
+ data.tar.gz: '071799903439ad9539a1a8ed1644c15f98649bec02f3bac4d1228df9f2d994eed58cf01964b39fb4f12d04f5c4396a30f5a962c9787e3f334ab90f580b230717'
data/lib/mool/base.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Mool
2
+ class Base
3
+ def attrs
4
+ Hash[instance_variables.collect do |attr|
5
+ [attr.to_s.delete(':@').to_sym,
6
+ instance_variable_get(attr)]
7
+ end]
8
+ end
9
+ end
10
+ end
data/lib/mool/command.rb CHANGED
@@ -13,6 +13,10 @@ module Mool
13
13
  `df`
14
14
  end
15
15
 
16
+ def self.dev_name_command(dev_entry)
17
+ File.read("#{dev_entry}/dev")
18
+ end
19
+
16
20
  def self.mount_command
17
21
  File.read('/proc/mounts')
18
22
  end
data/lib/mool/cpu.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  module Mool
2
- class Cpu
3
- attr_reader :cpu_name,
4
- :id,
5
- :model_name,
6
- :cores,
7
- :usr,
8
- :nice,
9
- :sys,
10
- :iowait,
11
- :irq,
12
- :soft,
13
- :steal,
14
- :guest,
15
- :gnice,
16
- :idle,
17
- :total
2
+ class Cpu < Mool::Base
3
+ attr_accessor :cpu_name,
4
+ :id,
5
+ :model_name,
6
+ :cores,
7
+ :usr,
8
+ :nice,
9
+ :sys,
10
+ :iowait,
11
+ :irq,
12
+ :soft,
13
+ :steal,
14
+ :guest,
15
+ :gnice,
16
+ :idle,
17
+ :total
18
18
 
19
19
  # ["all", "1", "2"]
20
20
  def initialize(process_number, opt={})
data/lib/mool/disk.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mool
2
- class Disk
2
+ class Disk < Mool::Base
3
3
  attr_accessor :path,
4
4
  :major,
5
5
  :minor,
@@ -17,13 +17,16 @@ module Mool
17
17
  :unity
18
18
 
19
19
  def initialize(dev_name)
20
- paths = Mool::Command.dev_block_command.select do |entry|
21
- Mool::Disk.dev_name_command(entry).include?(dev_name) ||
22
- Mool::Disk.uevent_command(entry).include?(dev_name) ||
23
- Mool::Disk.logical_name_command(entry)
24
- end
20
+ @path = nil
25
21
 
26
- @path = paths.first
22
+ Mool::Command.dev_block_command.each do |entry|
23
+ logical_name = Mool::Command.logical_name_command(entry)
24
+ next unless Mool::Command.dev_name_command(entry).include?(dev_name) ||
25
+ Mool::Command.uevent_command(entry).include?(dev_name) ||
26
+ (logical_name.present? && logical_name.include?(dev_name))
27
+ @path = entry
28
+ break
29
+ end
27
30
 
28
31
  raise "Does't exist #{dev_name}!" if @path.nil?
29
32
  read_uevent
@@ -60,9 +63,13 @@ module Mool
60
63
  @major,
61
64
  @minor,
62
65
  @devname,
63
- @devtype = Mool::Command.uevent_command(@path).scan(
64
- /.*=(\d+)\n.*=(\d+)\n.*=(\S+)\n.*=(\w+)\n/
65
- ).flatten
66
+ @devtype =
67
+ Mool::Command.uevent_command(@path).split("\n").map do |result|
68
+ result.split('=').last
69
+ end
70
+ # Mool::Command.uevent_command(@path).scan(
71
+ # /.*=(\d+)\n.*=(\d+)\n.*=(\S+)\n.*=(\w+)\n/
72
+ # ).flatten
66
73
  end
67
74
 
68
75
  def dev
@@ -95,11 +102,12 @@ module Mool
95
102
  def partitions
96
103
  return @partitions if defined? @partitions
97
104
  return unless is_disk?
105
+
98
106
  @partitions = Mool::Command.partitions_command(
99
107
  @path,
100
108
  @devname
101
109
  ).map do |part|
102
- MoolDisk.new(part.split('/').last)
110
+ Mool::Disk.new(part.split('/').last)
103
111
  end
104
112
  end
105
113
 
@@ -110,7 +118,7 @@ module Mool
110
118
  end
111
119
 
112
120
  @slaves = blocks.map do |slave|
113
- MoolDisk.new(slave.split('/').last)
121
+ Mool::Disk.new(slave.split('/').last)
114
122
  end
115
123
  end
116
124
 
@@ -163,6 +171,7 @@ module Mool
163
171
  !real_path.include?('/sr') &&
164
172
  !Mool::Command.real_path_command_exist?(real_path) &&
165
173
  Mool::Command.slaves_command(real_path).empty?
174
+
166
175
  disks << Mool::Disk.new(entry.split('/').last)
167
176
  end
168
177
 
@@ -177,7 +186,7 @@ module Mool
177
186
  end
178
187
 
179
188
  def self.all_usable
180
- result = MoolDisk.all
189
+ result = Mool::Disk.all
181
190
  result.each do |disk|
182
191
  result += (disk.partitions +
183
192
  disk.slaves +
data/lib/mool/memory.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mool
2
- class Memory
2
+ class Memory < Mool::Base
3
3
 
4
4
  attr_accessor :unity, :mem_used
5
5
 
data/lib/mool/process.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Mool
2
- class Process
3
- attr_reader :messures, :pattern
2
+ class Process < Mool::Base
3
+ attr_accessor :messures, :pattern
4
4
 
5
5
  STATUS_PROCESS = {
6
6
  'D' => :uninterruptible_sleep,
@@ -9,7 +9,7 @@ module Mool
9
9
  'T' => :stopped_by_job_control_signal,
10
10
  't' => :stopped_by_debugger_during_trace,
11
11
  'Z' => :zombie
12
- }
12
+ }.freeze
13
13
 
14
14
  def initialize(name, pattern, opt = {})
15
15
  if name.class != String || pattern.class != String
data/lib/mool/system.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  module Mool
2
- class System
3
- attr_reader :kernel,
4
- :current_loadavg,
5
- :last_5min_loadavg,
6
- :last_15min_loadavg,
7
- :thread_entities_exec,
8
- :total_thread_entities,
9
- :last_pid_process_created,
10
- :uptime_day,
11
- :uptime_hour,
12
- :uptime_minute,
13
- :uptime_second
2
+ class System < Mool::Base
3
+ attr_accessor :kernel,
4
+ :current_loadavg,
5
+ :last_5min_loadavg,
6
+ :last_15min_loadavg,
7
+ :thread_entities_exec,
8
+ :total_thread_entities,
9
+ :last_pid_process_created,
10
+ :uptime_day,
11
+ :uptime_hour,
12
+ :uptime_minute,
13
+ :uptime_second
14
14
 
15
15
  def initialize
16
16
  @kernel = Mool::Command.uname_command
data/lib/mool/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mool
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
data/lib/mool.rb CHANGED
@@ -1,4 +1,5 @@
1
- %w[command
1
+ %w[base
2
+ command
2
3
  cpu
3
4
  disk
4
5
  memory
metadata CHANGED
@@ -1,57 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mool
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - g.edera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
-
12
- date: 2018-03-26 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: "1.16"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
22
20
  type: :development
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: rake
26
21
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ~>
30
- - !ruby/object:Gem::Version
31
- version: "10.0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
32
34
  type: :development
33
- version_requirements: *id002
34
- - !ruby/object:Gem::Dependency
35
- name: minitest
36
35
  prerelease: false
37
- requirement: &id003 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- version: "5.0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
42
48
  type: :development
43
- version_requirements: *id003
44
- description: "Get operative system information: Disk, Memory, Cpu, Load-average, Processes."
45
- email:
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: 'Get operative system information: Disk, Memory, Cpu, Load-average, Processes.'
56
+ email:
46
57
  - gab.edera@gmail.com
47
58
  executables: []
48
-
49
59
  extensions: []
50
-
51
60
  extra_rdoc_files: []
52
-
53
- files:
54
- - .gitignore
61
+ files:
62
+ - ".gitignore"
55
63
  - Gemfile
56
64
  - LICENSE.txt
57
65
  - README.md
@@ -61,6 +69,7 @@ files:
61
69
  - lib/locales/en.mool.yml
62
70
  - lib/locales/es.mool.yml
63
71
  - lib/mool.rb
72
+ - lib/mool/base.rb
64
73
  - lib/mool/command.rb
65
74
  - lib/mool/cpu.rb
66
75
  - lib/mool/disk.rb
@@ -70,30 +79,28 @@ files:
70
79
  - lib/mool/version.rb
71
80
  - mool.gemspec
72
81
  homepage: https://github.com/gedera/mool
73
- licenses:
82
+ licenses:
74
83
  - MIT
75
- metadata:
84
+ metadata:
76
85
  allowed_push_host: https://rubygems.org
77
86
  post_install_message:
78
87
  rdoc_options: []
79
-
80
- require_paths:
88
+ require_paths:
81
89
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
83
- requirements:
84
- - &id004
85
- - ">="
86
- - !ruby/object:Gem::Version
87
- version: "0"
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
- requirements:
90
- - *id004
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
91
100
  requirements: []
92
-
93
101
  rubyforge_project:
94
- rubygems_version: 2.6.12
102
+ rubygems_version: 2.6.14
95
103
  signing_key:
96
104
  specification_version: 4
97
105
  summary: Get operative system information (Linux).
98
106
  test_files: []
99
-