linux_stat 2.5.2 → 2.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9155ed8b1f6161a8bafcb9fbd9f1a1d9f70b018ca62aabf49ad1c7439030ee2
4
- data.tar.gz: 22e52732cd8c8a2fca1f34ca9ece06178373c800ddbc200c42d1a61d49c29995
3
+ metadata.gz: 75ee9aa13037e326a0c04626cd28e0903b06372ce24344ffa38870f98dd6f0dd
4
+ data.tar.gz: d275807c8a9572fa9faaa1c562102302697f52b6a1cb36907fa71b2576c533b0
5
5
  SHA512:
6
- metadata.gz: d1f781908039e1946676f8a1502321b530538aef6d303976b07930c6d8933e7a45ca671e1aa3438fc774caa68c1b939f1ee12f47a5a6399523700b46cfb0c9f5
7
- data.tar.gz: cd51272b3c145c9a57a5b3ae444c21119430106436e29c843420269cbad47044fdc4e3836bf86e61404c6df20f462164dc673ec5e6d76b4acacfcc37effc61c8
6
+ metadata.gz: 3bd3330e9135cffee27a82fc661462a9c94e421ee5eebe24fb322ad9241e5498bdfd84914fd58dab93481366969f414bf2aa93e9507bb967ca18a462c91fc007
7
+ data.tar.gz: 686e7f1935fea8cde6ae24624522ef642f41e21304fdae7e758f3249f3b026ea6261a77fca76bbc2f5153d1d8426f9112a1b66f124e7c3d03106c0992ca731aa
@@ -344,7 +344,7 @@ module LinuxStat
344
344
  physical_cores = []
345
345
  hyperthreaded = {}
346
346
 
347
- return [] unless File.readable?('/sys/devices/system/cpu/'.freeze)
347
+ return [] unless File.executable?('/sys/devices/system/cpu/'.freeze)
348
348
  entries = Dir.entries('/sys/devices/system/cpu/'.freeze)
349
349
  entries.delete(?..freeze)
350
350
  entries.delete('..'.freeze)
@@ -384,7 +384,7 @@ module LinuxStat
384
384
  def hyperthreaded_core_list
385
385
  hyperthreaded = {}
386
386
 
387
- return [] unless File.readable?('/sys/devices/system/cpu/'.freeze)
387
+ return [] unless File.executable?('/sys/devices/system/cpu/'.freeze)
388
388
  entries = Dir.entries('/sys/devices/system/cpu/'.freeze)
389
389
  entries.delete(?..freeze)
390
390
  entries.delete('..'.freeze)
@@ -128,7 +128,7 @@ module LinuxStat
128
128
  # Also note that if there's no info available or no PCI enabled devices, it will return an empty
129
129
  # Hash.
130
130
  def devices_stat(hwdata: true)
131
- @@sys_pci_readable ||= File.readable?('/sys/bus/pci/devices/')
131
+ @@sys_pci_readable ||= File.executable?('/sys/bus/pci/devices/')
132
132
  return devices_info(hwdata: hwdata) unless @@sys_pci_readable
133
133
 
134
134
  Dir['/sys/bus/pci/devices/*/'.freeze].sort!.map! { |x|
@@ -215,7 +215,7 @@ module LinuxStat
215
215
  # But if the information isn't available, it will return nil.
216
216
  def count
217
217
  @@proc_pci_readable ||= File.readable?('/proc/bus/pci/devices')
218
- @@sys_pci_readable ||= File.readable?('/sys/bus/pci/devices/')
218
+ @@sys_pci_readable ||= File.executable?('/sys/bus/pci/devices/')
219
219
 
220
220
  if @@proc_pci_readable
221
221
  IO.readlines('/proc/bus/pci/devices'.freeze).length
@@ -64,7 +64,7 @@ module LinuxStat
64
64
 
65
65
  private
66
66
  def hwmon_readable?
67
- @@hwmon_readable ||= File.readable?("/sys/class/hwmon/")
67
+ @@hwmon_readable ||= File.executable?("/sys/class/hwmon/")
68
68
  end
69
69
 
70
70
  def query_hwmon(mon, key, div = false)
@@ -78,20 +78,46 @@ module LinuxStat
78
78
 
79
79
  while x = files[i += 1]
80
80
  splitted = File.split(x)
81
- path = File.join(splitted[0..-2])
82
-
83
- n = splitted[-1][/.*_/]
81
+ n = splitted.pop[/.*_/]
82
+ path = File.join(splitted)
84
83
 
85
84
  label_f = "#{path}/#{n}label"
86
- label = File.readable?(label_f) ? IO.read(label_f, encoding: 'ASCII-8BIT'.freeze).strip : nil
85
+
86
+ # Some of the files may have no content
87
+ # They can also raise Errno::EIO, Errno::ENODATA as well.
88
+ label = if File.readable?(label_f)
89
+ begin
90
+ IO.read(label_f, encoding: 'ASCII-8BIT'.freeze).strip
91
+ rescue Errno::EIO, Errno::ENODEV, Errno::ENODATA
92
+ nil
93
+ end
94
+ end
87
95
 
88
96
  temp_crit_f = "#{path}/#{n}crit"
89
- temp_crit = File.readable?(temp_crit_f) ? IO.read(temp_crit_f, encoding: 'ASCII-8BIT'.freeze).to_i : nil
97
+ temp_crit = if File.readable?(temp_crit_f)
98
+ begin
99
+ IO.read(temp_crit_f, encoding: 'ASCII-8BIT'.freeze).to_i
100
+ rescue Errno::EIO, Errno::ENODEV, Errno::ENODATA
101
+ nil
102
+ end
103
+ end
90
104
 
91
105
  temp_max_f = "#{path}/#{n}max"
92
- temp_max = File.readable?(temp_max_f) ? IO.read(temp_max_f, encoding: 'ASCII-8BIT'.freeze).to_i : nil
106
+ temp_max = if File.readable?(temp_max_f)
107
+ begin
108
+ IO.read(temp_max_f, encoding: 'ASCII-8BIT'.freeze).to_i
109
+ rescue Errno::EIO, Errno::ENODEV, Errno::ENODATA
110
+ nil
111
+ end
112
+ end
93
113
 
94
- value = File.readable?(x) ? IO.read(x).to_i : nil
114
+ value = if File.readable?(x)
115
+ begin
116
+ IO.read(x).to_i
117
+ rescue Errno::EIO, Errno::ENODEV, Errno::ENODATA
118
+ nil
119
+ end
120
+ end
95
121
 
96
122
  if dir != path
97
123
  dir = path
@@ -100,17 +126,17 @@ module LinuxStat
100
126
  end
101
127
 
102
128
  if div
103
- value /= 1000.0
129
+ value /= 1000.0 if value
104
130
  temp_max /= 1000.0 if temp_max
105
131
  temp_crit /= 1000.0 if temp_crit
106
132
  end
107
133
 
108
134
  h = {path: path, name: name}
109
135
 
110
- h.store(:label, label) if label
136
+ h.store(:label, label)
111
137
  h.store(key, value)
112
- h.store(:temp_crit, temp_crit) if temp_crit
113
- h.store(:temp_crit, temp_max) if temp_max
138
+ h.store(:temp_crit, temp_crit)
139
+ h.store(:temp_crit, temp_max)
114
140
 
115
141
  ret.push(h)
116
142
  end
@@ -47,7 +47,7 @@ module LinuxStat
47
47
  # Also note that if there's no info available or no USB devices, it will return an empty
48
48
  # Hash.
49
49
  def devices_stat(hwdata: true)
50
- @@sys_usb_readable ||= File.readable?('/sys/bus/usb/devices/')
50
+ @@sys_usb_readable ||= File.executable?('/sys/bus/usb/devices/')
51
51
  return [] unless @@sys_usb_readable
52
52
 
53
53
  Dir['/sys/bus/usb/devices/*/'.freeze].sort!.map! { |x|
@@ -137,7 +137,7 @@ module LinuxStat
137
137
  #
138
138
  # But if the information isn't available, it will return nil.
139
139
  def count
140
- @@sys_usb_readable ||= File.readable?('/sys/bus/usb/devices/')
140
+ @@sys_usb_readable ||= File.executable?('/sys/bus/usb/devices/')
141
141
  return nil unless @@sys_usb_readable
142
142
 
143
143
  Dir['/sys/bus/usb/devices/*/'.freeze].count { |x|
@@ -1,3 +1,3 @@
1
1
  module LinuxStat
2
- VERSION = "2.5.2"
2
+ VERSION = "2.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux_stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-23 00:00:00.000000000 Z
11
+ date: 2022-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Linux only, efficient linux system utilization reporting and system monitoring
14
14
  gem
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.2.29
93
+ rubygems_version: 3.3.8
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Efficient linux system reporting gem