heartbeat-client 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/hbc +14 -2
- data/lib/heartbeat-client.rb +18 -7
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bin/hbc
CHANGED
@@ -17,10 +17,22 @@ unless @config['apikey']
|
|
17
17
|
exit
|
18
18
|
end
|
19
19
|
|
20
|
+
unless @config['endpoint']
|
21
|
+
puts "Service Endpoint not found!"
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
20
25
|
if ARGV and ARGV.size == 1
|
21
|
-
Daemons.run_proc('heartbeat-client.rb')
|
26
|
+
Daemons.run_proc('heartbeat-client.rb', :dir => File.join('/tmp'), :monitor => true,
|
27
|
+
:backtrace => true, :monitor => true) do
|
28
|
+
Heartbeat.log = Logger.new('/tmp/heartbeat.log')
|
22
29
|
loop do
|
23
|
-
|
30
|
+
begin
|
31
|
+
Heartbeat.create(@config['apikey'], @config['endpoint'], @config['name'])
|
32
|
+
rescue => e
|
33
|
+
puts e.message
|
34
|
+
end
|
35
|
+
GC.start
|
24
36
|
sleep(30)
|
25
37
|
end
|
26
38
|
end
|
data/lib/heartbeat-client.rb
CHANGED
@@ -14,11 +14,17 @@ class Heartbeat
|
|
14
14
|
RUBY_PLATFORM.downcase.include?("linux")
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.log=(logger)
|
18
|
+
@@log = logger
|
19
|
+
end
|
20
|
+
|
17
21
|
def self.log
|
18
|
-
|
22
|
+
@@log
|
19
23
|
end
|
20
|
-
|
24
|
+
|
21
25
|
def self.create(apikey, endpoint, name = nil)
|
26
|
+
log.info("#create - Collecting data...")
|
27
|
+
|
22
28
|
procs = {'total' => 0, 'running' => 0, 'stuck' => 0, 'sleeping' => 0, 'threads' => 0, 'stopped' => 0, 'zombie' => 0}
|
23
29
|
load_avg = []
|
24
30
|
cpu_usage = {'user' => 0, 'sys' => 0, 'idle' => 0}
|
@@ -26,13 +32,15 @@ class Heartbeat
|
|
26
32
|
memory = {'free' => 0, 'used' => 0}
|
27
33
|
disks = {}
|
28
34
|
swap = {'free' => 0, 'used' => 0}
|
29
|
-
|
35
|
+
|
36
|
+
log.debug("Dumping top output...")
|
30
37
|
if is_linux?
|
31
38
|
`top -b -n1 > /tmp/top.out`
|
32
39
|
else
|
33
40
|
`top -l 1 > /tmp/top.out`
|
34
41
|
end
|
35
|
-
|
42
|
+
|
43
|
+
log.debug("Dumping df output...")
|
36
44
|
`df -m > /tmp/dfm.out`
|
37
45
|
|
38
46
|
if File.exists?('/tmp/top.out')
|
@@ -87,10 +95,13 @@ class Heartbeat
|
|
87
95
|
}
|
88
96
|
}
|
89
97
|
}
|
90
|
-
|
91
|
-
|
98
|
+
|
99
|
+
log.info("#create - Sending data to endpoint...")
|
100
|
+
res = Heartbeat.post(endpoint + '/heartbeat', options)
|
101
|
+
log.debug("Response: #{res.response.inspect}") if res
|
102
|
+
log.info("Finished iteration.")
|
92
103
|
else
|
93
|
-
|
104
|
+
log.error "No top output found."
|
94
105
|
end
|
95
106
|
end
|
96
107
|
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Oliver Kiessler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|