cloudscale 0.0.8 → 0.0.9

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cloudscale +5 -0
  3. data/lib/cloudscale/monitor/agent/agent.rb +8 -2
  4. data/lib/cloudscale/monitor/reporter/influxdb_reporter.rb +29 -5
  5. data/lib/cloudscale/plugins/mongo/preops/mongodb_preop.rb +12 -4
  6. data/lib/cloudscale/plugins/mysql/data/mysql_chart.json +506 -0
  7. data/lib/cloudscale/plugins/mysql/data/mysql_menu.json +35 -0
  8. data/lib/cloudscale/plugins/mysql/mysql_counters.rb +90 -0
  9. data/lib/cloudscale/plugins/mysql/mysql_general_status.rb +119 -0
  10. data/lib/cloudscale/plugins/mysql/mysql_innodb.rb +113 -0
  11. data/lib/cloudscale/plugins/mysql/mysql_querycache.rb +59 -0
  12. data/lib/cloudscale/plugins/mysql/preops/mysql_preop.rb +95 -0
  13. data/lib/cloudscale/plugins/postgres/preops/postgres_preop.rb +12 -4
  14. data/lib/cloudscale/plugins/redis/data/redis_chart.json +110 -0
  15. data/lib/cloudscale/plugins/redis/data/redis_menu.json +17 -0
  16. data/lib/cloudscale/plugins/redis/preops/redis_preop.rb +117 -0
  17. data/lib/cloudscale/plugins/redis/redis_server_status.rb +227 -0
  18. data/lib/cloudscale/rest/rest_client.rb +14 -8
  19. data/lib/cloudscale/rest/rest_client_helper.rb +23 -16
  20. data/lib/cloudscale/schedule.rb +1 -0
  21. data/lib/cloudscale/store/agent/agent.store +1 -1
  22. data/lib/cloudscale/store/agent/agent_instance.store +11 -0
  23. data/lib/cloudscale/store/agent/influxdb.store +1 -1
  24. data/lib/cloudscale/version.rb +1 -1
  25. data/lib/store/plugin/host +1 -0
  26. data/lib/store/plugin/mongo-connect-timeout +1 -0
  27. data/lib/store/plugin/mongo-db +1 -0
  28. data/lib/store/plugin/mongo-host +1 -0
  29. data/lib/store/plugin/mongo-op-timeout +1 -0
  30. data/lib/store/plugin/mongo-password +1 -0
  31. data/lib/store/plugin/mongo-port +2 -0
  32. data/lib/store/plugin/mongo-ssl +2 -0
  33. data/lib/store/plugin/mongo-username +1 -0
  34. data/lib/store/plugin/mysql-db +0 -0
  35. data/lib/store/plugin/mysql-host +0 -0
  36. data/lib/store/plugin/mysql-password +0 -0
  37. data/lib/store/plugin/mysql-port +1 -0
  38. data/lib/store/plugin/mysql-username +0 -0
  39. data/lib/store/plugin/port +1 -0
  40. data/lib/store/plugin/postgres-db +0 -0
  41. data/lib/store/plugin/postgres-host +0 -0
  42. data/lib/store/plugin/postgres-password +0 -0
  43. data/lib/store/plugin/postgres-port +1 -0
  44. data/lib/store/plugin/postgres-username +0 -0
  45. data/lib/store/plugin/redis-db +0 -0
  46. data/lib/store/plugin/redis-host +0 -0
  47. data/lib/store/plugin/redis-password +0 -0
  48. data/lib/store/plugin/redis-port +1 -0
  49. data/lib/store/plugin/redis-reconnect-attempts +1 -0
  50. data/lib/store/plugin/redis-timeout +1 -0
  51. data/lib/store/plugin/redis-username +0 -0
  52. data/lib/store/plugin/token +1 -0
  53. metadata +45 -11
  54. data/bin/autospec +0 -16
  55. data/bin/bundler +0 -16
  56. data/bin/htmldiff +0 -16
  57. data/bin/ldiff +0 -16
  58. data/bin/monitor +0 -16
  59. data/bin/rake +0 -16
  60. data/bin/restclient +0 -16
  61. data/bin/rspec +0 -16
@@ -17,15 +17,23 @@ module Cloudscale
17
17
  class PostgresPreop < Preops::PluginPreop
18
18
  include Singleton
19
19
 
20
- attr_accessor :options
20
+ attr_accessor :options, :connection
21
21
 
22
22
  def is_enabled
23
- true
23
+ enabled = false
24
+
25
+ if !defined? PG
26
+ enabled = false
27
+ end
28
+
29
+ enabled
24
30
  end
25
31
 
26
32
  def register
27
- init_charts("#{File.dirname(__FILE__)}/../data/postgres_chart.json")
28
- init_menus("#{File.dirname(__FILE__)}/../data/postgres_menu.json")
33
+ if is_enabled
34
+ init_charts("#{File.dirname(__FILE__)}/../data/postgres_chart.json")
35
+ init_menus("#{File.dirname(__FILE__)}/../data/postgres_menu.json")
36
+ end
29
37
  end
30
38
 
31
39
  def initialize
@@ -0,0 +1,110 @@
1
+ {
2
+ "postgres.rows" : {
3
+ "chartId" : "postgres.rows",
4
+ "options" : {
5
+ "title" : { "text" : "Row Stats" },
6
+ "subtitle" : { "text" : "The row usage/performance details" },
7
+ "chart" : {
8
+ "type": "area"
9
+ },
10
+ "xAxis" : {
11
+ "title" : {
12
+ "text" : "Date"
13
+ },
14
+ "type" : "datetime"
15
+ },
16
+ "yAxis" : {
17
+ "title" : {
18
+ "text" : "short"
19
+ },
20
+ "type" : "linear"
21
+ },
22
+ "legend" : {
23
+ "title" : "Row Statistics",
24
+ "enabled" : true,
25
+ "align" : "center",
26
+ "verticalAlign" : "bottom"
27
+ }
28
+ },
29
+ "queries" :[{
30
+ "command" : "select mean(value) from /^[[agentInstanceId]].postgres.rows\\./i"
31
+ }],
32
+ "agentInstanceId" : null,
33
+ "menuId" : "postgres.general",
34
+ "order" : 0,
35
+ "width" : 12,
36
+ "height" : 0
37
+ },
38
+ "postgres.transactions" : {
39
+ "chartId" : "postgres.transactions",
40
+ "options" : {
41
+ "title" : { "text" : "Transaction Stats" },
42
+ "subtitle" : { "text" : "The transaction usage/performance details" },
43
+ "chart" : {
44
+ "type": "area"
45
+ },
46
+ "xAxis" : {
47
+ "title" : {
48
+ "text" : "Date"
49
+ },
50
+ "type" : "datetime"
51
+ },
52
+ "yAxis" : {
53
+ "title" : {
54
+ "text" : "short"
55
+ },
56
+ "type" : "linear"
57
+ },
58
+ "legend" : {
59
+ "title" : "Transaction Statistics",
60
+ "enabled" : true,
61
+ "align" : "center",
62
+ "verticalAlign" : "bottom"
63
+ }
64
+ },
65
+ "queries" :[{
66
+ "command" : "select mean(value) from /^[[agentInstanceId]].postgres.transactions\\./i"
67
+ }],
68
+ "agentInstanceId" : null,
69
+ "menuId" : "postgres.general",
70
+ "order" : 0,
71
+ "width" : 12,
72
+ "height" : 0
73
+ },
74
+ "postgres.bulk" : {
75
+ "chartId" : "postgres.bulk",
76
+ "options" : {
77
+ "title" : { "text" : "Bulk Stats" },
78
+ "subtitle" : { "text" : "The bulk usage/performance details" },
79
+ "chart" : {
80
+ "type": "area"
81
+ },
82
+ "xAxis" : {
83
+ "title" : {
84
+ "text" : "Date"
85
+ },
86
+ "type" : "datetime"
87
+ },
88
+ "yAxis" : {
89
+ "title" : {
90
+ "text" : "short"
91
+ },
92
+ "type" : "linear"
93
+ },
94
+ "legend" : {
95
+ "title" : "Bulk Statistics",
96
+ "enabled" : true,
97
+ "align" : "center",
98
+ "verticalAlign" : "bottom"
99
+ }
100
+ },
101
+ "queries" :[{
102
+ "command" : "select mean(value) from /^[[agentInstanceId]].postgres.bulk\\./i"
103
+ }],
104
+ "agentInstanceId" : null,
105
+ "menuId" : "postgres.general",
106
+ "order" : 0,
107
+ "width" : 12,
108
+ "height" : 0
109
+ }
110
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "postgres":{
3
+ "menuId" : "postgresql",
4
+ "label" : "PostgreSQL",
5
+ "description": "PostgreSQL information",
6
+ "order" : 1,
7
+ "agentInstanceId" : null,
8
+ "subItems" : [
9
+ {
10
+ "menuId" : "postgres.general",
11
+ "label" : "General Stats",
12
+ "description" : "All relevant information regarding the PostgreSQL Endpoint",
13
+ "order" : 1
14
+ }
15
+ ]
16
+ }
17
+ }
@@ -0,0 +1,117 @@
1
+ require "logger"
2
+ begin
3
+ require "redis"
4
+ rescue LoadError
5
+ puts "WARNING: Load error Redis needs to be installed via bundler"
6
+ end
7
+ require "singleton"
8
+ require "#{File.dirname(__FILE__)}/../../preops/plugin_preop"
9
+
10
+ ##
11
+ #
12
+ # @author Johannes Hiemer.
13
+ #
14
+ ##
15
+ module Cloudscale
16
+ module Preops
17
+ class RedisPreop < Preops::PluginPreop
18
+ include Singleton
19
+
20
+ attr_accessor :options, :connection
21
+
22
+ def is_enabled
23
+ enabled = false
24
+
25
+ if !defined? Redis
26
+ enabled = false
27
+ end
28
+
29
+ enabled
30
+ end
31
+
32
+ def register
33
+ if is_enabled
34
+ init_charts("#{File.dirname(__FILE__)}/../data/redis_chart.json")
35
+ init_menus("#{File.dirname(__FILE__)}/../data/redis_menu.json")
36
+ end
37
+ end
38
+
39
+ def initialize
40
+ self.init
41
+ begin
42
+ timeout = Redis::Client::DEFAULTS[:timeout]
43
+ reconnect_attempts = Redis::Client::DEFAULTS[:reconnect_attempts]
44
+ rescue
45
+ timeout = 30
46
+ reconnect_attempts = 5
47
+ end
48
+
49
+ @options = {
50
+ :"redis-host" => {
51
+ :argument => "--redis-host",
52
+ :description => "Host for your Redis Instance (e.g. host.instance.com)",
53
+ :required => true,
54
+ :value => nil
55
+ },
56
+ :"redis-port" => {
57
+ :argument => "--redis-port",
58
+ :description => "Port for your Redis Instance (Standard 5432)",
59
+ :required => false,
60
+ :value => 6379
61
+ },
62
+ :"redis-db" => {
63
+ :argument => "--redis-db",
64
+ :description => "Database of your Redis instance",
65
+ :required => false,
66
+ :value => nil
67
+ },
68
+ :"redis-username" => {
69
+ :argument => "--redis-username",
70
+ :description => "Username for your Redis instance",
71
+ :required => false,
72
+ :value => nil
73
+ },
74
+ :"redis-password" => {
75
+ :argument => "--redis-password",
76
+ :description => "Password for your Redis instance",
77
+ :required => false,
78
+ :value => nil
79
+ },
80
+ :"redis-timeout" => {
81
+ :argument => "--redis-timeout",
82
+ :description => "Timeout for your Redis instance",
83
+ :required => false,
84
+ :value => timeout
85
+ },
86
+ :"redis-reconnect-attempts" => {
87
+ :argument => "--redis-reconnect-attempts",
88
+ :description => "Reconnect attempts for your Redis instance",
89
+ :required => false,
90
+ :value => reconnect_attempts
91
+ }
92
+ }
93
+ end
94
+
95
+ def connection
96
+ if @connection == nil
97
+ if defined? Redis
98
+ begin
99
+ options = {
100
+ host: @options[:'redis-host'][:value],
101
+ port: @options[:'redis-port'][:value],
102
+ timeout: @options[:'redis-timeout'][:value],
103
+ reconnect_attempts: @options[:'redis-reconnect-attempts'][:value]
104
+ }
105
+ options[:password] = @options[:'redis-password'][:value] if @options[:'redis-password'][:value]
106
+ @connection = Redis.new(options)
107
+ rescue PGError => e
108
+ puts e.message
109
+ end
110
+ end
111
+ end
112
+ @connection
113
+ end
114
+
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,227 @@
1
+ #require "#{File.dirname(__FILE__)}/../preops/plugin_postgres_preop"
2
+ require "#{File.dirname(__FILE__)}/../plugin"
3
+
4
+ ##
5
+ #
6
+ # @author Johannes Hiemer.
7
+ #
8
+ ##
9
+ module Cloudscale
10
+ module Plugins
11
+ class RedisServerStatus < Plugins::Plugin
12
+ attr_reader :connection
13
+
14
+ SKIP_KEYS_REGEX = ['gcc_version', 'master_host', 'master_link_status',
15
+ 'master_port', 'mem_allocator', 'multiplexing_api', 'process_id',
16
+ 'redis_git_dirty', 'redis_git_sha1', 'redis_version', '^role',
17
+ 'run_id', '^slave', 'used_memory_human', 'used_memory_peak_human',
18
+ 'redis_mode', 'os', 'arch_bits', 'tcp_port',
19
+ 'rdb_last_bgsave_status', 'aof_last_bgrewrite_status', 'config_file',
20
+ 'redis_build_id']
21
+
22
+ def is_enabled
23
+ Preops::RedisPreop.instance.is_enabled
24
+ end
25
+
26
+ def initialize
27
+ super
28
+ if is_enabled
29
+ @connection = Preops::RedisPreop.instance.connection
30
+ end
31
+ end
32
+
33
+ def collect(agentInstanceId)
34
+ registry = Monitor::Registry.instance
35
+ metrics = Metrics::Agent.new
36
+ log.info("Calling Collect on RedisServerStatus")
37
+ report_memory(registry, metrics)
38
+ report_data(registry, metrics)
39
+ end
40
+
41
+ def report_memory(registry, metrics)
42
+ used_memory = @connection.info.fetch('used_memory').to_i.div(1024)
43
+
44
+ registry.metrics["redis.memory.usage"] = metrics.gauge :used_memory_u do
45
+ { :value => used_memory }
46
+ end
47
+ end
48
+
49
+ def report_data(registry, metrics)
50
+ info = @connection.info
51
+
52
+ registry.metrics["redis.uptime.seconds"] = metrics.gauge :uptime_in_seconds do
53
+ { :value => info["uptime_in_seconds"] }
54
+ end
55
+
56
+ registry.metrics["redis.lru.clock"] = metrics.gauge :lru_clock do
57
+ { :value => info["lru_clock"] }
58
+ end
59
+
60
+ registry.metrics["redis.connected.clients"] = metrics.gauge :connected_clients do
61
+ { :value => info["connected_clients"] }
62
+ end
63
+
64
+ registry.metrics["redis.client.longest.output.list"] = metrics.gauge :client_longest_output_list do
65
+ { :value => info["client_longest_output_list"] }
66
+ end
67
+
68
+ registry.metrics["redis.client.biggest.input.buffer"] = metrics.gauge :client_biggest_input_buf do
69
+ { :value => info["client_biggest_input_buf"] }
70
+ end
71
+
72
+ registry.metrics["redis.blocked"] = metrics.gauge :blocked_clients do
73
+ { :value => info["blocked_clients"] }
74
+ end
75
+
76
+ registry.metrics["redis.memory.used"] = metrics.gauge :used_memory do
77
+ { :value => info["used_memory"] }
78
+ end
79
+
80
+ registry.metrics["redis.memory.rss"] = metrics.gauge :used_memory_rss do
81
+ { :value => info["used_memory_rss"] }
82
+ end
83
+
84
+ registry.metrics["redis.memory.peak"] = metrics.gauge :used_memory_peak do
85
+ { :value => info["used_memory_peak"] }
86
+ end
87
+
88
+ registry.metrics["redis.memory.lua"] = metrics.gauge :used_memory_lua do
89
+ { :value => info["used_memory_lua"] }
90
+ end
91
+
92
+ registry.metrics["redis.memory.fragmentation.ratio"] = metrics.gauge :mem_fragmentation_ratio do
93
+ { :value => info["mem_fragmentation_ratio"] }
94
+ end
95
+
96
+ registry.metrics["redis.rdb.changes.since.last.save"] = metrics.gauge :rdb_changes_since_last_save do
97
+ { :value => info["rdb_changes_since_last_save"] }
98
+ end
99
+
100
+ registry.metrics["redis.rdb.bgsave_in_progress"] = metrics.gauge :rdb_bgsave_in_progress do
101
+ { :value => info["rdb_bgsave_in_progress"] }
102
+ end
103
+
104
+ registry.metrics["redis.rdb.changes.since.last.save"] = metrics.gauge :rdb_changes_since_last_save do
105
+ { :value => info["rdb_changes_since_last_save"] }
106
+ end
107
+
108
+ registry.metrics["redis.rdb.current.bgsave.time"] = metrics.gauge :rdb_current_bgsave_time_sec do
109
+ { :value => info["rdb_current_bgsave_time_sec"] }
110
+ end
111
+
112
+ registry.metrics["redis.rdb.bgsave.time"] = metrics.gauge :rdb_current_bgsave_time_sec do
113
+ { :value => info["rdb_current_bgsave_time_sec"] }
114
+ end
115
+
116
+ registry.metrics["redis.aof.rewrite.progress"] = metrics.gauge :aof_rewrite_in_progress do
117
+ { :value => info["aof_rewrite_in_progress"] }
118
+ end
119
+
120
+ registry.metrics["redis.aof.rewrite.scheduled"] = metrics.gauge :aof_rewrite_scheduled do
121
+ { :value => info["aof_rewrite_scheduled"] }
122
+ end
123
+
124
+ registry.metrics["redis.aof.last.rewrite"] = metrics.gauge :aof_last_rewrite_time_sec do
125
+ { :value => info["aof_last_rewrite_time_sec"] }
126
+ end
127
+
128
+ registry.metrics["redis.aof.current.rewrite"] = metrics.gauge :aof_current_rewrite_time_sec do
129
+ { :value => info["aof_current_rewrite_time_sec"] }
130
+ end
131
+
132
+ registry.metrics["redis.total.connections.received"] = metrics.gauge :total_connections_received do
133
+ { :value => info["total_connections_received"] }
134
+ end
135
+
136
+ registry.metrics["redis.total.commands.processed"] = metrics.gauge :total_commands_processed do
137
+ { :value => info["total_commands_processed"] }
138
+ end
139
+
140
+ registry.metrics["redis.instantaneous.ops.per.sec"] = metrics.gauge :instantaneous_ops_per_sec do
141
+ { :value => info["instantaneous_ops_per_sec"] }
142
+ end
143
+
144
+ registry.metrics["redis.rejected.connections"] = metrics.gauge :rejected_connections do
145
+ { :value => info["rejected_connections"] }
146
+ end
147
+
148
+ registry.metrics["redis.sync.full"] = metrics.gauge :sync_full do
149
+ { :value => info["sync_full"] }
150
+ end
151
+
152
+ registry.metrics["redis.sync.partial.ok"] = metrics.gauge :sync_partial_ok do
153
+ { :value => info["sync_partial_ok"] }
154
+ end
155
+
156
+ registry.metrics["redis.sync.partial.err"] = metrics.gauge :sync_partial_err do
157
+ { :value => info["sync_partial_err"] }
158
+ end
159
+
160
+ registry.metrics["redis.keys.expired"] = metrics.gauge :expired_keys do
161
+ { :value => info["expired_keys"] }
162
+ end
163
+
164
+ registry.metrics["redis.keys.evicted"] = metrics.gauge :evicted_keys do
165
+ { :value => info["evicted_keys"] }
166
+ end
167
+
168
+ registry.metrics["redis.keyspace.hits"] = metrics.gauge :keyspace_hits do
169
+ { :value => info["keyspace_hits"] }
170
+ end
171
+
172
+ registry.metrics["redis.keyspace.misses"] = metrics.gauge :keyspace_misses do
173
+ { :value => info["keyspace_misses"] }
174
+ end
175
+
176
+ registry.metrics["redis.pubsub.channels"] = metrics.gauge :pubsub_channels do
177
+ { :value => info["pubsub_channels"] }
178
+ end
179
+
180
+ registry.metrics["redis.pubsub.patterns"] = metrics.gauge :pubsub_patterns do
181
+ { :value => info["pubsub_patterns"] }
182
+ end
183
+
184
+ registry.metrics["redis.latest.fork.used"] = metrics.gauge :latest_fork_usec do
185
+ { :value => info["latest_fork_usec"] }
186
+ end
187
+
188
+ registry.metrics["redis.connected.slaves"] = metrics.gauge :connected_slaves do
189
+ { :value => info["connected_slaves"] }
190
+ end
191
+
192
+ registry.metrics["redis.master.repl.offset"] = metrics.gauge :master_repl_offset do
193
+ { :value => info["master_repl_offset"] }
194
+ end
195
+
196
+ registry.metrics["redis.repl.backlog.active"] = metrics.gauge :repl_backlog_active do
197
+ { :value => info["repl_backlog_active"] }
198
+ end
199
+
200
+ registry.metrics["redis.repl.backlog.size"] = metrics.gauge :repl_backlog_size do
201
+ { :value => info["repl_backlog_size"] }
202
+ end
203
+
204
+ registry.metrics["redis.repl.backlog.histlen"] = metrics.gauge :repl_backlog_histlen do
205
+ { :value => info["repl_backlog_histlen"] }
206
+ end
207
+
208
+ registry.metrics["redis.cpu.sys"] = metrics.gauge :used_cpu_sys do
209
+ { :value => info["used_cpu_sys"] }
210
+ end
211
+
212
+ registry.metrics["redis.cpu.user"] = metrics.gauge :used_cpu_user do
213
+ { :value => info["used_cpu_user"] }
214
+ end
215
+
216
+ registry.metrics["redis.cpu.sys.children"] = metrics.gauge :used_cpu_sys_children do
217
+ { :value => info["used_cpu_sys_children"] }
218
+ end
219
+
220
+ registry.metrics["redis.cpu.user.children"] = metrics.gauge :used_cpu_user_children do
221
+ { :value => info["used_cpu_user_children"] }
222
+ end
223
+ end
224
+
225
+ end
226
+ end
227
+ end