nephelae 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.ruby-version +1 -0
- data/MIT-LICENCE +20 -0
- data/README.md +44 -9
- data/Vagrantfile +14 -0
- data/bin/nephelae +18 -4
- data/lib/nephelae.rb +11 -12
- data/lib/nephelae/cloud_watch/cloud_watch.rb +32 -39
- data/lib/nephelae/cloud_watch/metrics.rb +11 -13
- data/lib/nephelae/plugins/passenger_status.rb +0 -1
- data/lib/nephelae/plugins/redis.rb +1 -1
- data/lib/nephelae/runner.rb +32 -22
- data/lib/nephelae/version.rb +1 -1
- data/nephelae.gemspec +1 -1
- metadata +19 -29
- data/lib/nephelae/cloud_watch/simple_aws.rb +0 -56
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 46ba6a351d50bbdc74cce995595f6df3da22dad2
|
4
|
+
data.tar.gz: eaae6fb957bb66420f0e40ed75b649d888e24215
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1182630f3252d7f6ec8aa3ff9b4525f9412dcae994c4bcaaa8d8ae48f490a72c6a45fdd2cff281af1a8deef12ad1f2758944fe28c0589d01f4fe636cabd60e3d
|
7
|
+
data.tar.gz: 5835f81f0b2ba3ebd6c3b3c5a25470959f775069129025e1d47a8e63484e108317e87c6288163ca1c7ae7200772e8bf8ede55b516c375a471f1b663fbf7911b5
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/MIT-LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2012 by Made by Many Ltd - http://madebymany.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,24 +1,59 @@
|
|
1
1
|
# Nephelae
|
2
2
|
|
3
|
-
|
3
|
+
The Nephelae were the nymph of clouds (http://www.theoi.com/Nymphe/Nephelai.html) carrying water from Earth to Heaven. In this particular case the nephelae carry data from servers to Amazon EC2 Cloud Watch. It was written to send disk space and memory usage of EC2 servers but can be extended to query any metrics and upload them on a regular basis.
|
4
|
+
|
5
|
+
For example the Redis plugin will collect the UsedMemory, ConnectedSlaves, ConnectedClients, ChangesSinceLastSave, MasterIOSecondsAgo, MasterLinkStatus and Up of a Redis instance and send this to AWS CloudWatch. We use this to put CloudWatch Alarms on the Up and MasterLinkStatus metrics to notify if Redis goes down or loses connection with the Master
|
6
|
+
|
7
|
+
The Nephelae gem contains a daemon process which has a number of plugins to collect stats. The daemon process is configured through a yaml file
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
7
|
-
|
11
|
+
To install as a gem
|
8
12
|
|
9
|
-
gem
|
13
|
+
$ gem install nephelae
|
10
14
|
|
11
|
-
|
15
|
+
## Usage
|
12
16
|
|
13
|
-
|
17
|
+
To run the nephelae deamon
|
14
18
|
|
15
|
-
|
19
|
+
$ nephelae start
|
16
20
|
|
17
|
-
|
21
|
+
This will start with default settings looking for a config yaml file in .etc/nephelae.yml. It will use /var/log as a log directory and /var/run for a pid directory
|
18
22
|
|
19
|
-
|
23
|
+
To start in the background (this uses the daemon gem http://daemons.rubyforge.org/)
|
24
|
+
|
25
|
+
$ nephelae start --piddir /home/nephelae/nephelae.pid --loglevel debug
|
26
|
+
|
27
|
+
|
28
|
+
To start in the foreground
|
29
|
+
|
30
|
+
$ nephelae --foreground
|
31
|
+
|
32
|
+
Other command line options
|
33
|
+
|
34
|
+
--loglevel *level* (debug, info, warn, error, fatal) default: warn
|
35
|
+
--config *path*
|
36
|
+
--instance-name *override the instance-id*
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
The config yaml file is used to define the AWS access keys and plugin settings
|
41
|
+
|
42
|
+
An example configuration file
|
20
43
|
|
21
|
-
|
44
|
+
```yaml
|
45
|
+
:aws_secret_access_key: your_secret_key
|
46
|
+
:aws_access_key_id: your_access_key
|
47
|
+
:region: ec2_region
|
48
|
+
:plugins:
|
49
|
+
:disk_space:
|
50
|
+
:plugin_class: DiskSpace
|
51
|
+
:path: /
|
52
|
+
:schedule: 1m
|
53
|
+
:mem_usage:
|
54
|
+
:plugin_class: MemUsage
|
55
|
+
:schedule: 1m
|
56
|
+
```
|
22
57
|
|
23
58
|
## Contributing
|
24
59
|
|
data/Vagrantfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant::Config.run do |config|
|
5
|
+
|
6
|
+
config.vm.define :precise64 do |precise64|
|
7
|
+
precise64.vm.box = "precise64"
|
8
|
+
precise64.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
9
|
+
precise64.vm.network :bridged, :bridge => "en0"
|
10
|
+
precise64.vm.customize ["modifyvm", :id, "--memory", 512]
|
11
|
+
precise64.vm.share_folder "v-data", "/nephelae", "./"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/bin/nephelae
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'daemons'
|
4
|
-
|
4
|
+
require_relative '../lib/nephelae'
|
5
5
|
require 'optparse'
|
6
6
|
require 'yaml'
|
7
7
|
|
@@ -16,6 +16,8 @@ logfile = STDOUT
|
|
16
16
|
loglevel = Logger::WARN
|
17
17
|
logdir = '/var/log'
|
18
18
|
piddir = '/var/run'
|
19
|
+
foreground = false
|
20
|
+
instance_name = nil
|
19
21
|
|
20
22
|
OptionParser.new do |o|
|
21
23
|
o.banner << " command"
|
@@ -28,6 +30,14 @@ OptionParser.new do |o|
|
|
28
30
|
logdir = v
|
29
31
|
end
|
30
32
|
|
33
|
+
o.on("--instance-name INSTANCE_NAME", "The instance name you want metrics bound to") do |v|
|
34
|
+
instance_name = v
|
35
|
+
end
|
36
|
+
|
37
|
+
o.on("--foreground", "Run in foreground") do |v|
|
38
|
+
foreground = v
|
39
|
+
end
|
40
|
+
|
31
41
|
o.on("--piddir PIDDIR", "The directory to put pid files") do |v|
|
32
42
|
piddir = v
|
33
43
|
end
|
@@ -56,7 +66,11 @@ Nephelae::Logging.logger = log
|
|
56
66
|
File.open( file ) { |yf| settings = YAML::load( yf ) }
|
57
67
|
|
58
68
|
new_argv = [cmd]
|
59
|
-
|
60
|
-
|
61
|
-
|
69
|
+
if foreground then
|
70
|
+
Nephelae::Runner.run(instance_name, settings)
|
71
|
+
else
|
72
|
+
Daemons.run_proc('nephelae', {ARGV: new_argv, log_dir: logdir, dir_mode: :normal, dir: piddir, log_output: true}) do
|
73
|
+
Nephelae::Runner.run(instance_name, settings)
|
74
|
+
end
|
62
75
|
end
|
76
|
+
|
data/lib/nephelae.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require "nephelae/cloud_watch/metrics"
|
1
|
+
require_relative "nephelae/version"
|
2
|
+
require_relative "nephelae/logging"
|
3
|
+
require_relative "nephelae/cloud_watch/cloud_watch"
|
4
|
+
require_relative "nephelae/cloud_watch/metrics"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
require_relative "nephelae/plugins/plugin"
|
7
|
+
require_relative "nephelae/plugins/disk_space"
|
8
|
+
require_relative "nephelae/plugins/mem_usage"
|
9
|
+
require_relative "nephelae/plugins/nephelae_process"
|
10
|
+
require_relative "nephelae/plugins/passenger_status"
|
11
|
+
require_relative "nephelae/plugins/redis"
|
13
12
|
|
14
|
-
|
13
|
+
require_relative "nephelae/runner"
|
15
14
|
|
16
15
|
module Nephelae
|
17
16
|
# Your code goes here...
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'excon'
|
3
|
+
|
1
4
|
module Nephelae
|
2
5
|
class CloudWatch
|
3
6
|
include Logging
|
@@ -5,51 +8,41 @@ module Nephelae
|
|
5
8
|
attr_accessor :aws_access_key_id, :aws_secret_access_key, :aws_session_token, :aws_credentials_expire_at, :url
|
6
9
|
|
7
10
|
def initialize(options={})
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@
|
16
|
-
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
17
|
-
|
18
|
-
@url = "#{@scheme}://#{@host}:#{@port}#{@path}"
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def request(params)
|
23
|
-
body = AWS.signed_params(
|
24
|
-
params,
|
25
|
-
{
|
26
|
-
:aws_access_key_id => @aws_access_key_id,
|
27
|
-
:aws_session_token => @aws_session_token,
|
28
|
-
:aws_secret_access_key => @aws_secret_access_key,
|
29
|
-
:host => @host,
|
30
|
-
:path => @path,
|
31
|
-
:port => @port,
|
32
|
-
:version => '2010-08-01'
|
33
|
-
}
|
34
|
-
)
|
35
|
-
|
36
|
-
AWS.request(@url, {
|
37
|
-
:body => body,
|
38
|
-
:expects => 200,
|
39
|
-
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
40
|
-
:host => @host,
|
41
|
-
:method => 'POST'
|
42
|
-
})
|
11
|
+
opts = {
|
12
|
+
access_key_id: options[:aws_access_key_id],
|
13
|
+
secret_access_key: options[:aws_secret_access_key],
|
14
|
+
region: options[:region]
|
15
|
+
}
|
16
|
+
|
17
|
+
AWS.config opts
|
18
|
+
@cw = AWS::CloudWatch.new
|
43
19
|
end
|
44
20
|
|
45
|
-
def put_metric(metric)
|
21
|
+
def put_metric(instance_name, metric)
|
46
22
|
params = metric.params
|
23
|
+
data = {}
|
24
|
+
data[:namespace] = metric.namespace
|
25
|
+
data[:metric_data] = []
|
47
26
|
unless params.nil?
|
48
|
-
|
49
|
-
|
50
|
-
|
27
|
+
params.each do |param|
|
28
|
+
Logging.logger.warn "Key : #{param[:name]}, Value : #{param[:value]}"
|
29
|
+
options = {}
|
30
|
+
options[:metric_name] = param[:name]
|
31
|
+
options[:dimensions] = [
|
32
|
+
{name: 'InstanceId', value: instance_name}
|
33
|
+
]
|
34
|
+
options[:timestamp] = Time.now.iso8601
|
35
|
+
options[:value] = param[:value]
|
36
|
+
options[:unit] = param[:unit]
|
37
|
+
data[:metric_data] << options
|
38
|
+
end
|
39
|
+
@cw.put_metric_data(data)
|
51
40
|
end
|
52
41
|
end
|
53
42
|
|
43
|
+
def get_instance_id()
|
44
|
+
Excon.get('http://169.254.169.254/latest/meta-data/instance-id').body
|
45
|
+
end
|
46
|
+
|
54
47
|
end
|
55
48
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../logging'
|
2
|
+
|
1
3
|
module Nephelae
|
2
4
|
class Metrics
|
3
5
|
attr_accessor :params, :namespace, :instance_id
|
@@ -6,26 +8,22 @@ module Nephelae
|
|
6
8
|
|
7
9
|
def initialize(namespace, options = {})
|
8
10
|
#code to get the instance id from ec2 metadata
|
9
|
-
@instance_id = options[:instance_id]
|
10
|
-
@params =
|
11
|
-
@
|
12
|
-
@params['Namespace'] = namespace
|
11
|
+
@instance_id = options[:instance_id]
|
12
|
+
@params = []
|
13
|
+
@namespace = namespace
|
13
14
|
@mcount = 0
|
14
15
|
end
|
15
16
|
|
16
17
|
def append_metric(name, value, options = {})
|
17
18
|
dim_count = 1
|
18
19
|
@mcount = @mcount + 1
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if @instance_id
|
25
|
-
params["MetricData.member.#{@mcount}.Dimensions.member.#{dim_count}.Name"] = 'InstanceId'
|
26
|
-
params["MetricData.member.#{@mcount}.Dimensions.member.#{dim_count}.Value"] = @instance_id
|
27
|
-
end
|
20
|
+
param = {}
|
21
|
+
param[:name] = name
|
22
|
+
param[:value] = value
|
23
|
+
param[:unit] = options[:unit] || 'None'
|
24
|
+
param[:timestamp] = options[:timestamp] if options[:timestamp]
|
28
25
|
|
26
|
+
@params << param
|
29
27
|
end
|
30
28
|
|
31
29
|
def params
|
@@ -13,7 +13,6 @@ module Nephelae
|
|
13
13
|
metrics.append_metric('ActiveInstances', stats[:active], {unit: 'Count'})
|
14
14
|
metrics.append_metric('InactiveInstances', stats[:inactive], {unit: 'Count'})
|
15
15
|
metrics.append_metric('WaitingOnGlobalQueue', stats[:waiting_on_global_queue], {unit: 'Count'})
|
16
|
-
|
17
16
|
end
|
18
17
|
|
19
18
|
return metrics
|
@@ -9,7 +9,7 @@ module Nephelae
|
|
9
9
|
if $?.success?
|
10
10
|
stats = parse_status(output)
|
11
11
|
metrics.append_metric('Up', 1)
|
12
|
-
metrics.append_metric('MasterLinkStatus', (stats[:
|
12
|
+
metrics.append_metric('MasterLinkStatus', (stats[:master_link_status] == 'up' ? 1 : 0)) unless stats[:master_link_status].nil?
|
13
13
|
metrics.append_metric('MasterIOSecondsAgo', stats[:master_last_io_seconds_ago], {unit: 'Seconds'}) unless stats[:master_last_io_seconds_ago].nil?
|
14
14
|
metrics.append_metric('ChangesSinceLastSave', stats[:changes_since_last_save], {unit: 'Count'})
|
15
15
|
metrics.append_metric('UsedMemory', stats[:used_memory], {unit: 'Bytes'})
|
data/lib/nephelae/runner.rb
CHANGED
@@ -6,40 +6,50 @@ module Nephelae
|
|
6
6
|
|
7
7
|
attr_accessor :aws_access_key_id, :aws_secret_access_key, :region, :plugins
|
8
8
|
|
9
|
-
def initialize(config = {})
|
9
|
+
def initialize(instance_name, config = {})
|
10
10
|
new_conf = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
11
|
+
@instance_name = instance_name
|
11
12
|
@aws_access_key_id = new_conf[:aws_access_key_id]
|
12
13
|
@aws_secret_access_key = new_conf[:aws_secret_access_key]
|
13
14
|
@region = new_conf[:region] || 'us-east-1'
|
14
15
|
@plugins = new_conf[:plugins] || default_plugins
|
15
16
|
@plugins[:nephelae_process] = {plugin_class: "NephelaeProcess", schedule: "5m"}
|
16
17
|
end
|
17
|
-
|
18
|
+
|
19
|
+
def self.run(instance_name, settings)
|
20
|
+
new(instance_name, settings).run
|
21
|
+
end
|
22
|
+
|
18
23
|
def run
|
19
24
|
log.warn "starting nephelae"
|
20
25
|
EM.run {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
26
|
+
cloud = CloudWatch.new({aws_access_key_id: @aws_access_key_id, aws_secret_access_key: @aws_secret_access_key, region: @region})
|
27
|
+
@instance_name ||= cloud.get_instance_id
|
28
|
+
|
29
|
+
log.warn("sending metrics for instance : #{@instance_name}")
|
30
|
+
|
31
|
+
#make one request to put a cloud watch metric for nephelae being up. hopefully this can make it bork early if anything is wrong
|
32
|
+
cloud.put_metric(@instance_name, NephelaeProcess.new.get_metrics)
|
33
|
+
|
34
|
+
scheduler = Rufus::Scheduler.new
|
35
|
+
|
36
|
+
log.warn("setting up schudules")
|
37
|
+
plugins.each do |name, config|
|
38
|
+
schedule = config.delete(:schedule) || '5m'
|
39
|
+
klass_name = config.delete(:plugin_class)
|
40
|
+
klass = Object.const_get('Nephelae').const_get(klass_name)
|
41
|
+
p = klass.new(config)
|
42
|
+
log.warn("setting up schudule for #{name} plugin")
|
43
|
+
scheduler.every schedule do
|
44
|
+
begin
|
45
|
+
log.warn "putting metric plugin #{name}"
|
46
|
+
cloud.put_metric(@instance_name, p.get_metrics)
|
47
|
+
rescue StandardError => e
|
48
|
+
log.error("nephelae plugin #{p.class} failed #{e.message}")
|
49
|
+
log.error(e.backtrace.join("\n"))
|
40
50
|
end
|
41
51
|
end
|
42
|
-
|
52
|
+
end
|
43
53
|
}
|
44
54
|
end
|
45
55
|
|
data/lib/nephelae/version.rb
CHANGED
data/nephelae.gemspec
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nephelae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Stuart Eccles
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: excon
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,65 +27,57 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: eventmachine
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rufus-scheduler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: daemons
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
70
|
+
name: aws-sdk
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
description: Nephelae is a daemon process that will upload custom cloud watch metrics
|
@@ -101,15 +90,17 @@ extensions: []
|
|
101
90
|
extra_rdoc_files: []
|
102
91
|
files:
|
103
92
|
- .gitignore
|
93
|
+
- .ruby-version
|
104
94
|
- Gemfile
|
105
95
|
- LICENSE
|
96
|
+
- MIT-LICENCE
|
106
97
|
- README.md
|
107
98
|
- Rakefile
|
99
|
+
- Vagrantfile
|
108
100
|
- bin/nephelae
|
109
101
|
- lib/nephelae.rb
|
110
102
|
- lib/nephelae/cloud_watch/cloud_watch.rb
|
111
103
|
- lib/nephelae/cloud_watch/metrics.rb
|
112
|
-
- lib/nephelae/cloud_watch/simple_aws.rb
|
113
104
|
- lib/nephelae/logging.rb
|
114
105
|
- lib/nephelae/plugins/disk_space.rb
|
115
106
|
- lib/nephelae/plugins/mem_usage.rb
|
@@ -122,26 +113,25 @@ files:
|
|
122
113
|
- nephelae.gemspec
|
123
114
|
homepage: https://github.com/madebymany/nephelae
|
124
115
|
licenses: []
|
116
|
+
metadata: {}
|
125
117
|
post_install_message:
|
126
118
|
rdoc_options: []
|
127
119
|
require_paths:
|
128
120
|
- lib
|
129
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
122
|
requirements:
|
132
|
-
- -
|
123
|
+
- - '>='
|
133
124
|
- !ruby/object:Gem::Version
|
134
125
|
version: '0'
|
135
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
127
|
requirements:
|
138
|
-
- -
|
128
|
+
- - '>='
|
139
129
|
- !ruby/object:Gem::Version
|
140
130
|
version: '0'
|
141
131
|
requirements: []
|
142
132
|
rubyforge_project:
|
143
|
-
rubygems_version:
|
133
|
+
rubygems_version: 2.0.3
|
144
134
|
signing_key:
|
145
|
-
specification_version:
|
135
|
+
specification_version: 4
|
146
136
|
summary: Poll for server metrics and post them to AWS as custom CloudWatch metrics
|
147
137
|
test_files: []
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
require 'excon'
|
3
|
-
require 'openssl'
|
4
|
-
|
5
|
-
module Nephelae
|
6
|
-
module AWS
|
7
|
-
|
8
|
-
def self.escape(string)
|
9
|
-
string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
|
10
|
-
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.hmac_sign(string_to_sign, key)
|
15
|
-
digest = OpenSSL::Digest::Digest.new('sha256')
|
16
|
-
OpenSSL::HMAC.digest(digest, key, string_to_sign)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.signed_params(params, options = {})
|
20
|
-
params.merge!({
|
21
|
-
'AWSAccessKeyId' => options[:aws_access_key_id],
|
22
|
-
'SignatureMethod' => 'HmacSHA256',
|
23
|
-
'SignatureVersion' => '2',
|
24
|
-
'Timestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
25
|
-
'Version' => options[:version]
|
26
|
-
})
|
27
|
-
|
28
|
-
params.merge!({
|
29
|
-
'SecurityToken' => options[:aws_session_token]
|
30
|
-
}) if options[:aws_session_token]
|
31
|
-
|
32
|
-
body = ''
|
33
|
-
for key in params.keys.sort
|
34
|
-
unless (value = params[key]).nil?
|
35
|
-
body << "#{key}=#{escape(value.to_s)}&"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
string_to_sign = "POST\n#{options[:host]}:#{options[:port]}\n#{options[:path]}\n" << body.chop
|
39
|
-
signed_string = hmac_sign(string_to_sign, options[:aws_secret_access_key])
|
40
|
-
body << "Signature=#{escape(Base64.encode64(signed_string).chomp!)}"
|
41
|
-
|
42
|
-
body
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.request(url, params, &block)
|
46
|
-
excon = Excon.new(url, params)
|
47
|
-
excon.request(params, &block)
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.get_instance_id
|
51
|
-
Excon.get('http://169.254.169.254/latest/meta-data/instance-id').body
|
52
|
-
#"i-f746ec92"
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|