cloudscale 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.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +33 -0
  4. data/bin/autospec +16 -0
  5. data/bin/bundler +16 -0
  6. data/bin/htmldiff +16 -0
  7. data/bin/ldiff +16 -0
  8. data/bin/monitor +16 -0
  9. data/bin/rake +16 -0
  10. data/bin/rspec +16 -0
  11. data/lib/cloudscale.rb +127 -0
  12. data/lib/cloudscale/monitor/agent/init.rb +63 -0
  13. data/lib/cloudscale/monitor/agent/init_charts.rb +60 -0
  14. data/lib/cloudscale/monitor/agent/init_menus.rb +44 -0
  15. data/lib/cloudscale/monitor/agent/preops/general_preop.rb +34 -0
  16. data/lib/cloudscale/monitor/agent/preops/preop.rb +72 -0
  17. data/lib/cloudscale/monitor/model/agent/agent_instance.rb +33 -0
  18. data/lib/cloudscale/monitor/model/agent/agent_instance_settings.rb +26 -0
  19. data/lib/cloudscale/monitor/model/constants/agent_instance_store.rb +42 -0
  20. data/lib/cloudscale/monitor/model/constants/agent_store.rb +23 -0
  21. data/lib/cloudscale/monitor/model/constants/influxdb_store.rb +23 -0
  22. data/lib/cloudscale/monitor/model/influxdb/influxdata.rb +28 -0
  23. data/lib/cloudscale/monitor/reporter/influxdb_reporter.rb +188 -0
  24. data/lib/cloudscale/plugins/mongo/data/os_chart.json +362 -0
  25. data/lib/cloudscale/plugins/mongo/data/os_menu.json +17 -0
  26. data/lib/cloudscale/plugins/mongo/mongo_db_status.rb +57 -0
  27. data/lib/cloudscale/plugins/mongo/mongo_replica_status.rb +103 -0
  28. data/lib/cloudscale/plugins/mongo/mongo_server_status.rb +172 -0
  29. data/lib/cloudscale/plugins/os/data/os_chart.json +362 -0
  30. data/lib/cloudscale/plugins/os/data/os_menu.json +17 -0
  31. data/lib/cloudscale/plugins/os/preops/plugin_preop.rb +56 -0
  32. data/lib/cloudscale/plugins/os/sigar_cpu_perc.rb +54 -0
  33. data/lib/cloudscale/plugins/os/sigar_disk_iops.rb +55 -0
  34. data/lib/cloudscale/plugins/os/sigar_disk_space.rb +54 -0
  35. data/lib/cloudscale/plugins/os/sigar_net_byte_information.rb +53 -0
  36. data/lib/cloudscale/plugins/os/sigar_packet_information.rb +63 -0
  37. data/lib/cloudscale/plugins/os/sigar_ram_usage.rb +46 -0
  38. data/lib/cloudscale/plugins/os/sigar_swap_usage.rb +46 -0
  39. data/lib/cloudscale/plugins/plugin.rb +98 -0
  40. data/lib/cloudscale/plugins/postgres/postgres_server_status.rb +143 -0
  41. data/lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb +105 -0
  42. data/lib/cloudscale/plugins/preops/plugin_postgres_preop.rb +70 -0
  43. data/lib/cloudscale/registry.rb +48 -0
  44. data/lib/cloudscale/rest/rest_client.rb +198 -0
  45. data/lib/cloudscale/rest/rest_client_helper.rb +70 -0
  46. data/lib/cloudscale/schedule.rb +32 -0
  47. data/lib/cloudscale/store/agent/agent.store +7 -0
  48. data/lib/cloudscale/store/agent/agent_instance.store +11 -0
  49. data/lib/cloudscale/store/agent/influxdb.store +6 -0
  50. data/lib/cloudscale/store/plugin/token +1 -0
  51. data/lib/cloudscale/version.rb +8 -0
  52. data/lib/test/rest/rest_client_test.rb +50 -0
  53. data/lib/test/sigar/sigar_test.rb +36 -0
  54. metadata +264 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66a4ec23c44700c7d80cc2d00163a944079071a9
4
+ data.tar.gz: 96d0911073295d9ac5e0217c26da5b48dc372423
5
+ SHA512:
6
+ metadata.gz: d4d1648fee87cf5045706b90d86a47ddd59e96f22361be6aa5986a35e3d7b5c5c7c952d6956b7b2352aa21d62cb5956b0d1b8cab7220b41b9af0ad15408cf14f
7
+ data.tar.gz: e17a674df825b182654adbbf45faac820bab033b26d9aa9caad8b542715cf5daeebd8ed1187c37749ae10a6369797203fa65f72c400d0e49c1c021a6aad1d372
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Johannes Hiemer
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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Cloudscale
2
+
3
+ Monitoring Client for the evoila IaaS and PaaS Platform
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cloudscale'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cloudscale
20
+
21
+ To prepare system for monitor execution, run bin/prepare_monitor.sh.
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/cloudscale-monitor/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/bin/autospec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
data/bin/bundler ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'bundler' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('bundler', 'bundler')
data/bin/htmldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
data/bin/monitor ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'monitor' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('cloudscale', 'monitor')
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
data/lib/cloudscale.rb ADDED
@@ -0,0 +1,127 @@
1
+ require "optparse"
2
+ require "singleton"
3
+ require "yaml"
4
+ require "json"
5
+ require "#{File.dirname(__FILE__)}/cloudscale/version"
6
+ require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/init"
7
+ require "#{File.dirname(__FILE__)}/cloudscale/schedule"
8
+ require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/preops/general_preop"
9
+ require "#{File.dirname(__FILE__)}/cloudscale/plugins/plugin"
10
+ Dir["#{File.dirname(__FILE__)}/cloudscale/plugins/*/*.rb"].each { | f | require f }
11
+
12
+ ##
13
+ #
14
+ # @author Johannes Hiemer.
15
+ #
16
+ ##
17
+ module Cloudscale
18
+ module Monitor
19
+ options = {}
20
+ mandatory = Array.new
21
+ mandatoryGeneral = Array.new
22
+
23
+ scheduler = nil
24
+
25
+ Monitor::GeneralPreop.instance.init
26
+
27
+ parser = OptionParser.new do | parser |
28
+
29
+ parser.banner = "Usage: monitoring COMMAND [OPTIONS]"
30
+ parser.separator ""
31
+ parser.separator "Commands"
32
+ parser.separator " start: Start cloudscale monitoring agent"
33
+ parser.separator " stop: Stop cloudscale monitoring agent"
34
+ parser.separator ""
35
+ parser.separator " reset: This resets the Chart, Table and Coredata specification settings.
36
+ WARNING: Please be aware, that all collected data will be lost in your management environment."
37
+ parser.separator " delete: This removes the complete cloudscale monitoring agent. WARNING: Please be aware, that all
38
+ collected data AND the agent will be lost in your management environment."
39
+ parser.separator "Options"
40
+
41
+ parser.on("-v", "--version", "Show version information about this program and quit.") do
42
+ puts "Cloudscale Monitoring " + VERSION
43
+ exit
44
+ end
45
+
46
+ parser.separator "\n"
47
+ parser.separator "Monitoring specific Settings [Mandatory]"
48
+
49
+ Monitor::GeneralPreop.instance.options.each do | key, value |
50
+ if (value[:required])
51
+ mandatoryGeneral.push(key)
52
+ end
53
+ parser.on(value[:argument][1,2] + " n", value[:argument] + "=n", value[:description]) do | value |
54
+ Monitor::GeneralPreop.instance.set_option_value(key, value)
55
+ end
56
+ end
57
+
58
+ parser.separator "\n"
59
+ parser.separator "Plugin specific Settings [Mandatory]"
60
+
61
+ Plugins::PluginPreop.instance.options.each do | key, value |
62
+ if (value[:required])
63
+ mandatory.push(key)
64
+ end
65
+ parser.on(value[:argument][1,2] + " n", value[:argument] + "=n", value[:description]) do | value |
66
+ Plugins::PluginPreop.instance.set_option_value(key, value)
67
+ end
68
+ end
69
+ end
70
+
71
+ begin
72
+ parser.parse!
73
+ missingGeneral = mandatoryGeneral.select { | param |
74
+ Monitor::GeneralPreop.instance.get_option_value(param).nil?
75
+ }
76
+ missing = mandatory.select{ | param |
77
+ Plugins::PluginPreop.instance.get_option_value(param).nil?
78
+ }
79
+ if (!missing.empty? || !missingGeneral.empty?)
80
+ puts "\n"
81
+ puts "Error during execution: "
82
+ puts " Missing general options: #{missingGeneral.join(', ')}"
83
+ puts " Missing options: #{missing.join(', ')}"
84
+ puts "\n"
85
+ puts parser
86
+ exit
87
+ else
88
+ Plugins::PluginPreop.instance.save_options
89
+ Monitor::GeneralPreop.instance.save_options
90
+ end
91
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
92
+ puts $!.to_s
93
+ puts parser
94
+ exit
95
+ end
96
+
97
+ agent_instance = Monitor::Init.new(GeneralPreop.instance.get_option_value("token"))
98
+ agent_instance_id = registry = Monitor::Registry.instance.agent_instance_id
99
+
100
+ case ARGV[0]
101
+ when "start"
102
+ plugins = Set.new
103
+
104
+ Plugins::PluginPreop.instance.register
105
+
106
+ Plugins::Plugin.plugins.each do | plugin_class |
107
+ plugin = plugin_class.new
108
+ plugins << plugin
109
+ end
110
+
111
+ scheduler = Monitor::Schedule.new(plugins, agent_instance_id)
112
+ when "stop"
113
+ puts "call stop on options #{options.inspect}"
114
+ when "reset"
115
+ puts "Starting cleanup process"
116
+ Plugins::Plugin.reset(agent_instance_id)
117
+ Plugins::PluginPreop.instance.clear_options
118
+ when "delete"
119
+ puts "Starting removal process"
120
+ Plugins::Plugin.remove(agent_instance_id)
121
+ Plugins::PluginPreop.instance.clear_options
122
+ else
123
+ puts parser
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,63 @@
1
+ require "yaml"
2
+ require "logger"
3
+ require "#{File.dirname(__FILE__)}/../model/agent/agent_instance"
4
+ require "#{File.dirname(__FILE__)}/../model/agent/agent_instance_settings"
5
+ require "#{File.dirname(__FILE__)}/../model/constants/agent_instance_store"
6
+ require "#{File.dirname(__FILE__)}/../model/constants/agent_store"
7
+ require "#{File.dirname(__FILE__)}/../../rest/rest_client"
8
+
9
+ ##
10
+ #
11
+ # @author Johannes Hiemer.
12
+ #
13
+ ##
14
+ module Cloudscale
15
+ module Monitor
16
+ class Init
17
+ attr_accessor :log, :server, :client
18
+
19
+ def initialize(token)
20
+ @log = Logger.new(STDOUT)
21
+ @server = Socket.gethostname
22
+ @client = RestClientWrapper.instance
23
+ @registry = Monitor::Registry.instance
24
+
25
+ puts " "
26
+ puts "Running preflight verification for cloudscale monitoring agent"
27
+
28
+ if (@registry.stored_agent == nil)
29
+ raise "You did not provide any valid Agent file under /store/agent/agent.store."
30
+ end
31
+
32
+ agent = client.searchOne('agents', 'findByAgentId', { :agentId => @registry.stored_agent["agentId"] })
33
+
34
+ if (agent == nil)
35
+ raise "No agent registered yet. It is not allowed to connect this agent instance to cloudscale monitoring."
36
+ end
37
+
38
+ if (@registry.stored_agent_instance != nil)
39
+ agent_instance = client.searchOne('agentInstances',
40
+ 'findByAgentInstanceId', { :id => @registry.stored_agent_instance["agentInstanceId"] })
41
+ end
42
+
43
+ if (agent_instance == nil)
44
+ puts " No Instance of this agent was started previously, starting cloudscale monitoring agent for the first, registering..."
45
+
46
+ agent_instance_settings = Monitor::Settings.new(15, 0, 1500, 5)
47
+ agent_instance = Monitor::AgentInstance.new(RestClientWrapper.load_entity_ref(agent)["href"],
48
+ @registry.agent_instance_id, token, server, agent_instance_settings, Time.now.to_i * 1000)
49
+
50
+ client.post('agentInstances', agent_instance)
51
+ Constants::AgentInstance.create(agent_instance.to_h)
52
+ else
53
+ puts " Instance has been started previously, loading settings and existing data... \n\n"
54
+
55
+ agent_instance["lastInitialization"] = Time.now.to_i * 1000
56
+
57
+ client.patch('agentInstances', RestClientWrapper.load_entity_id(agent_instance), agent_instance)
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,60 @@
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
+ def self.setup_charts
49
+ if (!Plugins::PluginComponents.is_initialized())
50
+ Plugins::PluginComponents.init_charts()
51
+ end
52
+ end
53
+
54
+ def self.remove_charts
55
+ Plugins::PluginComponents.remove_charts()
56
+ end
57
+
58
+ end
59
+ end
60
+ end