cloud66_agent 1.0.12 → 1.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/bin/cloud66_agent +3 -0
- data/cloud66_agent.gemspec +6 -7
- data/lib/cloud66_agent/utils/server.rb +2 -2
- data/lib/cloud66_agent/utils/version.rb +2 -2
- data/lib/cloud66_agent/utils/vital_signs.rb +0 -104
- metadata +7 -77
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmZlNTc5MGIwYTliYmRkOTgwNmJiNmJiNjk4N2UzYjVjNmM0Mzk0Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
OTE0OGQxMDRiOGIxOGUzYjE0OWJmODBkZTVlMmRiNzM4YjlhZTBhOQ==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWEyYTk1N2JjM2Y0YWE1MWUyYmIzMDNlYmFhMTNhMTAzNGZlYmNkMDExNmYw
|
10
|
+
ZmNiZjM1ODk5MDdjNzAyNDYyYzMxZDc2NWFiODdlMTBlYjM2NWUxNWU2ODJk
|
11
|
+
YzVjODI0MDkyMzE1YjBhMDEyMWZiNGU0ZjM0NTIxZjdiNGU4ZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzVkYzE4MDA5OGIwOTI3YjI0ODcyYjQ4Nzc3NjNhODdlNjdmNzE0ZTNlMjYz
|
14
|
+
YTg2ZmIwYzEyMDBiNWMyMTNkMGY2NWNmN2Q0ZmQzZTgwZWYyZWQ3MzhkN2U5
|
15
|
+
NGRlNThhMzQwMTI3Yjc0MDQ3YjhiOTUzNjJlNDc4NDY1OTJlNGY=
|
data/bin/cloud66_agent
CHANGED
@@ -74,6 +74,9 @@ elsif command == 'fail2ban'
|
|
74
74
|
opts.on('--port PORT', 'Attack port') { |v| @port = v }
|
75
75
|
end.order!
|
76
76
|
Cloud66Agent.fail2ban(@is_banned, @ip_address, @attack, @port)
|
77
|
+
elsif command == 'vitals'
|
78
|
+
# disable vital signs
|
79
|
+
exit 0
|
77
80
|
else
|
78
81
|
begin
|
79
82
|
Cloud66Agent.send command
|
data/cloud66_agent.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = "cloud66_agent"
|
8
8
|
gem.version = Cloud66::Utils::Version.current
|
9
9
|
gem.platform = Gem::Platform::RUBY
|
10
|
-
gem.date = '
|
10
|
+
gem.date = '2014-02-04'
|
11
11
|
gem.authors = ["Cloud 66"]
|
12
12
|
gem.email = ['hello@cloud66.com']
|
13
13
|
gem.description = "See https://www.cloud66.com for more info"
|
@@ -19,14 +19,13 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
# dependencies
|
22
|
-
gem.add_dependency('httparty', '
|
23
|
-
gem.add_dependency('sys-filesystem', '~>1.1.0')
|
22
|
+
gem.add_dependency('httparty', '~> 0.12.0')
|
24
23
|
# backups
|
25
24
|
gem.add_dependency('backup', '~>3.2.0')
|
26
|
-
gem.add_dependency('net-ssh', '<= 2.5.2')
|
27
|
-
gem.add_dependency('excon', '~> 0.17.0')
|
28
|
-
gem.add_dependency('fog', '~> 1.9.0')
|
29
|
-
gem.add_dependency('json', '~> 1.8.0')
|
25
|
+
#gem.add_dependency('net-ssh', '<= 2.5.2')
|
26
|
+
#gem.add_dependency('excon', '~> 0.17.0')
|
27
|
+
#gem.add_dependency('fog', '~> 1.9.0')
|
28
|
+
#gem.add_dependency('json', '~> 1.8.0')
|
30
29
|
end
|
31
30
|
|
32
31
|
|
@@ -76,9 +76,9 @@ module Cloud66
|
|
76
76
|
time = Time.now.utc.to_i
|
77
77
|
hash = Digest::SHA1.hexdigest("#{$config.api_key}#{$config.secret_key}#{time}").downcase
|
78
78
|
if data.nil?
|
79
|
-
content = { :headers => { '
|
79
|
+
content = { :headers => { 'api-key' => $config.api_key, 'hash' => hash, 'time' => time.to_s } }
|
80
80
|
else
|
81
|
-
content = { :headers => { '
|
81
|
+
content = { :headers => { 'api-key' => $config.api_key, 'hash' => hash, 'time' => time.to_s, 'Content-Type' => 'application/json' }, :body => { data: data }.to_json }
|
82
82
|
end
|
83
83
|
content
|
84
84
|
end
|
@@ -13,10 +13,10 @@ module Cloud66
|
|
13
13
|
# Defines the minor version
|
14
14
|
# PATCH:
|
15
15
|
# Defines the patch version
|
16
|
-
MAJOR, MINOR, PATCH = 1,
|
16
|
+
MAJOR, MINOR, PATCH = 1, 1, 0
|
17
17
|
|
18
18
|
#ie. PRERELEASE_MODIFIER = 'beta1'
|
19
|
-
PRERELEASE_MODIFIER =
|
19
|
+
PRERELEASE_MODIFIER = 'beta1'
|
20
20
|
|
21
21
|
##
|
22
22
|
# Returns the major version ( big release based off of multiple minor releases )
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'sys/filesystem'
|
2
|
-
require 'socket'
|
3
|
-
|
4
1
|
module Cloud66
|
5
2
|
module Utils
|
6
3
|
class VitalSigns
|
@@ -34,14 +31,6 @@ module Cloud66
|
|
34
31
|
return result
|
35
32
|
end
|
36
33
|
|
37
|
-
def self.vitals_info
|
38
|
-
return {
|
39
|
-
disk: Utils::VitalSigns.disk_usage_info,
|
40
|
-
cpu: Utils::VitalSigns.cpu_usage_info,
|
41
|
-
memory: Utils::VitalSigns.memory_usage_info
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
34
|
def self.is_aws?
|
46
35
|
# 6 seconds to find out if this is a AWS image or not!
|
47
36
|
instance = `/usr/bin/curl --connect-timeout 6 -s http://169.254.169.254/latest/meta-data/instance-id` rescue nil
|
@@ -50,99 +39,6 @@ module Cloud66
|
|
50
39
|
|
51
40
|
private
|
52
41
|
|
53
|
-
def self.disk_usage_info
|
54
|
-
space_info = {}
|
55
|
-
Sys::Filesystem.mounts do |mount|
|
56
|
-
stat = Sys::Filesystem.stat(mount.mount_point)
|
57
|
-
|
58
|
-
#skip if this mount is not active
|
59
|
-
#next if stat.blocks_available == 0 && stat.blocks == 0
|
60
|
-
|
61
|
-
mb_free = Float(stat.block_size) * Float(stat.blocks_available) / 1000 / 1000
|
62
|
-
mb_total = Float(stat.block_size) * Float(stat.blocks) / 1000 / 1000
|
63
|
-
mb_used = mb_total - mb_free
|
64
|
-
percent_used = mb_total > 0.0 ? mb_used / mb_total * 100 : 0.0
|
65
|
-
|
66
|
-
space_info[mount.mount_point] = { mb_free: mb_free, mb_used: mb_used, mb_total: mb_total, percent_used: percent_used }
|
67
|
-
mount.mount_point
|
68
|
-
end
|
69
|
-
return space_info
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.cpu_usage_info
|
73
|
-
|
74
|
-
#NOTE: we can get core-level info with mpstat -P ALL 1 1
|
75
|
-
#parse mpstat result
|
76
|
-
mpstat_result = `mpstat 1 5`
|
77
|
-
|
78
|
-
# mpstat_result = <<-SAMPLE
|
79
|
-
#Linux 3.2.0-23-generic (precise64) 12/07/2012 _x86_64_ (2 CPU)
|
80
|
-
#
|
81
|
-
#10:42:50 AM CPU %usr %nice %sys %ddle %irq %soft %steal %guest %idle
|
82
|
-
#10:42:51 AM all 0.00 0.00 0.50 5.00 0.00 0.00 0.00 0.00 99.50
|
83
|
-
#Average: all 0.00 0.00 0.50 50.00 0.00 0.00 0.00 0.00 99.50
|
84
|
-
#SAMPLE
|
85
|
-
|
86
|
-
#split output into lines
|
87
|
-
lines = mpstat_result.split(/\r?\n/)
|
88
|
-
|
89
|
-
#get rid of time (first 13 chars)
|
90
|
-
lines = lines.map { |line| line[13..-1] }
|
91
|
-
|
92
|
-
#get the header line and split into columns
|
93
|
-
header_line = lines.detect { |line| line =~ /%idle/ }
|
94
|
-
columns = header_line.split(/\s+/)
|
95
|
-
|
96
|
-
#detect position of %idle column
|
97
|
-
idle_index = columns.index('%idle')
|
98
|
-
|
99
|
-
#get average line
|
100
|
-
average_line = lines[-1]
|
101
|
-
columns = average_line.split(/\s+/)
|
102
|
-
|
103
|
-
#get idle value
|
104
|
-
idle_string = columns[idle_index]
|
105
|
-
idle_value = idle_string.to_f
|
106
|
-
|
107
|
-
percent_used = 100.0 - idle_value
|
108
|
-
|
109
|
-
#get average utilization value
|
110
|
-
return { percent_used: percent_used, percent_free: idle_value }
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.memory_usage_info
|
114
|
-
free_m_result = `free -m`
|
115
|
-
# free_m_result = <<-SAMPLE
|
116
|
-
# total used free shared buffers cached
|
117
|
-
#Mem: 590 480 109 0 37 227
|
118
|
-
#-/+ buffers/cache: 216 373
|
119
|
-
#Swap: 0 0 0
|
120
|
-
#SAMPLE
|
121
|
-
|
122
|
-
free_m_result.each_line do |line|
|
123
|
-
if line =~ /^Mem:/
|
124
|
-
parts = line.scan(/.*?(\d+)/)
|
125
|
-
parts.flatten!
|
126
|
-
|
127
|
-
mb_total = parts[0].to_f
|
128
|
-
# mb_used is not a true representation due to OS gobbling up mem
|
129
|
-
# mb_used = parts[1].to_i
|
130
|
-
mb_free = parts[2].to_f
|
131
|
-
mb_shared = parts[3].to_f
|
132
|
-
mb_buffers = parts[4].to_f
|
133
|
-
mb_cached = parts[5].to_f
|
134
|
-
|
135
|
-
#The total free memory available to proceses is calculated by adding up Mem:cached + Mem:buffers + Mem:free (99 + 63 + 296)
|
136
|
-
#This then needs to be divided by Mem:total to get the total available free memory (1692)
|
137
|
-
mb_available = mb_cached + mb_buffers + mb_free
|
138
|
-
mb_used = mb_total - mb_available
|
139
|
-
mb_free = mb_total - mb_used
|
140
|
-
percent_used = mb_used / mb_total * 100
|
141
|
-
return { mb_free: mb_free, mb_used: mb_used, mb_total: mb_total, percent_used: percent_used }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
42
|
# parse the data, not using YAML due to YAML parsing issues and JSON output not always working
|
147
43
|
def self.parse_data(data)
|
148
44
|
hash = {}
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud66_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cloud 66
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.8.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.8.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sys-filesystem
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ~>
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
19
|
+
version: 0.12.0
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - ~>
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
26
|
+
version: 0.12.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: backup
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,62 +38,6 @@ dependencies:
|
|
52
38
|
- - ~>
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: 3.2.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: net-ssh
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - <=
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.5.2
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - <=
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 2.5.2
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: excon
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.17.0
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.17.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: fog
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.9.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.9.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: json
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 1.8.0
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.8.0
|
111
41
|
description: See https://www.cloud66.com for more info
|
112
42
|
email:
|
113
43
|
- hello@cloud66.com
|
@@ -151,12 +81,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
81
|
version: '0'
|
152
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
83
|
requirements:
|
154
|
-
- - ! '
|
84
|
+
- - ! '>'
|
155
85
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
86
|
+
version: 1.3.1
|
157
87
|
requirements: []
|
158
88
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.2.1
|
160
90
|
signing_key:
|
161
91
|
specification_version: 4
|
162
92
|
summary: Cloud 66 server component
|