cpu 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/cpu.gemspec +30 -26
- data/lib/cpu.rb +2 -1
- data/lib/cpu/processor.rb +1 -1
- data/lib/cpu/shared.rb +2 -2
- data/lib/cpu/version.rb +2 -2
- data/tests/load_test.rb +18 -17
- data/tests/msr_test.rb +3 -3
- data/tests/test_helper.rb +1 -0
- data/tests/usage_test.rb +2 -3
- metadata +55 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 806969485e2bd64b7d050da733a6b1f2905ac99c20163d2b8ecfa9758ced2ebc
|
4
|
+
data.tar.gz: b80fcf19ffee1a6c551832ae7ebf0dae7c362685c5135625c1f6c9f2902efce2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b66d556f6a7116c2dabfc544e15fa59f935134e8c3d2eb7eb46da7cb4a93fa284da82e1b2d63f1b89b43625d9c8d8c7f17edc53b4169070787d9246fe164fdff
|
7
|
+
data.tar.gz: 20da7779ca594c1cebc41e40a5b526569cede51b7dd7a6309655802b4e30a6a59aed6b7ca3f484ca1a05d1e4eb28ad24e68016f8255c60df4d86ea321656d5e1
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ GemHadar do
|
|
7
7
|
path_module 'CPU'
|
8
8
|
author 'Florian Frank'
|
9
9
|
email 'flori@ping.de'
|
10
|
-
homepage "
|
10
|
+
homepage "https://github.com/flori/#{name}"
|
11
11
|
summary 'CPU information in Ruby/Linux'
|
12
12
|
description 'Library to gather CPU information (load averages, usage,'\
|
13
13
|
' temperature) in Ruby on Linux'
|
@@ -17,7 +17,8 @@ GemHadar do
|
|
17
17
|
readme 'README.rdoc'
|
18
18
|
executables 'coretemp'
|
19
19
|
|
20
|
-
|
20
|
+
development_dependency 'rake'
|
21
|
+
dependency 'tins', '~>1.0'
|
21
22
|
dependency 'more_math', '~>0.0'
|
22
23
|
|
23
24
|
install_library do
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/cpu.gemspec
CHANGED
@@ -1,39 +1,43 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: cpu 0.0.6 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
|
-
s.name = "cpu"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.name = "cpu".freeze
|
6
|
+
s.version = "0.0.6"
|
6
7
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.rubygems_version = "
|
19
|
-
s.summary = "CPU information in Ruby/Linux"
|
20
|
-
s.test_files = ["tests/msr_test.rb", "tests/
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["Florian Frank".freeze]
|
11
|
+
s.date = "2018-07-21"
|
12
|
+
s.description = "Library to gather CPU information (load averages, usage, temperature) in Ruby on Linux".freeze
|
13
|
+
s.email = "flori@ping.de".freeze
|
14
|
+
s.executables = ["coretemp".freeze]
|
15
|
+
s.extra_rdoc_files = ["README.rdoc".freeze, "lib/cpu.rb".freeze, "lib/cpu/load.rb".freeze, "lib/cpu/msr.rb".freeze, "lib/cpu/processor.rb".freeze, "lib/cpu/shared.rb".freeze, "lib/cpu/usage.rb".freeze, "lib/cpu/usage_sampler.rb".freeze, "lib/cpu/version.rb".freeze]
|
16
|
+
s.files = [".gitignore".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.rdoc".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/coretemp".freeze, "cpu.gemspec".freeze, "lib/cpu.rb".freeze, "lib/cpu/load.rb".freeze, "lib/cpu/msr.rb".freeze, "lib/cpu/processor.rb".freeze, "lib/cpu/shared.rb".freeze, "lib/cpu/usage.rb".freeze, "lib/cpu/usage_sampler.rb".freeze, "lib/cpu/version.rb".freeze, "munin/coretemp".freeze, "tests/load_test.rb".freeze, "tests/msr_test.rb".freeze, "tests/test_helper.rb".freeze, "tests/usage_test.rb".freeze]
|
17
|
+
s.homepage = "https://github.com/flori/cpu".freeze
|
18
|
+
s.rdoc_options = ["--title".freeze, "Cpu - CPU information in Ruby/Linux".freeze, "--main".freeze, "README.rdoc".freeze]
|
19
|
+
s.rubygems_version = "2.7.3".freeze
|
20
|
+
s.summary = "CPU information in Ruby/Linux".freeze
|
21
|
+
s.test_files = ["tests/load_test.rb".freeze, "tests/msr_test.rb".freeze, "tests/test_helper.rb".freeze, "tests/usage_test.rb".freeze]
|
21
22
|
|
22
23
|
if s.respond_to? :specification_version then
|
23
|
-
s.specification_version =
|
24
|
+
s.specification_version = 4
|
24
25
|
|
25
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_development_dependency(%q<gem_hadar
|
27
|
-
s.
|
28
|
-
s.add_runtime_dependency(%q<
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
28
|
+
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
|
29
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"])
|
30
|
+
s.add_runtime_dependency(%q<more_math>.freeze, ["~> 0.0"])
|
29
31
|
else
|
30
|
-
s.add_dependency(%q<gem_hadar
|
31
|
-
s.add_dependency(%q<
|
32
|
-
s.add_dependency(%q<
|
32
|
+
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
33
|
+
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
34
|
+
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
35
|
+
s.add_dependency(%q<more_math>.freeze, ["~> 0.0"])
|
33
36
|
end
|
34
37
|
else
|
35
|
-
s.add_dependency(%q<gem_hadar
|
36
|
-
s.add_dependency(%q<
|
37
|
-
s.add_dependency(%q<
|
38
|
+
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
39
|
+
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
40
|
+
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
41
|
+
s.add_dependency(%q<more_math>.freeze, ["~> 0.0"])
|
38
42
|
end
|
39
43
|
end
|
data/lib/cpu.rb
CHANGED
@@ -120,7 +120,7 @@ module CPU
|
|
120
120
|
# sum up the CPU usage in this instance.
|
121
121
|
def sum_usage_processor(interval = 1, &block)
|
122
122
|
processors = usage(interval, &block)
|
123
|
-
processor = Processor.new
|
123
|
+
processor = Processor.new(-1, -1)
|
124
124
|
processor.num_processors = processor.num_cores = 1
|
125
125
|
begin
|
126
126
|
processor.temperature = processors.map(&:temperature).max
|
@@ -134,3 +134,4 @@ module CPU
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
137
|
+
CPU::MSR.load_module
|
data/lib/cpu/processor.rb
CHANGED
@@ -56,7 +56,7 @@ module CPU
|
|
56
56
|
# to the correct value for your Processor. On i7 architectures (and newer?)
|
57
57
|
# it should work without any further configuration.
|
58
58
|
def temperature
|
59
|
-
if @temperature
|
59
|
+
if defined?(@temperature)
|
60
60
|
@temperature
|
61
61
|
else
|
62
62
|
my_t_j_max = t_j_max.nonzero? || CPU.t_j_max
|
data/lib/cpu/shared.rb
CHANGED
@@ -2,7 +2,7 @@ module CPU
|
|
2
2
|
module Shared
|
3
3
|
# Returns the number of processors in this computer
|
4
4
|
def num_processors
|
5
|
-
if @num_processors
|
5
|
+
if defined?(@num_processors)
|
6
6
|
@num_processors
|
7
7
|
else
|
8
8
|
CPU.num_processors
|
@@ -15,7 +15,7 @@ module CPU
|
|
15
15
|
|
16
16
|
# Returns the number of cores in this computer
|
17
17
|
def num_cores
|
18
|
-
if @num_cores
|
18
|
+
if defined?(@num_cores)
|
19
19
|
@num_cores
|
20
20
|
else
|
21
21
|
CPU.num_cores
|
data/lib/cpu/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module CPU
|
2
2
|
# CPU version
|
3
|
-
VERSION = '0.0.
|
4
|
-
VERSION_ARRAY = VERSION.split(
|
3
|
+
VERSION = '0.0.6'
|
4
|
+
VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
|
5
5
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
6
6
|
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
7
7
|
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
data/tests/load_test.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
require '
|
2
|
-
require 'mocha'
|
1
|
+
require 'test_helper'
|
3
2
|
require 'cpu'
|
4
3
|
|
5
4
|
module CPU
|
6
|
-
class LoadTest < Test
|
5
|
+
class LoadTest < Minitest::Test
|
7
6
|
def test_load_minutes
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
CPU.stub :num_processors, 4 do
|
8
|
+
CPU.stub :num_cores, 2 do
|
9
|
+
@load = CPU.load
|
10
|
+
for v in %w[last_minute last_5_minutes last_15_minutes]
|
11
|
+
assert_kind_of Float, @load.__send__(v)
|
12
|
+
assert_operator @load.__send__(v), :>=, 0
|
13
|
+
assert_in_delta\
|
14
|
+
4 * @load.__send__("#{v}_by_processor"),
|
15
|
+
@load.__send__(v),
|
16
|
+
1E-3
|
17
|
+
assert_in_delta\
|
18
|
+
2 * @load.__send__("#{v}_by_core"),
|
19
|
+
@load.__send__(v),
|
20
|
+
1E-3
|
21
|
+
end
|
22
|
+
end
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
data/tests/msr_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
require 'cpu'
|
3
3
|
|
4
4
|
module CPU
|
5
|
-
class MSRTest < Test
|
5
|
+
class MSRTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@cpu0, @cpu1 = CPU.to_a
|
8
8
|
end
|
@@ -24,7 +24,7 @@ module CPU
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_wrong_processor_id
|
27
|
-
|
27
|
+
assert_raises(InvalidProcessorIdError) do
|
28
28
|
CPU::MSR.new(CPU.num_processors)
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'minitest/autorun'
|
data/tests/usage_test.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require 'mocha'
|
1
|
+
require 'test_helper'
|
3
2
|
require 'cpu'
|
4
3
|
|
5
4
|
module CPU
|
6
|
-
class UsageTest < Test
|
5
|
+
class UsageTest < Minitest::Test
|
7
6
|
def test_sum_usage
|
8
7
|
@processor = CPU.sum_usage_processor 1
|
9
8
|
assert_kind_of Processor, @processor
|
metadata
CHANGED
@@ -1,49 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Florian Frank
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-07-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: gem_hadar
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 1.9.1
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.9.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
42
|
name: tins
|
27
|
-
requirement:
|
28
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
29
44
|
requirements:
|
30
|
-
- - ~>
|
45
|
+
- - "~>"
|
31
46
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0
|
47
|
+
version: '1.0'
|
33
48
|
type: :runtime
|
34
49
|
prerelease: false
|
35
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
36
55
|
- !ruby/object:Gem::Dependency
|
37
56
|
name: more_math
|
38
|
-
requirement:
|
39
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
40
58
|
requirements:
|
41
|
-
- - ~>
|
59
|
+
- - "~>"
|
42
60
|
- !ruby/object:Gem::Version
|
43
61
|
version: '0.0'
|
44
62
|
type: :runtime
|
45
63
|
prerelease: false
|
46
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.0'
|
47
69
|
description: Library to gather CPU information (load averages, usage, temperature)
|
48
70
|
in Ruby on Linux
|
49
71
|
email: flori@ping.de
|
@@ -53,15 +75,15 @@ extensions: []
|
|
53
75
|
extra_rdoc_files:
|
54
76
|
- README.rdoc
|
55
77
|
- lib/cpu.rb
|
56
|
-
- lib/cpu/version.rb
|
57
|
-
- lib/cpu/usage.rb
|
58
|
-
- lib/cpu/processor.rb
|
59
78
|
- lib/cpu/load.rb
|
60
79
|
- lib/cpu/msr.rb
|
61
|
-
- lib/cpu/
|
80
|
+
- lib/cpu/processor.rb
|
62
81
|
- lib/cpu/shared.rb
|
82
|
+
- lib/cpu/usage.rb
|
83
|
+
- lib/cpu/usage_sampler.rb
|
84
|
+
- lib/cpu/version.rb
|
63
85
|
files:
|
64
|
-
- .gitignore
|
86
|
+
- ".gitignore"
|
65
87
|
- CHANGES
|
66
88
|
- COPYING
|
67
89
|
- Gemfile
|
@@ -81,36 +103,37 @@ files:
|
|
81
103
|
- munin/coretemp
|
82
104
|
- tests/load_test.rb
|
83
105
|
- tests/msr_test.rb
|
106
|
+
- tests/test_helper.rb
|
84
107
|
- tests/usage_test.rb
|
85
|
-
homepage:
|
108
|
+
homepage: https://github.com/flori/cpu
|
86
109
|
licenses: []
|
110
|
+
metadata: {}
|
87
111
|
post_install_message:
|
88
112
|
rdoc_options:
|
89
|
-
- --title
|
113
|
+
- "--title"
|
90
114
|
- Cpu - CPU information in Ruby/Linux
|
91
|
-
- --main
|
115
|
+
- "--main"
|
92
116
|
- README.rdoc
|
93
117
|
require_paths:
|
94
118
|
- lib
|
95
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
120
|
requirements:
|
98
|
-
- -
|
121
|
+
- - ">="
|
99
122
|
- !ruby/object:Gem::Version
|
100
123
|
version: '0'
|
101
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
125
|
requirements:
|
104
|
-
- -
|
126
|
+
- - ">="
|
105
127
|
- !ruby/object:Gem::Version
|
106
128
|
version: '0'
|
107
129
|
requirements: []
|
108
130
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
131
|
+
rubygems_version: 2.7.3
|
110
132
|
signing_key:
|
111
|
-
specification_version:
|
133
|
+
specification_version: 4
|
112
134
|
summary: CPU information in Ruby/Linux
|
113
135
|
test_files:
|
114
|
-
- tests/msr_test.rb
|
115
136
|
- tests/load_test.rb
|
137
|
+
- tests/msr_test.rb
|
138
|
+
- tests/test_helper.rb
|
116
139
|
- tests/usage_test.rb
|