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
@@ -0,0 +1,362 @@
1
+ {
2
+ "os.cpu.perc" : {
3
+ "chartId" : "os.cpu.perc",
4
+ "options" : {
5
+ "title" : { "text" : "CPU Usage" },
6
+ "subtitle" : { "text" : "The CPU 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" : "CPU Usage",
24
+ "enabled" : true,
25
+ "align" : "center",
26
+ "verticalAlign" : "bottom"
27
+ }
28
+ },
29
+ "queries" :[{
30
+ "command" : "select mean(value) from /^[[agentInstanceId]].os.cpu.perc\\./i"
31
+ }],
32
+ "agentInstanceId" : null,
33
+ "menuId" : "os.overview",
34
+ "order" : 0,
35
+ "width" : 12,
36
+ "height" : 0
37
+ },
38
+ "os.ram" : {
39
+ "chartId" : "os.ram",
40
+ "options" : {
41
+ "title" : { "text" : "RAM Usage" },
42
+ "subtitle" : { "text" : "The RAM 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" : "RAM Usage",
60
+ "enabled" : true,
61
+ "align" : "center",
62
+ "verticalAlign" : "bottom"
63
+ }
64
+ },
65
+ "queries" : [{
66
+ "command" : "select mean(value) from /^[[agentInstanceId]].os.ram\\./i"
67
+ }],
68
+ "agentInstanceId" : null,
69
+ "menuId" : "os.overview",
70
+ "order" : 0,
71
+ "width" : 6,
72
+ "height" : 0
73
+ },
74
+ "os.swap" : {
75
+ "chartId" : "os.swap",
76
+ "options" : {
77
+ "title" : { "text" : "Swap Usage" },
78
+ "subtitle" : { "text" : "The Swap 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" : "Swap Usage",
96
+ "enabled" : true,
97
+ "align" : "center",
98
+ "verticalAlign" : "bottom"
99
+ }
100
+ },
101
+ "queries" : [{
102
+ "command" : "select mean(value) from /^[[agentInstanceId]].os.swap\\./i"
103
+ }],
104
+ "agentInstanceId" : null,
105
+ "menuId" : "os.overview",
106
+ "order" : 0,
107
+ "width" : 6,
108
+ "height" : 0
109
+ },
110
+ "os.net.received.packets" : {
111
+ "chartId" : "os.net.received.packets",
112
+ "options" : {
113
+ "title" : { "text" : "Net Usage received" },
114
+ "subtitle" : { "text" : "The net usage packets received usage/performance details" },
115
+ "chart" : {
116
+ "type": "area"
117
+ },
118
+ "xAxis" : {
119
+ "title" : {
120
+ "text" : "Date"
121
+ },
122
+ "type" : "datetime"
123
+ },
124
+ "yAxis" : {
125
+ "title" : {
126
+ "text" : "bytes"
127
+ },
128
+ "type" : "linear"
129
+ },
130
+ "legend" : {
131
+ "title" : "Net Usage received",
132
+ "enabled" : true,
133
+ "align" : "center",
134
+ "verticalAlign" : "bottom"
135
+ }
136
+ },
137
+ "queries" : [{
138
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.network.received.packets\\./i WHERE time > now() - 300s GROUP BY time(10s)"
139
+ }],
140
+ "agentInstanceId" : null,
141
+ "menuId" : "os.overview",
142
+ "order" : 0,
143
+ "width" : 12,
144
+ "height" : 0
145
+ },
146
+ "os.net.send.packets" : {
147
+ "chartId" : "os.net.send.packets",
148
+ "options" : {
149
+ "title" : { "text" : "Net Usage packets send" },
150
+ "subtitle" : { "text" : "The net usage packets send usage/performance details" },
151
+ "chart" : {
152
+ "type": "area"
153
+ },
154
+ "xAxis" : {
155
+ "title" : {
156
+ "text" : "Date"
157
+ },
158
+ "type" : "datetime"
159
+ },
160
+ "yAxis" : {
161
+ "title" : {
162
+ "text" : "bytes"
163
+ },
164
+ "type" : "linear"
165
+ },
166
+ "legend" : {
167
+ "title" : "Net Usage send",
168
+ "enabled" : true,
169
+ "align" : "center",
170
+ "verticalAlign" : "bottom"
171
+ }
172
+ },
173
+ "queries" : [{
174
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.network.send.packets\\./i WHERE time > now() - 300s GROUP BY time(10s)"
175
+ }],
176
+ "agentInstanceId" : null,
177
+ "menuId" : "os.overview",
178
+ "order" : 0,
179
+ "width" : 12,
180
+ "height" : 0
181
+ },
182
+ "os.net.received.bytes" : {
183
+ "chartId" : "os.net.received.bytes",
184
+ "options" : {
185
+ "title" : { "text" : "Net Usage bytes received" },
186
+ "subtitle" : { "text" : "The net usage bytes received usage/performance details" },
187
+ "chart" : {
188
+ "type": "area"
189
+ },
190
+ "xAxis" : {
191
+ "title" : {
192
+ "text" : "Date"
193
+ },
194
+ "type" : "datetime"
195
+ },
196
+ "yAxis" : {
197
+ "title" : {
198
+ "text" : "bytes"
199
+ },
200
+ "type" : "linear"
201
+ },
202
+ "legend" : {
203
+ "title" : "Net Usage bytes received",
204
+ "enabled" : true,
205
+ "align" : "center",
206
+ "verticalAlign" : "bottom"
207
+ }
208
+ },
209
+ "queries" : [{
210
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.network.received.bytes\\./i WHERE time > now() - 300s GROUP BY time(10s)"
211
+ }],
212
+ "agentInstanceId" : null,
213
+ "menuId" : "os.overview",
214
+ "order" : 0,
215
+ "width" : 12,
216
+ "height" : 0
217
+ },
218
+ "os.net.send.bytes" : {
219
+ "chartId" : "os.net.send.bytes",
220
+ "options" : {
221
+ "title" : { "text" : "Net Usage bytes send" },
222
+ "subtitle" : { "text" : "The net usage bytes send usage/performance details" },
223
+ "chart" : {
224
+ "type": "area"
225
+ },
226
+ "xAxis" : {
227
+ "title" : {
228
+ "text" : "Date"
229
+ },
230
+ "type" : "datetime"
231
+ },
232
+ "yAxis" : {
233
+ "title" : {
234
+ "text" : "bytes"
235
+ },
236
+ "type" : "linear"
237
+ },
238
+ "legend" : {
239
+ "title" : "Net Usage bytes send",
240
+ "enabled" : true,
241
+ "align" : "center",
242
+ "verticalAlign" : "bottom"
243
+ }
244
+ },
245
+ "queries" : [{
246
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.network.send.bytes\\./i WHERE time > now() - 300s GROUP BY time(10s)"
247
+ }],
248
+ "agentInstanceId" : null,
249
+ "menuId" : "os.overview",
250
+ "order" : 0,
251
+ "width" : 12,
252
+ "height" : 0
253
+ },
254
+ "os.disk.usage" : {
255
+ "chartId" : "os.disk.usage",
256
+ "options" : {
257
+ "title" : { "text" : "Disk Usage" },
258
+ "subtitle" : { "text" : "The disk usage" },
259
+ "chart" : {
260
+ "type": "pie"
261
+ },
262
+ "xAxis" : {
263
+ "title" : {
264
+ "text" : "Last 15 Minutes"
265
+ },
266
+ "type" : "datetime"
267
+ },
268
+ "yAxis" : {
269
+ "title" : {
270
+ "text" : "bytes"
271
+ },
272
+ "type" : "linear"
273
+ },
274
+ "legend" : {
275
+ "title" : "Disk Usage",
276
+ "enabled" : true,
277
+ "align" : "center",
278
+ "verticalAlign" : "bottom"
279
+ }
280
+ },
281
+ "queries" : [{
282
+ "command" : "select value from /^[[agentInstanceId]].os.disk.usage\\./i where time > now() - 15m group by time(15m) limit 1"
283
+ }],
284
+ "agentInstanceId" : null,
285
+ "menuId" : "os.overview",
286
+ "order" : 0,
287
+ "width" : 6,
288
+ "height" : 0
289
+ },
290
+ "os.disk.read" : {
291
+ "chartId" : "os.disk.read",
292
+ "options" : {
293
+ "title" : { "text" : "Disk read Usage" },
294
+ "subtitle" : { "text" : "The disk read usage/performance details" },
295
+ "chart" : {
296
+ "type": "area"
297
+ },
298
+ "xAxis" : {
299
+ "title" : {
300
+ "text" : "Date"
301
+ },
302
+ "type" : "datetime"
303
+ },
304
+ "yAxis" : {
305
+ "title" : {
306
+ "text" : "bytes"
307
+ },
308
+ "type" : "linear"
309
+ },
310
+ "legend" : {
311
+ "title" : "Disk read usage",
312
+ "enabled" : true,
313
+ "align" : "center",
314
+ "verticalAlign" : "bottom"
315
+ }
316
+ },
317
+ "queries" : [{
318
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.disk.iops\\./i WHERE time > now() - 300s GROUP BY time(10s)"
319
+ }],
320
+ "agentInstanceId" : null,
321
+ "menuId" : "os.overview",
322
+ "order" : 0,
323
+ "width" : 6,
324
+ "height" : 0
325
+ },
326
+ "os.disk.write" : {
327
+ "chartId" : "os.disk.write",
328
+ "options" : {
329
+ "title" : { "text" : "Disk write Usage" },
330
+ "subtitle" : { "text" : "The disk write usage/performance details" },
331
+ "chart" : {
332
+ "type": "area"
333
+ },
334
+ "xAxis" : {
335
+ "title" : {
336
+ "text" : "Date"
337
+ },
338
+ "type" : "datetime"
339
+ },
340
+ "yAxis" : {
341
+ "title" : {
342
+ "text" : "bytes"
343
+ },
344
+ "type" : "linear"
345
+ },
346
+ "legend" : {
347
+ "title" : "Disk write usage",
348
+ "enabled" : true,
349
+ "align" : "center",
350
+ "verticalAlign" : "bottom"
351
+ }
352
+ },
353
+ "queries" : [{
354
+ "command" : "select derivative(value) from /^[[agentInstanceId]].os.disk.iops\\./i WHERE time > now() - 300s GROUP BY time(10s)"
355
+ }],
356
+ "agentInstanceId" : null,
357
+ "menuId" : "os.overview",
358
+ "order" : 0,
359
+ "width" : 6,
360
+ "height" : 0
361
+ }
362
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "os":{
3
+ "menuId" : "os",
4
+ "label" : "Operating System",
5
+ "description": "All Operating System relevant information",
6
+ "order" : 1,
7
+ "agentInstanceId" : null,
8
+ "subItems" : [
9
+ {
10
+ "menuId" : "os.overview",
11
+ "label" : "OS Overview",
12
+ "description" : "All relevant information regarding the currently running Operating System below the Application",
13
+ "order" : 1
14
+ }
15
+ ]
16
+ }
17
+ }
@@ -0,0 +1,57 @@
1
+ #require "#{File.dirname(__FILE__)}/../preops/plugin_mongodb_preop"
2
+ require "#{File.dirname(__FILE__)}/../plugin"
3
+
4
+ ##
5
+ #
6
+ # @author Johannes Hiemer.
7
+ #
8
+ ##
9
+ module Cloudscale
10
+ module Plugins
11
+ class MongoDbStatus < Plugins::Plugin
12
+ attr_reader
13
+
14
+ def log
15
+ @log = Logger.new(STDOUT)
16
+ end
17
+
18
+ def is_enabled
19
+ false
20
+ end
21
+
22
+ def initialize
23
+ super
24
+ if is_enabled
25
+ end
26
+ end
27
+
28
+ def collect(agentInstanceId)
29
+ log.info("Calling Collect on MongoDbStatus")
30
+ stats = @db.stats
31
+
32
+ registry.metrics["mongo.status.objects"] = metrics.gauge :status_objects do
33
+ { :value => stats['objects'] }
34
+ end
35
+
36
+ report(indexMetric, menu, stats['indexes'], false, agentInstanceId, "dbIndexChart",
37
+ "Indexes in database", "Total number of indexes in the database" , "area", "Time", "Count", "c", nil)
38
+
39
+ report(dataSizeMetric, menu, stats['dataSize'], false, agentInstanceId, "dbDataSizeChart",
40
+ "Data size of database", "Total data size of the database" , "area", "Time", "MB", "MB", nil)
41
+
42
+ report(indexSizeMetric, menu, stats['indexSize'], false, agentInstanceId, "dbStorageSizeChart",
43
+ "Storage size of database", "Total storage size of the database", "area", "Time", "MB", "MB", nil)
44
+
45
+ report(storageSizeMetric, menu, stats['storageSize'], false, agentInstanceId, "dbIndexSizeChart",
46
+ "Index size of database", "Total index size of the database" , "area", "Time", "MB", "MB", nil)
47
+
48
+ report(collectionsMetric, menu, stats['collections'], false, agentInstanceId, "dbCollectionsChart",
49
+ "Collections in database", "Total number of collections in the database" , "area", "Time", "Count", "c", nil)
50
+
51
+ report(avgObjSizeMetric, menu, stats['avgObjSize'], false, agentInstanceId, "dbAvgObjSizeChart",
52
+ "Average object size in database", "The average object size across all collections in the database" , "area", "Time", "MB", "MB", nil)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,103 @@
1
+ #require "#{File.dirname(__FILE__)}/../preops/plugin_mongodb_preop"
2
+ require "#{File.dirname(__FILE__)}/../plugin"
3
+
4
+ ##
5
+ #
6
+ # @author Johannes Hiemer.
7
+ #
8
+ ##
9
+ module Cloudscale
10
+ module Plugins
11
+ class MongoReplicaStatus < Plugins::Plugin
12
+
13
+ attr_reader :menu_replicaClusterStatus, :db
14
+ def log
15
+ @log = Logger.new(STDOUT)
16
+ end
17
+
18
+ def is_enabled
19
+ false
20
+ end
21
+
22
+ def initialize
23
+ super
24
+ if is_enabled
25
+ menus = Plugins::PluginMenus.load_hash()
26
+ @menu_replicaClusterStatus = load_menu(menus["mongodb-server-stats"], "replicaClusterStatus")
27
+
28
+ @db = Plugins::PluginPreop.instance.db
29
+ components = Plugins::PluginComponents.load_hash()
30
+ @metric = load_metric(components["mongodb-replica-stats"], "replicaClusterStatus")
31
+ end
32
+ end
33
+
34
+ def collectHourly(agentInstanceId)
35
+ log.info("Calling Collect on MongoReplicaStatus")
36
+ replset_status = db.command({'replSetGetStatus' => 1}, :check_response => false)
37
+
38
+ unless replset_status['ok'] == 1
39
+ return "Node isn't a member of a Replica Set","Unable to fetch Replica Set status information."
40
+ end
41
+
42
+ body = Array.new
43
+ body.push(["Replica Set", replset_status['set']])
44
+ body.push(["Replica Set State", get_replica_state(replset_status['myState'])])
45
+
46
+ primary = replset_status['members'].detect { | member | member['state'] == 1 }
47
+ if primary
48
+ member = replset_status['members'].detect do | member |
49
+ member['self']
50
+ end
51
+
52
+ if member
53
+ body.push(["Optime Difference for member " + member["name"], current_member['optimeDate'] - primary['optimeDate']])
54
+ end
55
+ end
56
+
57
+ primary_server_table = Monitor::Table.new("replicaClusterStatus", "Replica Status Information", nil, body, "compact")
58
+ primary_server_table.caption = "Replica Status Information for a MongoDB Cluster"
59
+ persist_table(primary_server_table, agentInstanceId, metric["metricId"])
60
+
61
+ head = ["Name", "Error Message (most recent)", "Health", "State", "Uptime", "Optime Date", "Last Heartbeat", "Last Hearbeat Received",
62
+ "Last Heartbeat Message", "Ping Ms"]
63
+ memberBody = Array.new
64
+ replset_status['members'].detect do | member |
65
+ memberBody.push(member["name"], member["errmsg"], member["health"], member["stateStr"], member["uptime"],
66
+ member["optimeDate"], member["lastHeartbeat"], member["lastHeartbeatRecv"], member["lastHeartbeatMessage"],
67
+ member["pingMs"])
68
+ end
69
+ member_server_table = Monitor::Table.new("replicaClusterStatus", "Replica Status Information", nil, memberBody, "compact")
70
+ member_server_table.caption = "Replica Status Information for a MongoDB Cluster"
71
+ persist_table(member_server_table, agentInstanceId, menu_replicaClusterStatus)
72
+
73
+ end
74
+
75
+ def get_replica_state(state)
76
+ member_state = case state
77
+ when 0
78
+ 'Starting Up'
79
+ when 1
80
+ 'Primary'
81
+ when 2
82
+ 'Secondary'
83
+ when 3
84
+ 'Recovering'
85
+ when 4
86
+ 'Fatal'
87
+ when 5
88
+ 'Starting up (forking threads)'
89
+ when 6
90
+ 'Unknown'
91
+ when 7
92
+ 'Arbiter'
93
+ when 8
94
+ 'Down'
95
+ when 9
96
+ 'Rollback'
97
+ end
98
+ return member_state
99
+ end
100
+
101
+ end
102
+ end
103
+ end