linux_stat 2.2.2 → 2.5.0

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.
data/ext/procfs/statm.h CHANGED
@@ -1,6 +1,6 @@
1
1
  #define PAGESIZE sysconf(_SC_PAGESIZE)
2
2
 
3
- VALUE statm(VALUE obj, VALUE pid) {
3
+ static VALUE statm(volatile VALUE obj, volatile VALUE pid) {
4
4
  VALUE hash = rb_hash_new() ;
5
5
 
6
6
  int _pid = FIX2INT(pid) ;
@@ -34,7 +34,7 @@ VALUE statm(VALUE obj, VALUE pid) {
34
34
  return hash ;
35
35
  }
36
36
 
37
- VALUE statm_virtual(VALUE obj, VALUE pid) {
37
+ static VALUE statm_virtual(volatile VALUE obj, volatile VALUE pid) {
38
38
  int _pid = FIX2INT(pid) ;
39
39
  if (_pid < 0) return Qnil ;
40
40
 
@@ -52,7 +52,7 @@ VALUE statm_virtual(VALUE obj, VALUE pid) {
52
52
  return UINT2NUM(_virtual * PAGESIZE) ;
53
53
  }
54
54
 
55
- VALUE statm_resident(VALUE obj, VALUE pid) {
55
+ static VALUE statm_resident(volatile VALUE obj, volatile VALUE pid) {
56
56
  int _pid = FIX2INT(pid) ;
57
57
  if (_pid < 0) return Qnil ;
58
58
 
@@ -70,7 +70,7 @@ VALUE statm_resident(VALUE obj, VALUE pid) {
70
70
  return UINT2NUM(resident * PAGESIZE) ;
71
71
  }
72
72
 
73
- VALUE statm_shared(VALUE obj, VALUE pid) {
73
+ static VALUE statm_shared(volatile VALUE obj, volatile VALUE pid) {
74
74
  int _pid = FIX2INT(pid) ;
75
75
  if (_pid < 0) return Qnil ;
76
76
 
@@ -88,7 +88,7 @@ VALUE statm_shared(VALUE obj, VALUE pid) {
88
88
  return UINT2NUM(shared * PAGESIZE) ;
89
89
  }
90
90
 
91
- VALUE statm_memory(VALUE obj, VALUE pid) {
91
+ static VALUE statm_memory(volatile VALUE obj, volatile VALUE pid) {
92
92
  int _pid = FIX2INT(pid) ;
93
93
  if (_pid < 0) return Qnil ;
94
94
 
data/ext/procfs/uptime.h CHANGED
@@ -1,4 +1,4 @@
1
- VALUE uptime_f(VALUE obj) {
1
+ static VALUE uptime_f(volatile VALUE obj) {
2
2
  FILE *f = fopen("/proc/uptime", "r") ;
3
3
  if (!f) return Qnil ;
4
4
 
@@ -11,103 +11,103 @@
11
11
  #pragma intel optimization_level 3
12
12
  #endif
13
13
 
14
- static VALUE getTick(VALUE obj) {
14
+ static VALUE getTick(volatile VALUE obj) {
15
15
  int val = sysconf(_SC_CLK_TCK) ;
16
16
  if (val < 0) return Qnil ;
17
17
 
18
18
  return INT2FIX(val) ;
19
19
  }
20
20
 
21
- static VALUE getChildMax(VALUE obj) {
21
+ static VALUE getChildMax(volatile VALUE obj) {
22
22
  long long int val = sysconf(_SC_CHILD_MAX) ;
23
23
  if (val < 0) return Qnil ;
24
24
 
25
25
  return LL2NUM(val) ;
26
26
  }
27
27
 
28
- static VALUE getHostnameMax(VALUE obj) {
28
+ static VALUE getHostnameMax(volatile VALUE obj) {
29
29
  long long val = sysconf(_SC_HOST_NAME_MAX) ;
30
30
  if (val < 0) return Qnil ;
31
31
 
32
32
  return LL2NUM(val) ;
33
33
  }
34
34
 
35
- static VALUE getLoginNameMax(VALUE obj) {
35
+ static VALUE getLoginNameMax(volatile VALUE obj) {
36
36
  long long val = sysconf(_SC_LOGIN_NAME_MAX) ;
37
37
  if (val < 0) return Qnil ;
38
38
 
39
39
  return LL2NUM(val) ;
40
40
  }
41
41
 
42
- static VALUE getOpenMax(VALUE obj) {
42
+ static VALUE getOpenMax(volatile VALUE obj) {
43
43
  long long val = sysconf(_SC_OPEN_MAX) ;
44
44
  if (val < 0) return Qnil ;
45
45
 
46
46
  return LL2NUM(val) ;
47
47
  }
48
48
 
49
- static VALUE getPageSize(VALUE obj) {
49
+ static VALUE getPageSize(volatile VALUE obj) {
50
50
  int val = sysconf(_SC_PAGESIZE) ;
51
51
  if (val < 0) return Qnil ;
52
52
 
53
53
  return INT2FIX(val) ;
54
54
  }
55
55
 
56
- static VALUE getStreamMax(VALUE obj) {
56
+ static VALUE getStreamMax(volatile VALUE obj) {
57
57
  long long val = sysconf(_SC_STREAM_MAX) ;
58
58
  if (val < 0) return Qnil ;
59
59
 
60
60
  return LL2NUM(val) ;
61
61
  }
62
62
 
63
- static VALUE getTTYNameMax(VALUE obj) {
63
+ static VALUE getTTYNameMax(volatile VALUE obj) {
64
64
  long long val = sysconf(_SC_TTY_NAME_MAX) ;
65
65
  if (val < 0) return Qnil ;
66
66
 
67
67
  return LL2NUM(val) ;
68
68
  }
69
69
 
70
- static VALUE getPosixVersion(VALUE obj) {
70
+ static VALUE getPosixVersion(volatile VALUE obj) {
71
71
  long long val = sysconf(_SC_VERSION) ;
72
72
  if (val < 0) return Qnil ;
73
73
 
74
74
  return LL2NUM(val) ;
75
75
  }
76
76
 
77
- static VALUE getLineMax(VALUE obj) {
77
+ static VALUE getLineMax(volatile VALUE obj) {
78
78
  long long val = sysconf(_SC_LINE_MAX) ;
79
79
  if (val < 0) return Qnil ;
80
80
 
81
81
  return LL2NUM(val) ;
82
82
  }
83
83
 
84
- static VALUE getExprNestMax(VALUE obj) {
84
+ static VALUE getExprNestMax(volatile VALUE obj) {
85
85
  long long val = sysconf(_SC_EXPR_NEST_MAX) ;
86
86
  if (val < 0) return Qnil ;
87
87
 
88
88
  return LL2NUM(val) ;
89
89
  }
90
90
 
91
- static VALUE getProcessorConfigured(VALUE obj) {
91
+ static VALUE getProcessorConfigured(volatile VALUE obj) {
92
92
  long val = sysconf(_SC_NPROCESSORS_CONF) ;
93
93
  if (val < 0) return Qnil ;
94
94
 
95
95
  return LONG2NUM(val) ;
96
96
  }
97
97
 
98
- static VALUE getProcessorOnline(VALUE obj) {
98
+ static VALUE getProcessorOnline(volatile VALUE obj) {
99
99
  long val = sysconf(_SC_NPROCESSORS_ONLN) ;
100
100
  if (val < 0) return Qnil ;
101
101
 
102
102
  return LONG2NUM(val) ;
103
103
  }
104
104
 
105
- static VALUE getUser(VALUE obj) {
105
+ static VALUE getUser(volatile VALUE obj) {
106
106
  char *name = getlogin() ;
107
107
  return name ? rb_str_new_cstr(name) : rb_str_new_cstr("") ;
108
108
  }
109
109
 
110
- static VALUE getUID(VALUE obj) {
110
+ static VALUE getUID(volatile VALUE obj) {
111
111
  return UINT2NUM((unsigned int) getuid()) ;
112
112
  }
113
113
 
@@ -115,11 +115,11 @@ static VALUE getGID(VALUE obj) {
115
115
  return UINT2NUM((unsigned int) getgid()) ;
116
116
  }
117
117
 
118
- static VALUE getEUID(VALUE obj) {
118
+ static VALUE getEUID(volatile VALUE obj) {
119
119
  return UINT2NUM((unsigned int) geteuid()) ;
120
120
  }
121
121
 
122
- static VALUE getHostname(VALUE obj) {
122
+ static VALUE getHostname(volatile VALUE obj) {
123
123
  int h_max = sysconf(_SC_HOST_NAME_MAX) + 1 ;
124
124
  char hostname[h_max] ;
125
125
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  static struct sysinfo info ;
15
15
 
16
- VALUE totalram(VALUE obj) {
16
+ static VALUE totalram(volatile VALUE obj) {
17
17
  char status = sysinfo(&info) ;
18
18
  if (status < 0) return Qnil ;
19
19
 
@@ -22,7 +22,7 @@ VALUE totalram(VALUE obj) {
22
22
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
23
23
  }
24
24
 
25
- VALUE freeram(VALUE obj) {
25
+ static VALUE freeram(volatile VALUE obj) {
26
26
  char status = sysinfo(&info) ;
27
27
  if (status < 0) return Qnil ;
28
28
 
@@ -31,7 +31,7 @@ VALUE freeram(VALUE obj) {
31
31
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
32
32
  }
33
33
 
34
- VALUE sharedram(VALUE obj) {
34
+ static VALUE sharedram(volatile VALUE obj) {
35
35
  char status = sysinfo(&info) ;
36
36
  if (status < 0) return Qnil ;
37
37
 
@@ -40,7 +40,7 @@ VALUE sharedram(VALUE obj) {
40
40
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
41
41
  }
42
42
 
43
- VALUE bufferram(VALUE obj) {
43
+ static VALUE bufferram(volatile VALUE obj) {
44
44
  char status = sysinfo(&info) ;
45
45
  if (status < 0) return Qnil ;
46
46
 
@@ -49,7 +49,7 @@ VALUE bufferram(VALUE obj) {
49
49
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
50
50
  }
51
51
 
52
- VALUE totalswap(VALUE obj) {
52
+ static VALUE totalswap(volatile VALUE obj) {
53
53
  static struct sysinfo info ;
54
54
  char status = sysinfo(&info) ;
55
55
  if (status < 0) return Qnil ;
@@ -59,7 +59,7 @@ VALUE totalswap(VALUE obj) {
59
59
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
60
60
  }
61
61
 
62
- VALUE freeswap(VALUE obj) {
62
+ static VALUE freeswap(volatile VALUE obj) {
63
63
  char status = sysinfo(&info) ;
64
64
  if (status < 0) return Qnil ;
65
65
 
@@ -68,7 +68,7 @@ VALUE freeswap(VALUE obj) {
68
68
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
69
69
  }
70
70
 
71
- VALUE totalhigh(VALUE obj) {
71
+ static VALUE totalhigh(volatile VALUE obj) {
72
72
  char status = sysinfo(&info) ;
73
73
  if (status < 0) return Qnil ;
74
74
 
@@ -77,7 +77,7 @@ VALUE totalhigh(VALUE obj) {
77
77
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
78
78
  }
79
79
 
80
- VALUE freehigh(VALUE obj) {
80
+ static VALUE freehigh(volatile VALUE obj) {
81
81
  char status = sysinfo(&info) ;
82
82
  if (status < 0) return Qnil ;
83
83
 
@@ -86,7 +86,7 @@ VALUE freehigh(VALUE obj) {
86
86
  return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
87
87
  }
88
88
 
89
- VALUE uptime(VALUE obj) {
89
+ static VALUE uptime(volatile VALUE obj) {
90
90
  char status = sysinfo(&info) ;
91
91
  if (status < 0) return Qnil ;
92
92
 
@@ -94,7 +94,7 @@ VALUE uptime(VALUE obj) {
94
94
  return ULL2NUM((unsigned long long) v) ;
95
95
  }
96
96
 
97
- VALUE loads(VALUE obj) {
97
+ static VALUE loads(volatile VALUE obj) {
98
98
  char status = sysinfo(&info) ;
99
99
  if(status < 0) return rb_ary_new() ;
100
100
 
@@ -112,7 +112,7 @@ VALUE loads(VALUE obj) {
112
112
  }
113
113
 
114
114
  // Some people may need this function, just keep it to not make unnecessary calls
115
- VALUE sysinfoStat(VALUE obj) {
115
+ static VALUE sysinfoStat(volatile VALUE obj) {
116
116
  char status = sysinfo(&info) ;
117
117
  VALUE hash = rb_hash_new() ;
118
118
  if (status < 0) return hash ;
@@ -28,23 +28,23 @@ void init_buf() {
28
28
  }
29
29
  }
30
30
 
31
- static VALUE getSysname(VALUE obj) {
31
+ static VALUE getSysname(volatile VALUE obj) {
32
32
  return rb_str_new_cstr(sysname) ;
33
33
  }
34
34
 
35
- static VALUE getNodename(VALUE obj) {
35
+ static VALUE getNodename(volatile VALUE obj) {
36
36
  return rb_str_new_cstr(nodename) ;
37
37
  }
38
38
 
39
- static VALUE getRelease(VALUE obj) {
39
+ static VALUE getRelease(volatile VALUE obj) {
40
40
  return rb_str_new_cstr(release) ;
41
41
  }
42
42
 
43
- static VALUE getVersion(VALUE obj) {
43
+ static VALUE getVersion(volatile VALUE obj) {
44
44
  return rb_str_new_cstr(version) ;
45
45
  }
46
46
 
47
- static VALUE getMachine(VALUE obj) {
47
+ static VALUE getMachine(volatile VALUE obj) {
48
48
  return rb_str_new_cstr(machine) ;
49
49
  }
50
50
 
@@ -308,7 +308,7 @@ module LinuxStat
308
308
  ret[:charge_full_wh] = c_f_wh if c_f_wh
309
309
  ret[:charge_percentage] = charge_percentage if charge_percentage
310
310
 
311
- h.merge!(File.split(x)[-1].to_sym => ret)
311
+ h.store(File.split(x)[-1].to_sym, ret)
312
312
  end
313
313
  h
314
314
  end
@@ -46,7 +46,8 @@ module LinuxStat
46
46
  res = totald.-(idle_now - idle_then).fdiv(totald).abs.*(100)
47
47
  res = res.nan? ? 0.0 : res > 100 ? 100.0 : res.round(2)
48
48
 
49
- h.merge!( x => res )
49
+ h.store(x, res)
50
+ h
50
51
  end
51
52
  end
52
53
 
@@ -203,12 +204,16 @@ module LinuxStat
203
204
 
204
205
  h = {}
205
206
  @@cur_f.each { |id, file|
206
- h.merge!(id => IO.read(file).to_i) if File.readable?(file)
207
+ h.store(id, IO.read(file).to_i) if File.readable?(file)
207
208
  }
208
209
 
209
210
  h
210
211
  end
211
212
 
213
+ def times
214
+ LinuxStat::ProcFS.cpu_times
215
+ end
216
+
212
217
  ##
213
218
  # Returns a Hash with max core frequencies corresponding to the CPUs.
214
219
  #
@@ -225,7 +230,7 @@ module LinuxStat
225
230
 
226
231
  h = {}
227
232
  @@min_f.each { |id, file|
228
- h.merge!(id => IO.read(file).to_i) if File.readable?(file)
233
+ h.store(id, IO.read(file).to_i) if File.readable?(file)
229
234
  }
230
235
 
231
236
  h
@@ -247,7 +252,7 @@ module LinuxStat
247
252
 
248
253
  h = {}
249
254
  @@min_f.each { |id, file|
250
- h.merge!(id => IO.read(file).to_i) if File.readable?(file)
255
+ h.store(id, IO.read(file).to_i) if File.readable?(file)
251
256
  }
252
257
 
253
258
  h
@@ -271,7 +276,7 @@ module LinuxStat
271
276
 
272
277
  h = {}
273
278
  @@scaling_g.each { |id, file|
274
- h.merge!(id => IO.read(file).tap(&:strip!)) if File.readable?(file)
279
+ h.store(id, IO.read(file).tap(&:strip!)) if File.readable?(file)
275
280
  }
276
281
 
277
282
  h
@@ -293,14 +298,89 @@ module LinuxStat
293
298
 
294
299
  h = {}
295
300
  @@scaling_av_g.each { |id, file|
296
- h.merge!(id => IO.read(file).split.each(&:strip!)) if File.readable?(file)
301
+ h.store(id, IO.read(file).split.each(&:strip!)) if File.readable?(file)
297
302
  }
298
303
 
299
304
  h
300
305
  end
301
306
 
307
+ ##
308
+ # Returns the number of physical cores on the system.
309
+ #
310
+ # The return value is an Array of Integers. Each number denoting the physical processor number.
311
+ # You can later use this to schedule tasks or something else (not provided by LinuxStat).
312
+ #
313
+ # However, if the information isn't available on /sys/devices/system/cpu[0-9]*/topology/thread_siblings_list, it will return an empty Array.
314
+ def physical_core_list
315
+ physical_cores = []
316
+ hyperthreaded = {}
317
+
318
+ entries = Dir.entries('/sys/devices/system/cpu/'.freeze)
319
+ entries.delete(?..freeze)
320
+ entries.delete('..'.freeze)
321
+
322
+ entries.each do |x|
323
+ if x[0..2] == 'cpu'.freeze && LinuxStat::Misc.integer?(x[3..-1])
324
+ file = "/sys/devices/system/cpu/#{x}/topology/thread_siblings_list"
325
+ next unless File.readable?(file)
326
+
327
+ data = IO.read(file)
328
+ data.strip!
329
+
330
+ val = data.split(?,.freeze).map(&:to_i)
331
+ val.shift
332
+
333
+ # Add items has for fast lookup.
334
+ # This hash includes all hyper threaded cores that doesn't map to anything.
335
+ # But this hash has the purpose to look up for items and not include in the list of physical_cores
336
+ # This is just an array, but can look for keys in O(1), so it's faster than ary.find() { ... }.
337
+ val.each { |x| hyperthreaded.store(x, nil) }
338
+
339
+ key = x[3..-1].to_i
340
+ physical_cores << key unless hyperthreaded.key?(key)
341
+ end
342
+ end
343
+
344
+ physical_cores
345
+ end
346
+
347
+ ##
348
+ # Returns the number of physical cores on the system.
349
+ #
350
+ # The return value is an Array of Integers. Each number denoting the hyperthreaded processor number.
351
+ # You can later use this to schedule tasks or something else (not provided by LinuxStat).
352
+ #
353
+ # However, if the information isn't available on /sys/devices/system/cpu[0-9]*/topology/thread_siblings_list, it will return an empty Array.
354
+ def hyperthreaded_core_list
355
+ hyperthreaded = {}
356
+
357
+ entries = Dir.entries('/sys/devices/system/cpu/'.freeze)
358
+ entries.delete(?..freeze)
359
+ entries.delete('..'.freeze)
360
+
361
+ entries.each do |x|
362
+ if x[0..2] == 'cpu'.freeze && LinuxStat::Misc.integer?(x[3..-1])
363
+ file = "/sys/devices/system/cpu/#{x}/topology/thread_siblings_list"
364
+ next unless File.readable?(file)
365
+
366
+ data = IO.read(file)
367
+ data.strip!
368
+
369
+ val = data.split(?,.freeze).map(&:to_i)
370
+ val.shift
371
+
372
+ # Add items has for fast lookup to get rid of duplicate items.
373
+ val.each { |x| hyperthreaded.store(x, nil) unless hyperthreaded.key?(x) }
374
+ end
375
+ end
376
+
377
+ hyperthreaded.keys
378
+ end
379
+
302
380
  alias usages stat
303
381
  alias usage total_usage
382
+ alias physical_cores physical_core_list
383
+ alias hyperthreaded_cores hyperthreaded_core_list
304
384
 
305
385
  private
306
386
  def cpuinfo
@@ -110,6 +110,51 @@ module LinuxStat
110
110
  def stat_raw(fs = ?..freeze)
111
111
  LinuxStat::FS.stat(fs)
112
112
  end
113
+
114
+ def sector_size(path = LinuxStat::Mounts.root)
115
+ LinuxStat::FS.sectors(path)
116
+ end
117
+
118
+ def io_total(path = LinuxStat::Mounts.root)
119
+ p = File.split(path)[-1]
120
+ _io_total = LinuxStat::FS.total_io(p)
121
+
122
+ return {} if _io_total.empty?
123
+
124
+ sector_size = LinuxStat::FS.sectors(path)
125
+ return {} unless sector_size
126
+
127
+ {
128
+ read: _io_total[0] &.*(sector_size),
129
+ write: _io_total[1] &.*(sector_size),
130
+ }
131
+ end
132
+
133
+ def io_usage(path = LinuxStat::Mounts.root, interval = 0.1)
134
+ p = File.split(path)[-1]
135
+
136
+ measure1 = LinuxStat::FS.total_io(p)
137
+ sleep(interval)
138
+ measure2 = LinuxStat::FS.total_io(p)
139
+
140
+ return {} if measure1.empty? || measure2.empty?
141
+
142
+ sector_size = LinuxStat::FS.sectors(path)
143
+ return {} unless sector_size
144
+
145
+ m1r = measure1[0]
146
+ m1w = measure1[1]
147
+
148
+ m2r = measure2[0]
149
+ m2w = measure2[1]
150
+
151
+ {
152
+ read: m2r.-(m1r).*(sector_size).fdiv(interval),
153
+ write: m2w.-(m1w).*(sector_size).fdiv(interval)
154
+ }
155
+ end
156
+
157
+ alias sectors sector_size
113
158
  end
114
159
  end
115
160
  end
@@ -58,7 +58,7 @@ module LinuxStat
58
58
  def tmpfs
59
59
  ret = {}
60
60
  mounts.each { |x|
61
- ret.merge!({x.split[1] => x}) if x.start_with?('tmpfs '.freeze)
61
+ ret.store(x.split[1], x) if x.start_with?('tmpfs '.freeze)
62
62
  }
63
63
  ret
64
64
  end
@@ -115,7 +115,7 @@ module LinuxStat
115
115
 
116
116
  unless x.empty?
117
117
  _x = x.split
118
- m.merge!(_x[0] => _x[1])
118
+ m.store(_x[0], _x[1])
119
119
  end
120
120
  end
121
121
  m
@@ -146,7 +146,7 @@ module LinuxStat
146
146
  _x = x.split
147
147
  total, free, available, used = fs_info(_x[1])
148
148
 
149
- m.merge!(_x[0] => {
149
+ m.store(_x[0], {
150
150
  mountpoint: _x[1],
151
151
 
152
152
  total: total,
@@ -120,8 +120,8 @@ module LinuxStat
120
120
 
121
121
  r.each_with_index { |x, i|
122
122
  downcased = x.downcase
123
- h.merge!(:r => i) if downcased.start_with?('receive'.freeze)
124
- h.merge!(:t => i) if downcased.start_with?('transmit'.freeze)
123
+ h.store(:r, i) if downcased.start_with?('receive'.freeze)
124
+ h.store(:t, i) if downcased.start_with?('transmit'.freeze)
125
125
  }
126
126
 
127
127
  data_0 = data.next.gsub(?|.freeze, ' %'.freeze)
data/lib/linux_stat/os.rb CHANGED
@@ -234,7 +234,8 @@ module LinuxStat
234
234
  value[0] = ''.freeze if value[0] == ?".freeze
235
235
  value[-1] = ''.freeze if value[-1] == ?".freeze
236
236
 
237
- h.merge!( key.to_sym => value )
237
+ h.store(key.to_sym, value)
238
+ h
238
239
  }
239
240
  end
240
241
  end
@@ -76,7 +76,7 @@ module LinuxStat
76
76
  kernel_driver: kernel_driver
77
77
  }
78
78
 
79
- ret.merge!(hwdata: query) unless query.empty?
79
+ ret.store(:hwdata, query) unless query.empty?
80
80
 
81
81
  ret
82
82
  }
@@ -186,14 +186,14 @@ module LinuxStat
186
186
  vendor: vendor, device: device
187
187
  }
188
188
 
189
- ret.merge!(sub_vendor: sub_vendor) if sub_vendor
190
- ret.merge!(sub_device: sub_device) if sub_device
189
+ ret.store(:sub_vendor, sub_vendor) if sub_vendor
190
+ ret.store(:sub_device, sub_device) if sub_device
191
191
 
192
- ret.merge!(kernel_driver: kernel_driver) if kernel_driver
193
- ret.merge!(revision: revision) unless revision.empty?
194
- ret.merge!(irq: irq) if irq
195
- ret.merge!(enable: enable) unless enable.nil?
196
- ret.merge!(hwdata: query) unless query.empty?
192
+ ret.store(:kernel_driver, kernel_driver) if kernel_driver
193
+ ret.store(:revision, revision) unless revision.empty?
194
+ ret.store(:irq, irq) if irq
195
+ ret.store(:enable, enable) unless enable.nil?
196
+ ret.store(:hwdata, query) unless query.empty?
197
197
 
198
198
  ret
199
199
  rescue StandardError
@@ -355,7 +355,7 @@ module LinuxStat
355
355
 
356
356
  if sub_vendor_id && sub_device_id
357
357
  sub_product = vendor.dig(1, product_id, 1, sub_vendor_id, sub_device_id)
358
- ret.merge!(sub_system: sub_product) if sub_product
358
+ ret.store(:sub_system, sub_product) if sub_product
359
359
  end
360
360
 
361
361
  ret