host 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/host/linux/load_average.rb +4 -2
- data/lib/host/linux/memory.rb +7 -5
- data/lib/host/linux/processor.rb +4 -2
- data/lib/host/version.rb +1 -1
- metadata +2 -2
@@ -34,7 +34,8 @@ module Host
|
|
34
34
|
# Refreshes your load average information, reading from +/proc/loadavg+
|
35
35
|
# once again
|
36
36
|
def refresh
|
37
|
-
get_loadinfo
|
37
|
+
get_loadinfo(true)
|
38
|
+
self
|
38
39
|
end
|
39
40
|
|
40
41
|
|
@@ -43,7 +44,8 @@ module Host
|
|
43
44
|
# Retrieves information about load average on a Linux system,
|
44
45
|
# gathering the indices for the last minute, last 5 minutes
|
45
46
|
# and last 15 minutes.
|
46
|
-
def get_loadinfo
|
47
|
+
def get_loadinfo (force_reload=false)
|
48
|
+
@info = [] if force_reload
|
47
49
|
loadavg = File.read('/proc/loadavg')
|
48
50
|
averages = loadavg.gsub(/\d+\.\d+/)
|
49
51
|
|
data/lib/host/linux/memory.rb
CHANGED
@@ -15,27 +15,28 @@ module Host
|
|
15
15
|
# reloaded. Defaults to +false+. Equivalent to:
|
16
16
|
# Host::Memory.refresh.total
|
17
17
|
def total(refresh=false)
|
18
|
-
get_meminfo if refresh
|
18
|
+
get_meminfo(true) if refresh
|
19
19
|
as_integer @info[:MemTotal]
|
20
20
|
end
|
21
21
|
|
22
22
|
# Sugar. Equivalent to Host::Memory.get('MemFree') with implicit
|
23
23
|
# transformation to integer (in kB).
|
24
24
|
def free(refresh=false)
|
25
|
-
get_meminfo if refresh
|
25
|
+
get_meminfo(true) if refresh
|
26
26
|
as_integer @info[:MemFree]
|
27
27
|
end
|
28
28
|
|
29
29
|
# Sugar. Equivalent to Host::Memory.get('Buffers') with implicit
|
30
30
|
# transformation to integer (in kB)
|
31
31
|
def buffers(refresh=false)
|
32
|
-
get_meminfo if refresh
|
32
|
+
get_meminfo(true) if refresh
|
33
33
|
as_integer @info[:Buffers]
|
34
34
|
end
|
35
35
|
|
36
36
|
# Refreshes your memory information, reading +/proc/meminfo+ once again
|
37
37
|
def refresh
|
38
|
-
get_meminfo
|
38
|
+
get_meminfo(true)
|
39
|
+
self
|
39
40
|
end
|
40
41
|
|
41
42
|
# Retrieves specific information for the given key (as some exotic
|
@@ -64,7 +65,8 @@ module Host
|
|
64
65
|
|
65
66
|
# Opens +/proc/meminfo+ and parses it, storing the information in a
|
66
67
|
# key-value manner.
|
67
|
-
def get_meminfo
|
68
|
+
def get_meminfo(force_reload=false)
|
69
|
+
@info = [] if force_reload
|
68
70
|
matcher = /(.*):\s*(.*)$/
|
69
71
|
mem_info = File.read('/proc/meminfo')
|
70
72
|
|
data/lib/host/linux/processor.rb
CHANGED
@@ -56,14 +56,16 @@ module Host
|
|
56
56
|
# Refreshes your processor information, reading from +/proc/cpuinfo+ once
|
57
57
|
# again
|
58
58
|
def refresh
|
59
|
-
get_cpuinfo
|
59
|
+
get_cpuinfo(true)
|
60
|
+
self
|
60
61
|
end
|
61
62
|
|
62
63
|
private
|
63
64
|
|
64
65
|
# Opens +/proc/cpuinfo+ and parses it, filling the info hash
|
65
66
|
# with all the information in that file
|
66
|
-
def get_cpuinfo
|
67
|
+
def get_cpuinfo(force_reload=false)
|
68
|
+
@info = [] if force_reload
|
67
69
|
matcher = /(.*):\s*(.*)$/
|
68
70
|
cpu_info = File.read '/proc/cpuinfo'
|
69
71
|
|
data/lib/host/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
segments:
|
65
65
|
- 0
|
66
|
-
hash:
|
66
|
+
hash: 2931948725765703593
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|