linux-kstat 0.2.6-universal-linux → 0.2.8-universal-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +10 -0
- data/Gemfile +2 -0
- data/MANIFEST.md +1 -0
- data/README.md +7 -2
- data/Rakefile +10 -2
- data/lib/linux/kstat.rb +22 -18
- data/lib/linux-kstat.rb +2 -0
- data/linux-kstat.gemspec +18 -8
- data/spec/linux_kstat_spec.rb +23 -15
- data.tar.gz.sig +0 -0
- metadata +50 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e193e5bb9555bf697c749f74f73d5cc9d0ead99072235e027f97d9f1fed4645d
|
4
|
+
data.tar.gz: 1377fdf553ee873d8acbd40c849e55205467e443c3e41ebf697a3dcf62f9b6ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c0c13badaaaeac7de87d4c60df7d653bb739705c3a7289b709dd7f99001c8c49172429693c32a1d2983a3b793cc6efbe13917056fa9b5a25ae4fb4fe79d5d0
|
7
|
+
data.tar.gz: cadfd737b379423f7f05d7a0509b7fbfd7a7d77053bda59bd732f74d50d4b3f35652bbd867653fd0a3c2b8be2ec93b6ab994fbc9ba4d7d007ddca9e1e09ef958
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.2.8 - 13-Jun-2025
|
2
|
+
* Minor optimization where I avoid making repeated calls.
|
3
|
+
* Add a keys method delegator.
|
4
|
+
|
5
|
+
## 0.2.7 - 20-Apr-2024
|
6
|
+
* Rubocop updates.
|
7
|
+
* Spec updates.
|
8
|
+
* Gemspec updates.
|
9
|
+
* Documentation and other miscellaneous project updates.
|
10
|
+
|
1
11
|
## 0.2.6 - 10-Dec-2020
|
2
12
|
* Specify an rspec version for the development dependency.
|
3
13
|
* Minor updates to gemspec, Rakefile.
|
data/Gemfile
ADDED
data/MANIFEST.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://github.com/djberg96/linux-kstat/actions/workflows/ruby.yml)
|
2
|
+
|
1
3
|
## Description
|
2
4
|
|
3
5
|
A Ruby library for gathering Linux kernel statistics out of `/proc/stat`.
|
@@ -6,6 +8,9 @@ A Ruby library for gathering Linux kernel statistics out of `/proc/stat`.
|
|
6
8
|
|
7
9
|
`gem install linux-kstat`
|
8
10
|
|
11
|
+
## Adding the trusted cert
|
12
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/linux-kstat/main/certs/djberg96_pub.pem)`
|
13
|
+
|
9
14
|
### Bundler
|
10
15
|
|
11
16
|
If you have trouble install this gem via bundler, please try this:
|
@@ -15,7 +20,7 @@ If you have trouble install this gem via bundler, please try this:
|
|
15
20
|
Then attempt to install again.
|
16
21
|
|
17
22
|
## Synopsis
|
18
|
-
```
|
23
|
+
```ruby
|
19
24
|
# require 'linux-kstat' will also work
|
20
25
|
require 'linux/kstat'
|
21
26
|
|
@@ -49,7 +54,7 @@ Apache-2.0
|
|
49
54
|
|
50
55
|
## Copyright
|
51
56
|
|
52
|
-
(C) 2003-
|
57
|
+
(C) 2003-2024 Daniel J. Berger
|
53
58
|
All Rights Reserved.`
|
54
59
|
|
55
60
|
## Warranty
|
data/Rakefile
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
4
5
|
|
5
|
-
CLEAN.include('**/*.gem', '**/*.rbc')
|
6
|
+
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.lock')
|
6
7
|
|
7
8
|
namespace :gem do
|
8
9
|
desc 'Build the linux-kstat gem'
|
9
10
|
task :create => [:clean] do
|
10
11
|
require 'rubygems/package'
|
11
|
-
spec =
|
12
|
+
spec = Gem::Specification.load('linux-kstat.gemspec')
|
12
13
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
13
14
|
Gem::Package.build(spec)
|
14
15
|
end
|
@@ -24,8 +25,15 @@ namespace :gem do
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
RuboCop::RakeTask.new
|
29
|
+
|
27
30
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
28
31
|
t.pattern = ['spec/*.rb']
|
29
32
|
end
|
30
33
|
|
34
|
+
# Clean up afterwards
|
35
|
+
Rake::Task[:spec].enhance do
|
36
|
+
Rake::Task[:clean].invoke
|
37
|
+
end
|
38
|
+
|
31
39
|
task :default => :spec
|
data/lib/linux/kstat.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
|
3
5
|
# The Linux module serves as a namespace only.
|
@@ -7,13 +9,14 @@ module Linux
|
|
7
9
|
extend Forwardable
|
8
10
|
|
9
11
|
# The version of the linux-kstat library
|
10
|
-
VERSION = '0.2.
|
12
|
+
VERSION = '0.2.8'
|
11
13
|
|
12
14
|
# :stopdoc:
|
13
15
|
|
14
16
|
# Delegate the the [] and inspect methods to the @hash variable
|
15
17
|
def_delegator(:@hash, :[])
|
16
18
|
def_delegator(:@hash, :inspect)
|
19
|
+
def_delegator(:@hash, :keys)
|
17
20
|
|
18
21
|
# :startdoc:
|
19
22
|
|
@@ -52,31 +55,32 @@ module Linux
|
|
52
55
|
def get_proc_stat_info
|
53
56
|
hash = {}
|
54
57
|
|
55
|
-
|
58
|
+
File.readlines('/proc/stat').each do |line|
|
56
59
|
info = line.split
|
60
|
+
next if info.empty?
|
61
|
+
key = info.first.to_sym
|
62
|
+
|
57
63
|
unless info.empty?
|
58
64
|
if info.first =~ /^cpu/i
|
59
|
-
hash[
|
60
|
-
:user
|
61
|
-
:nice
|
62
|
-
:system
|
63
|
-
:idle
|
64
|
-
:iowait
|
65
|
-
:irq
|
66
|
-
:softirq
|
67
|
-
:steal
|
68
|
-
:guest
|
65
|
+
hash[key] = {
|
66
|
+
:user => info[1].to_i,
|
67
|
+
:nice => info[2].to_i,
|
68
|
+
:system => info[3].to_i,
|
69
|
+
:idle => info[4].to_i,
|
70
|
+
:iowait => info[5].to_i,
|
71
|
+
:irq => info[6].to_i,
|
72
|
+
:softirq => info[7].to_i,
|
73
|
+
:steal => info[8].to_i,
|
74
|
+
:guest => info[9].to_i,
|
69
75
|
:guest_nice => info[10].to_i
|
70
76
|
}
|
77
|
+
elsif info.size > 2
|
78
|
+
hash[key] = info[1..-1].map(&:to_i)
|
71
79
|
else
|
72
|
-
|
73
|
-
hash[info.first.to_sym] = info[1..-1].map{ |e| e.to_i }
|
74
|
-
else
|
75
|
-
hash[info.first.to_sym] = info[1].to_i
|
76
|
-
end
|
80
|
+
hash[key] = info[1].to_i
|
77
81
|
end
|
78
82
|
end
|
79
|
-
|
83
|
+
end
|
80
84
|
|
81
85
|
hash
|
82
86
|
end
|
data/lib/linux-kstat.rb
CHANGED
data/linux-kstat.gemspec
CHANGED
@@ -2,26 +2,36 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'linux-kstat'
|
5
|
-
gem.version = '0.2.
|
5
|
+
gem.version = '0.2.8'
|
6
6
|
gem.license = 'Apache-2.0'
|
7
7
|
gem.author = 'Daniel J. Berger'
|
8
8
|
gem.email = 'djberg96@gmail.com'
|
9
|
-
gem.platform = Gem::Platform.new('universal-linux')
|
10
9
|
gem.homepage = 'https://github.com/djberg96/linux-kstat'
|
11
10
|
gem.summary = 'Ruby interface for Linux kernel stats in /proc/stat'
|
12
11
|
gem.test_files = Dir['spec/*_spec.rb']
|
13
12
|
gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
14
13
|
gem.cert_chain = ['certs/djberg96_pub.pem']
|
15
14
|
|
15
|
+
gem.add_development_dependency('rake')
|
16
|
+
gem.add_development_dependency('rubocop')
|
17
|
+
gem.add_development_dependency('rubocop-rspec')
|
16
18
|
gem.add_development_dependency('rspec', '~> 3.9')
|
17
19
|
|
20
|
+
# Don't build this gem with Java-based implementations
|
21
|
+
if RUBY_ENGINE !~ /truffleruby|jruby/i
|
22
|
+
gem.platform = Gem::Platform.new(['universal', 'linux'])
|
23
|
+
end
|
24
|
+
|
18
25
|
gem.metadata = {
|
19
|
-
'homepage_uri'
|
20
|
-
'bug_tracker_uri'
|
21
|
-
'changelog_uri'
|
22
|
-
'documentation_uri'
|
23
|
-
'source_code_uri'
|
24
|
-
'wiki_uri'
|
26
|
+
'homepage_uri' => 'https://github.com/djberg96/linux-kstat',
|
27
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/linux-kstat/issues',
|
28
|
+
'changelog_uri' => 'https://github.com/djberg96/linux-kstat/blob/master/CHANGES.md',
|
29
|
+
'documentation_uri' => 'https://github.com/djberg96/linux-kstat/wiki',
|
30
|
+
'source_code_uri' => 'https://github.com/djberg96/linux-kstat',
|
31
|
+
'wiki_uri' => 'https://github.com/djberg96/linux-kstat/wiki',
|
32
|
+
'rubygems_mfa_required' => 'true',
|
33
|
+
'github_repo' => 'https://github.com/djberg96/linux-kstat',
|
34
|
+
'funding_uri' => 'https://github.com/sponsors/djberg96'
|
25
35
|
}
|
26
36
|
|
27
37
|
gem.description = <<-EOF
|
data/spec/linux_kstat_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#######################################################################
|
2
4
|
# linux_kstat_spec.rb
|
3
5
|
#
|
@@ -7,30 +9,36 @@ require 'rspec'
|
|
7
9
|
require 'linux/kstat'
|
8
10
|
|
9
11
|
describe Linux::Kstat do
|
10
|
-
let(:kstat){
|
12
|
+
let(:kstat){ described_class.new }
|
11
13
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
expect(Linux::Kstat::VERSION).to eql('0.2.
|
14
|
+
context 'constants' do
|
15
|
+
it 'defines a version constant that is set to the expected value' do
|
16
|
+
expect(Linux::Kstat::VERSION).to eql('0.2.8')
|
15
17
|
expect(Linux::Kstat::VERSION).to be_frozen
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
context
|
20
|
-
it
|
21
|
-
expect(
|
22
|
-
expect{
|
23
|
-
expect(
|
21
|
+
context 'hash access' do
|
22
|
+
it 'allows hash style key access' do
|
23
|
+
expect(kstat).to respond_to(:[])
|
24
|
+
expect{ kstat[:cpu] }.not_to raise_error
|
25
|
+
expect(kstat[:cpu].keys.size).to be(10)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'contains the expected keys and value types' do
|
29
|
+
expect(kstat[:cpu]).to be_a(Hash)
|
30
|
+
expect(kstat[:btime]).to be_a(Numeric)
|
31
|
+
expect(kstat[:intr]).to be_a(Array)
|
24
32
|
end
|
25
33
|
|
26
|
-
it
|
27
|
-
expect(kstat
|
28
|
-
expect(kstat
|
29
|
-
expect(kstat
|
34
|
+
it 'delegates the keys method' do
|
35
|
+
expect(kstat).to respond_to(:keys)
|
36
|
+
expect(kstat.keys).to be_a(Array)
|
37
|
+
expect(kstat.keys).to include(:cpu)
|
30
38
|
end
|
31
39
|
|
32
|
-
it
|
33
|
-
expect{
|
40
|
+
it 'does not allow key assignment' do
|
41
|
+
expect{ kstat[:cpu] = 'test' }.to raise_error(NoMethodError)
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux-kstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: universal-linux
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
@@ -35,8 +34,50 @@ cert_chain:
|
|
35
34
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
35
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
36
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
37
|
+
date: 2025-06-13 00:00:00.000000000 Z
|
39
38
|
dependencies:
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: rake
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rubocop
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rubocop-rspec
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
40
81
|
- !ruby/object:Gem::Dependency
|
41
82
|
name: rspec
|
42
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +101,7 @@ extensions: []
|
|
60
101
|
extra_rdoc_files: []
|
61
102
|
files:
|
62
103
|
- CHANGES.md
|
104
|
+
- Gemfile
|
63
105
|
- LICENSE
|
64
106
|
- MANIFEST.md
|
65
107
|
- README.md
|
@@ -75,11 +117,13 @@ licenses:
|
|
75
117
|
metadata:
|
76
118
|
homepage_uri: https://github.com/djberg96/linux-kstat
|
77
119
|
bug_tracker_uri: https://github.com/djberg96/linux-kstat/issues
|
78
|
-
changelog_uri: https://github.com/djberg96/linux-kstat/blob/master/CHANGES
|
120
|
+
changelog_uri: https://github.com/djberg96/linux-kstat/blob/master/CHANGES.md
|
79
121
|
documentation_uri: https://github.com/djberg96/linux-kstat/wiki
|
80
122
|
source_code_uri: https://github.com/djberg96/linux-kstat
|
81
123
|
wiki_uri: https://github.com/djberg96/linux-kstat/wiki
|
82
|
-
|
124
|
+
rubygems_mfa_required: 'true'
|
125
|
+
github_repo: https://github.com/djberg96/linux-kstat
|
126
|
+
funding_uri: https://github.com/sponsors/djberg96
|
83
127
|
rdoc_options: []
|
84
128
|
require_paths:
|
85
129
|
- lib
|
@@ -94,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
138
|
- !ruby/object:Gem::Version
|
95
139
|
version: '0'
|
96
140
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
98
|
-
signing_key:
|
141
|
+
rubygems_version: 3.6.1
|
99
142
|
specification_version: 4
|
100
143
|
summary: Ruby interface for Linux kernel stats in /proc/stat
|
101
144
|
test_files:
|
metadata.gz.sig
CHANGED
Binary file
|