cloudscale 0.0.6 → 0.0.7

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cloudscale.rb +37 -25
  3. data/lib/cloudscale/monitor/agent/{init.rb → agent.rb} +42 -1
  4. data/lib/cloudscale/monitor/plugin/settings_db.rb +60 -0
  5. data/lib/cloudscale/monitor/{agent/preops → preops}/general_preop.rb +0 -0
  6. data/lib/cloudscale/monitor/preops/preop.rb +62 -0
  7. data/lib/cloudscale/plugins/mongo/mongo_db_status.rb +24 -19
  8. data/lib/cloudscale/plugins/mongo/mongo_replica_status.rb +48 -75
  9. data/lib/cloudscale/plugins/mongo/mongo_server_status.rb +112 -135
  10. data/lib/cloudscale/plugins/mongo/preops/mongodb_preop.rb +113 -0
  11. data/lib/cloudscale/plugins/os/preops/{plugin_preop.rb → os_preop.rb} +7 -4
  12. data/lib/cloudscale/plugins/os/sigar_cpu_perc.rb +3 -3
  13. data/lib/cloudscale/plugins/os/sigar_disk_iops.rb +4 -4
  14. data/lib/cloudscale/plugins/os/sigar_disk_space.rb +3 -3
  15. data/lib/cloudscale/plugins/os/sigar_net_byte_information.rb +4 -5
  16. data/lib/cloudscale/plugins/os/sigar_packet_information.rb +4 -4
  17. data/lib/cloudscale/plugins/os/sigar_ram_usage.rb +4 -4
  18. data/lib/cloudscale/plugins/os/sigar_swap_usage.rb +3 -3
  19. data/lib/cloudscale/plugins/plugin.rb +2 -50
  20. data/lib/cloudscale/plugins/postgres/postgres_server_status.rb +60 -101
  21. data/lib/cloudscale/plugins/postgres/preops/postgres_preop.rb +80 -0
  22. data/lib/cloudscale/plugins/preops/plugin_preop.rb +30 -0
  23. data/lib/cloudscale/registry.rb +1 -0
  24. data/lib/cloudscale/store/plugin/host +1 -0
  25. data/lib/cloudscale/store/plugin/port +1 -0
  26. data/lib/cloudscale/store/plugin/token +1 -0
  27. data/lib/cloudscale/version.rb +1 -1
  28. metadata +41 -10
  29. data/lib/cloudscale/monitor/agent/init_charts.rb +0 -50
  30. data/lib/cloudscale/monitor/agent/init_menus.rb +0 -44
  31. data/lib/cloudscale/monitor/agent/preops/preop.rb +0 -76
  32. data/lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb +0 -105
  33. data/lib/cloudscale/plugins/preops/plugin_postgres_preop.rb +0 -70
@@ -0,0 +1,30 @@
1
+ require "logger"
2
+ require "#{File.dirname(__FILE__)}/../../monitor/preops/preop"
3
+
4
+ ##
5
+ #
6
+ # @author Johannes Hiemer.
7
+ #
8
+ ##
9
+ module Cloudscale
10
+ module Preops
11
+ class PluginPreop < Preops::Preop
12
+ attr_accessor :log, :pluginPreops
13
+
14
+ @pluginPreops = Set.new
15
+
16
+ def log
17
+ @log = Logger.new(STDOUT)
18
+ end
19
+
20
+ def self.pluginPreops
21
+ @pluginPreops
22
+ end
23
+
24
+ def self.inherited(klass)
25
+ @pluginPreops << klass
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,6 +1,7 @@
1
1
  require "singleton"
2
2
  require "securerandom"
3
3
  require "#{File.dirname(__FILE__)}/monitor/model/constants/agent_instance_store"
4
+ require "#{File.dirname(__FILE__)}/monitor/model/constants/agent_store"
4
5
 
5
6
  ##
6
7
  #
@@ -0,0 +1 @@
1
+ I"localhost:ET
@@ -0,0 +1 @@
1
+ I" 8080:ET
@@ -0,0 +1 @@
1
+ I"{e2FsZz1IUzI1NiwgdHlwPUNUfQ.e3Y9MCwgZD1tb25pdG9yaW5nLCBpYXQ9MTQwNDc1NzMyNH0.rG0biCuH_-X1vulEr19H2m42i4DGRR8PGwgXastyk3Q:ET
@@ -4,5 +4,5 @@
4
4
  #
5
5
  ##
6
6
  module Cloudscale
7
- VERSION = "0.0.6" unless const_defined?(:VERSION)
7
+ VERSION = "0.0.7" unless const_defined?(:VERSION)
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Hiemer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.9.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: mongo
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 2.0.3
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 2.0.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: pg
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 0.18.2
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 0.18.2
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: bundler
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -179,26 +207,26 @@ files:
179
207
  - bin/rake
180
208
  - bin/restclient
181
209
  - bin/rspec
182
- - lib/cloudscale/monitor/agent/init.rb
183
- - lib/cloudscale/monitor/agent/init_charts.rb
184
- - lib/cloudscale/monitor/agent/init_menus.rb
185
- - lib/cloudscale/monitor/agent/preops/general_preop.rb
186
- - lib/cloudscale/monitor/agent/preops/preop.rb
210
+ - lib/cloudscale/monitor/agent/agent.rb
187
211
  - lib/cloudscale/monitor/model/agent/agent_instance.rb
188
212
  - lib/cloudscale/monitor/model/agent/agent_instance_settings.rb
189
213
  - lib/cloudscale/monitor/model/constants/agent_instance_store.rb
190
214
  - lib/cloudscale/monitor/model/constants/agent_store.rb
191
215
  - lib/cloudscale/monitor/model/constants/influxdb_store.rb
192
216
  - lib/cloudscale/monitor/model/influxdb/influxdata.rb
217
+ - lib/cloudscale/monitor/plugin/settings_db.rb
218
+ - lib/cloudscale/monitor/preops/general_preop.rb
219
+ - lib/cloudscale/monitor/preops/preop.rb
193
220
  - lib/cloudscale/monitor/reporter/influxdb_reporter.rb
194
221
  - lib/cloudscale/plugins/mongo/data/os_chart.json
195
222
  - lib/cloudscale/plugins/mongo/data/os_menu.json
196
223
  - lib/cloudscale/plugins/mongo/mongo_db_status.rb
197
224
  - lib/cloudscale/plugins/mongo/mongo_replica_status.rb
198
225
  - lib/cloudscale/plugins/mongo/mongo_server_status.rb
226
+ - lib/cloudscale/plugins/mongo/preops/mongodb_preop.rb
199
227
  - lib/cloudscale/plugins/os/data/os_chart.json
200
228
  - lib/cloudscale/plugins/os/data/os_menu.json
201
- - lib/cloudscale/plugins/os/preops/plugin_preop.rb
229
+ - lib/cloudscale/plugins/os/preops/os_preop.rb
202
230
  - lib/cloudscale/plugins/os/sigar_cpu_perc.rb
203
231
  - lib/cloudscale/plugins/os/sigar_disk_iops.rb
204
232
  - lib/cloudscale/plugins/os/sigar_disk_space.rb
@@ -208,14 +236,17 @@ files:
208
236
  - lib/cloudscale/plugins/os/sigar_swap_usage.rb
209
237
  - lib/cloudscale/plugins/plugin.rb
210
238
  - lib/cloudscale/plugins/postgres/postgres_server_status.rb
211
- - lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb
212
- - lib/cloudscale/plugins/preops/plugin_postgres_preop.rb
239
+ - lib/cloudscale/plugins/postgres/preops/postgres_preop.rb
240
+ - lib/cloudscale/plugins/preops/plugin_preop.rb
213
241
  - lib/cloudscale/registry.rb
214
242
  - lib/cloudscale/rest/rest_client.rb
215
243
  - lib/cloudscale/rest/rest_client_helper.rb
216
244
  - lib/cloudscale/schedule.rb
217
245
  - lib/cloudscale/store/agent/agent.store
218
246
  - lib/cloudscale/store/agent/influxdb.store
247
+ - lib/cloudscale/store/plugin/host
248
+ - lib/cloudscale/store/plugin/port
249
+ - lib/cloudscale/store/plugin/token
219
250
  - lib/cloudscale/version.rb
220
251
  - lib/cloudscale.rb
221
252
  - lib/test/rest/rest_client_test.rb
@@ -1,50 +0,0 @@
1
- require "yaml"
2
- require "logger"
3
- require "json"
4
- require "yaml"
5
- require "#{File.dirname(__FILE__)}/../../rest/rest_client"
6
-
7
- ##
8
- #
9
- # @author Johannes Hiemer.
10
- #
11
- ##
12
- module Cloudscale
13
- module Monitor
14
- class InitCharts
15
- attr_accessor :log, :customer, :agentInstanceId, :server, :client
16
-
17
- def initialize(agentInstanceId, path)
18
- if (agentInstanceId == nil)
19
- raise "InitCharts.new(): AgentInstanceId may not be null"
20
- end
21
-
22
- @log = Logger.new(STDOUT)
23
- @log.info("Initializing Charts")
24
- @client = RestClientWrapper.instance
25
-
26
- file = File.read(path);
27
- plugin = YAML.load(JSON.parse(file).to_yaml)
28
- plugin.each do | key, value |
29
- init_chart(value, agentInstanceId)
30
- end
31
- end
32
-
33
- def init_chart(chart, agentInstanceId)
34
- chart["agentInstanceId"] = agentInstanceId
35
-
36
- chart["queries"].each { | query |
37
- query["command"].sub! '[[agentInstanceId]]', agentInstanceId
38
- }
39
-
40
- test_chart = @client.searchOne("charts", "findByAgentInstanceIdAndChartId", { :agentInstanceId => agentInstanceId, :chartId => chart["chartId"]})
41
- if (test_chart == nil)
42
- client.post("charts", chart)
43
- else
44
- client.patch("charts", RestClientWrapper.load_entity_id(test_chart), chart)
45
- end
46
- end
47
-
48
- end
49
- end
50
- end
@@ -1,44 +0,0 @@
1
- require "yaml"
2
- require "logger"
3
- require "json"
4
- require "#{File.dirname(__FILE__)}/../../rest/rest_client"
5
-
6
- ##
7
- #
8
- # @author Johannes Hiemer.
9
- #
10
- ##
11
- module Cloudscale
12
- module Monitor
13
- class InitMenus
14
- attr_accessor :log, :customer, :agentInstanceId, :server, :client
15
-
16
- def initialize(agentInstanceId, path)
17
- if (agentInstanceId == nil)
18
- raise "InitMenu.new(): AgentInstanceId may not be null"
19
- end
20
-
21
- @log = Logger.new(STDOUT)
22
- @log.info("Initializing Menu")
23
- @client = RestClientWrapper.instance
24
-
25
- file = File.read(path);
26
- plugin = YAML.load(JSON.parse(file).to_yaml)
27
- plugin.each do | key, value |
28
- init_menu(value, agentInstanceId)
29
- end
30
- end
31
-
32
- def init_menu(menuItem, agentInstanceId)
33
- menuItem["agentInstanceId"] = agentInstanceId
34
- test_menu = @client.searchOne("menus", "findByAgentInstanceIdAndMenuId", { :agentInstanceId => agentInstanceId, :menuId => menuItem["menuId"]})
35
- if (test_menu == nil)
36
- client.post("menus", menuItem)
37
- else
38
- client.patch("menus", RestClientWrapper.load_entity_id(test_menu), menuItem)
39
- end
40
- end
41
-
42
- end
43
- end
44
- end
@@ -1,76 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../../registry"
2
- require "#{File.dirname(__FILE__)}/../init_charts"
3
- require "#{File.dirname(__FILE__)}/../init_menus"
4
-
5
- ##
6
- #
7
- # @author Johannes Hiemer.
8
- #
9
- ##
10
- module Cloudscale
11
- module Preops
12
- class Preop
13
- attr_accessor :log, :registry
14
-
15
- def init
16
- @log = Logger.new(STDOUT)
17
- @registry = Monitor::Registry.instance
18
- @plugin_settings_db = FSDB::Database.new("#{File.dirname(__FILE__)}/../../../store/plugin/")
19
- init_options()
20
- end
21
-
22
- def set_option_value(key, val)
23
- options[key.to_sym][:value] = val
24
- end
25
-
26
- def get_option(key)
27
- options[key.to_sym]
28
- end
29
-
30
- def get_option_value(key)
31
- if (options[key.to_sym] != nil)
32
- options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
33
- else
34
- nil
35
- end
36
- end
37
-
38
- def init_options
39
- @plugin_settings_db.fetch.each do | key |
40
- if (options[key.to_sym])
41
- options[key.to_sym][:value] = @plugin_settings_db[key]
42
- end
43
- end
44
- end
45
-
46
- def save_options
47
- options.each do | key, value |
48
- @plugin_settings_db[key.to_s] = value[:value].to_s
49
- end
50
- end
51
-
52
- def clear_options
53
- @plugin_settings_db.fetch.each do | element |
54
- @plugin_settings_db.delete(element)
55
- end
56
- end
57
-
58
- def init_charts(path)
59
- log.info("Starting monitoring chart synchronization...")
60
-
61
- Monitor::InitCharts.new(@registry.agent_instance_id, path)
62
-
63
- log.info("Successfully synchronized charts...")
64
- end
65
-
66
- def init_menus(path)
67
- log.info("Starting monitoring menu synchronization...")
68
-
69
- Monitor::InitMenus.new(@registry.agent_instance_id, path)
70
-
71
- log.info("Successfully synchronized menus...")
72
- end
73
-
74
- end
75
- end
76
- end
@@ -1,105 +0,0 @@
1
- require "logger"
2
- #require "mongo"
3
- require "singleton"
4
- require "#{File.dirname(__FILE__)}/../../monitor/agent/preops/preop"
5
-
6
- ##
7
- #
8
- # @author Johannes Hiemer.
9
- #
10
- ##
11
- module Cloudscale
12
- module Plugins
13
- class PluginMongodbPreop < Preops::Preop
14
- include Singleton
15
-
16
- attr_accessor :db, :connection
17
- @@options = {
18
- :host => {
19
- :argument => "--host",
20
- :description => "Host for your MongoDB Instance (e.g. host.mongodb.com)",
21
- :required => true,
22
- :value => nil
23
- },
24
- :port => {
25
- :argument => "--port",
26
- :description => "Port for your MongoDB Instance (Standard 27017)",
27
- :required => false,
28
- :value => 27017
29
- },
30
- :db => {
31
- :argument => "--db",
32
- :description => "Database of your MongoDB instance",
33
- :required => true,
34
- :value => nil
35
- },
36
- :ssl => {
37
- :argument => "--ssl",
38
- :description => "Usage SSL of your MongoDB instance",
39
- :required => false,
40
- :value => false
41
- },
42
- :username => {
43
- :argument => "--username",
44
- :description => "Username for your MongoDB instance",
45
- :required => false,
46
- :value => nil
47
- },
48
- :password => {
49
- :argument => "--password",
50
- :description => "Password for your MongoDB instance",
51
- :required => false,
52
- :value => nil
53
- },
54
- :connect_timeout => {
55
- :argument => "--connect_timeout",
56
- :description => "Connection Timeout for your MongoDB instance",
57
- :required => false,
58
- :value => 30
59
- },
60
- :op_timeout => {
61
- :argument => "--op_timeout",
62
- :description => "Operation TImeout for your MongoDB instance",
63
- :required => false,
64
- :value => 30
65
- }
66
- }
67
-
68
- def options
69
- @@options
70
- end
71
-
72
- def initialize
73
- self.init
74
- begin
75
- @connection = Mongo::Connection.new(options[:host][:value], options[:port][:value])
76
- rescue Mongo::ConnectionFailure
77
- puts "Unable to connect to the MongoDB Daemon.",
78
- "Please ensure it is running on #{@host}:#{@port}\n\nException Message: #{$!.message}. Also confirm if SSL should be enabled or disabled."
79
- end
80
-
81
- # Try to connect to the database
82
- if (@connection != nil)
83
- @db = @connection.db(options[:db][:value])
84
- end
85
-
86
- begin
87
- if (@username != nil)
88
- @db.authenticate(options[:username][:value], options[:password][:value])
89
- end
90
- rescue Mongo::AuthenticationError
91
- puts "Unable to authenticate to MongoDB Database." << $!.message
92
- end
93
- end
94
-
95
- def connection
96
- @connection
97
- end
98
-
99
- def db
100
- @db
101
- end
102
-
103
- end
104
- end
105
- end
@@ -1,70 +0,0 @@
1
- require "logger"
2
- #require "pg"
3
- require "singleton"
4
- require "#{File.dirname(__FILE__)}/../../monitor/agent/preops/preop"
5
-
6
- ##
7
- #
8
- # @author Johannes Hiemer.
9
- #
10
- ##
11
- module Cloudscale
12
- module Plugins
13
- class PluginPostgresPreop < Preops::Preop
14
- include Singleton
15
-
16
- @@options = {
17
- :host => {
18
- :argument => "--host",
19
- :description => "Host for your Postgres Instance (e.g. host.instance.com)",
20
- :required => true,
21
- :value => nil
22
- },
23
- :port => {
24
- :argument => "--port",
25
- :description => "Port for your Postgres Instance (Standard 5432)",
26
- :required => false,
27
- :value => 5432
28
- },
29
- :db => {
30
- :argument => "--db",
31
- :description => "Database of your Postgres instance",
32
- :required => true,
33
- :value => nil
34
- },
35
- :username => {
36
- :argument => "--username",
37
- :description => "Username for your Postgres instance",
38
- :required => false,
39
- :value => nil
40
- },
41
- :password => {
42
- :argument => "--password",
43
- :description => "Password for your Postgres instance",
44
- :required => false,
45
- :value => nil
46
- }
47
- }
48
-
49
- def options
50
- @@options
51
- end
52
-
53
- def initialize
54
- self.init
55
- begin
56
- @connection = PG.connect(:host => options[:host][:value], :user => options[:username][:value],
57
- :password => options[:password][:value],
58
- :port => options[:port][:value].to_i, :dbname => options[:db][:value])
59
- rescue PGError => e
60
- puts e.message
61
- end
62
- end
63
-
64
- def connection
65
- @connection
66
- end
67
-
68
- end
69
- end
70
- end