heartbeat-client 0.2.1 → 0.2.2
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/VERSION +1 -1
- data/lib/heartbeat-client.rb +6 -20
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.2
|
data/lib/heartbeat-client.rb
CHANGED
|
@@ -73,7 +73,7 @@ class Heartbeat
|
|
|
73
73
|
#puts cpu_usage.inspect
|
|
74
74
|
#puts processes.inspect
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Heartbeat.post('/heartbeat', options)
|
|
77
77
|
else
|
|
78
78
|
put "No top output found."
|
|
79
79
|
end
|
|
@@ -95,11 +95,7 @@ class Heartbeat
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
def self.load_averages(load_avg, str)
|
|
98
|
-
|
|
99
|
-
avg = str.split('load average:')
|
|
100
|
-
else
|
|
101
|
-
avg = str.split(':')
|
|
102
|
-
end
|
|
98
|
+
avg = str.split(is_linux? ? 'load average:' : ':')
|
|
103
99
|
if avg and avg[0]
|
|
104
100
|
avg[1].split(',').each do |a|
|
|
105
101
|
load_avg << a.strip.to_f
|
|
@@ -111,15 +107,9 @@ class Heartbeat
|
|
|
111
107
|
cpu = str.split(':')
|
|
112
108
|
if cpu and cpu[0]
|
|
113
109
|
cpu[1].split(',').each do |cp|
|
|
114
|
-
if is_linux?
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
cpu_usage['id'] = cp.split(' ')[0].strip.to_f if cp.include?('id')
|
|
118
|
-
else
|
|
119
|
-
cpu_usage['user'] = cp.split(' ')[0].strip.to_f if cp.include?('user')
|
|
120
|
-
cpu_usage['sys'] = cp.split(' ')[0].strip.to_f if cp.include?('sys')
|
|
121
|
-
cpu_usage['idle'] = cp.split(' ')[0].strip.to_f if cp.include?('idle')
|
|
122
|
-
end
|
|
110
|
+
cpu_usage['user'] = cp.split(' ')[0].strip.to_f if cp.include?(is_linux? ? 'us' : 'user')
|
|
111
|
+
cpu_usage['sys'] = cp.split(' ')[0].strip.to_f if cp.include?(is_linux? ? 'sy' : 'sys')
|
|
112
|
+
cpu_usage['idle'] = cp.split(' ')[0].strip.to_f if cp.include?(is_linux? ? 'id' : 'idle')
|
|
123
113
|
end
|
|
124
114
|
end
|
|
125
115
|
end
|
|
@@ -127,11 +117,7 @@ class Heartbeat
|
|
|
127
117
|
def self.process(processes, line)
|
|
128
118
|
procs = line.split(' ')
|
|
129
119
|
if procs and procs.size > 0
|
|
130
|
-
|
|
131
|
-
processes << {'pid' => procs[0].strip.to_i, 'command' => procs[11].strip, 'cpu' => procs[8].strip.to_f} # debian
|
|
132
|
-
else
|
|
133
|
-
processes << {'pid' => procs[0].strip.to_i, 'command' => procs[1].strip, 'cpu' => procs[2].strip.to_f}
|
|
134
|
-
end
|
|
120
|
+
processes << (is_linux? ? procs[11].strip : procs[1].strip)
|
|
135
121
|
end
|
|
136
122
|
end
|
|
137
123
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heartbeat-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 19
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.2.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Oliver Kiessler
|