cloud_monitor_agent 0.0.1
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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.trayes.yml +0 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +7 -0
- data/cloud_monitor_agent.gemspec +28 -0
- data/examples/agent_client.rb +9 -0
- data/lib/cloud_monitor_agent.rb +44 -0
- data/lib/version.rb +4 -0
- data/spec/cloud_monitor_spec.rb +64 -0
- data/spec/spec_helper.rb +18 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd1db6788631ccb4787dc061cc8516ae8e8e93b2
|
4
|
+
data.tar.gz: 35abff2bd5510228c8af6067ff8b54958776f02d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71e9f94aa23f4d7fbb12bf531d75177d007ec1aba8ba39ed8363314d9f2ea5f06374fa2f97afba01326a9e0ec0eabc838a27f7d935b9f59969af396f7aa678fd
|
7
|
+
data.tar.gz: 156f74df3cd36070878934005b1e08c06dcf4d18f04be33d91dc6a3000707909d681a54b8949572fd72e76395fe5ef3fd8ede07d98c0710b3185f27a3a76879f
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.trayes.yml
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Subba Rao
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require './lib/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cloud_monitor_agent"
|
8
|
+
spec.version = CloudMonitor::VERSION
|
9
|
+
spec.authors = ["G SubbaRao"]
|
10
|
+
spec.email = ["subbarao.kly@gmail.com"]
|
11
|
+
spec.description = %q{A Ruby Gem with methods to send statistics such as CPU, Disk, TCP/UDP Connections, Load, Bandwidth, Disk I/O, and Memory to remote address}
|
12
|
+
spec.summary = %q{Extended version of usagewatch_ext}
|
13
|
+
spec.homepage = "https://github.com/gsubbarao/cloud_monitor_agent"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.rdoc_options << '--main' << 'README'
|
16
|
+
|
17
|
+
spec.post_install_message = "* CloudMonitorAgent Gem for sending client machine \nThanks for installing!"
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split($/)
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
spec.add_runtime_dependency('usagewatch_ext', '~> 0.2.1')
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'usagewatch_ext'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class CloudMonitorAgent
|
6
|
+
|
7
|
+
def initialize(url, token, intervel)
|
8
|
+
@url = url
|
9
|
+
@token = token
|
10
|
+
@intervel = intervel
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_url
|
14
|
+
@url
|
15
|
+
end
|
16
|
+
|
17
|
+
def token
|
18
|
+
@token
|
19
|
+
end
|
20
|
+
|
21
|
+
def delay
|
22
|
+
@intervel
|
23
|
+
end
|
24
|
+
|
25
|
+
def getPayload
|
26
|
+
usw = Usagewatch
|
27
|
+
payload = {:token => self.token, :cpu_used => usw.uw_cpuused, :disk_used => usw.uw_diskused_perc, :mem_used => usw.uw_memused, :bandwidth_up => usw.uw_bandtx,
|
28
|
+
:bandwidth_down => usw.uw_bandrx, :top_process_cpu => usw.uw_cputop, :top_process_memory => usw.uw_memtop};
|
29
|
+
end
|
30
|
+
|
31
|
+
def send_report
|
32
|
+
while true
|
33
|
+
payload = self.getPayload
|
34
|
+
uri = URI('http://localhost:9292/api/v1/push_info')
|
35
|
+
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
36
|
+
req.body = payload.to_json
|
37
|
+
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
38
|
+
http.request(req)
|
39
|
+
end
|
40
|
+
sleep @intervel
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/version.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'IncludeLibrary' do
|
5
|
+
it 'should include the library' do
|
6
|
+
a = CloudMonitorAgent
|
7
|
+
a.should be CloudMonitorAgent
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'Should Initilize API' do
|
12
|
+
it "should point to proper end point" do
|
13
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
14
|
+
a.api_url.class.should be(String)
|
15
|
+
a.api_url.should_not be_nil
|
16
|
+
a.api_url.class.should be("http://localhost:9292/api/v1/push_info")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'Should Initilize Token' do
|
21
|
+
it "should send proper token to end point" do
|
22
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
23
|
+
a.token.class.should be(String)
|
24
|
+
a.token.should_not be_nil
|
25
|
+
a.token.class.should be("6a44b2afb6d719a321567a56a37171d5")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'Should Initilize delay time' do
|
30
|
+
it "should send data after proper delay" do
|
31
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
32
|
+
a.delay.class.should be(Integer)
|
33
|
+
a.delay.should_not be_nil
|
34
|
+
a.deply.class.should be(60)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'Payload Verification' do
|
39
|
+
it "should contain proper token on payload" do
|
40
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
41
|
+
payload = a.getPayload
|
42
|
+
payload.token.should be(String)
|
43
|
+
payload.token.should_not be_nil
|
44
|
+
payload.token.token.should be("6a44b2afb6d719a321567a56a37171d5")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should be the percentage of cpu used" do
|
48
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
49
|
+
payload = a.getPayload
|
50
|
+
payload.uw_cpuused.class.should be(Float)
|
51
|
+
payload.uw_cpuused.should_not be_nil
|
52
|
+
payload.uw_cpuused.should be <= 100
|
53
|
+
payload.uw_cpuused.should be >= 0
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be the percentage of GB of disk used" do
|
57
|
+
a = CloudMonitorAgent.new("http://localhost:9292/api/v1/push_info", "6a44b2afb6d719a321567a56a37171d5", 60)
|
58
|
+
payload = a.getPayload
|
59
|
+
payload.uw_diskused_perc.class.should be(Float)
|
60
|
+
payload.uw_diskused_perc.should_not be_nil
|
61
|
+
payload.uw_diskused_perc.should be <= 100
|
62
|
+
payload.uw_diskused_perc.should be >= 0
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
OS = RUBY_PLATFORM
|
7
|
+
if OS.include? "darwin"
|
8
|
+
require "usagewatch_ext"
|
9
|
+
puts "Testing Mac Version"
|
10
|
+
elsif OS.include? "linux"
|
11
|
+
require "usagewatch"
|
12
|
+
puts "Testing Linux Version"
|
13
|
+
puts `uname -a`
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cloud_monitor_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- G SubbaRao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: usagewatch_ext
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.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.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A Ruby Gem with methods to send statistics such as CPU, Disk, TCP/UDP
|
70
|
+
Connections, Load, Bandwidth, Disk I/O, and Memory to remote address
|
71
|
+
email:
|
72
|
+
- subbarao.kly@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".DS_Store"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".trayes.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- Rakefile
|
84
|
+
- cloud_monitor_agent.gemspec
|
85
|
+
- examples/agent_client.rb
|
86
|
+
- lib/cloud_monitor_agent.rb
|
87
|
+
- lib/version.rb
|
88
|
+
- spec/cloud_monitor_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/gsubbarao/cloud_monitor_agent
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message: "* CloudMonitorAgent Gem for sending client machine \nThanks
|
95
|
+
for installing!"
|
96
|
+
rdoc_options:
|
97
|
+
- "--main"
|
98
|
+
- README
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.5.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Extended version of usagewatch_ext
|
117
|
+
test_files:
|
118
|
+
- spec/cloud_monitor_spec.rb
|
119
|
+
- spec/spec_helper.rb
|