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.
- checksums.yaml +4 -4
- data/lib/cloudscale.rb +37 -25
- data/lib/cloudscale/monitor/agent/{init.rb → agent.rb} +42 -1
- data/lib/cloudscale/monitor/plugin/settings_db.rb +60 -0
- data/lib/cloudscale/monitor/{agent/preops → preops}/general_preop.rb +0 -0
- data/lib/cloudscale/monitor/preops/preop.rb +62 -0
- data/lib/cloudscale/plugins/mongo/mongo_db_status.rb +24 -19
- data/lib/cloudscale/plugins/mongo/mongo_replica_status.rb +48 -75
- data/lib/cloudscale/plugins/mongo/mongo_server_status.rb +112 -135
- data/lib/cloudscale/plugins/mongo/preops/mongodb_preop.rb +113 -0
- data/lib/cloudscale/plugins/os/preops/{plugin_preop.rb → os_preop.rb} +7 -4
- data/lib/cloudscale/plugins/os/sigar_cpu_perc.rb +3 -3
- data/lib/cloudscale/plugins/os/sigar_disk_iops.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_disk_space.rb +3 -3
- data/lib/cloudscale/plugins/os/sigar_net_byte_information.rb +4 -5
- data/lib/cloudscale/plugins/os/sigar_packet_information.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_ram_usage.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_swap_usage.rb +3 -3
- data/lib/cloudscale/plugins/plugin.rb +2 -50
- data/lib/cloudscale/plugins/postgres/postgres_server_status.rb +60 -101
- data/lib/cloudscale/plugins/postgres/preops/postgres_preop.rb +80 -0
- data/lib/cloudscale/plugins/preops/plugin_preop.rb +30 -0
- data/lib/cloudscale/registry.rb +1 -0
- data/lib/cloudscale/store/plugin/host +1 -0
- data/lib/cloudscale/store/plugin/port +1 -0
- data/lib/cloudscale/store/plugin/token +1 -0
- data/lib/cloudscale/version.rb +1 -1
- metadata +41 -10
- data/lib/cloudscale/monitor/agent/init_charts.rb +0 -50
- data/lib/cloudscale/monitor/agent/init_menus.rb +0 -44
- data/lib/cloudscale/monitor/agent/preops/preop.rb +0 -76
- data/lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb +0 -105
- data/lib/cloudscale/plugins/preops/plugin_postgres_preop.rb +0 -70
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require "#{File.dirname(__FILE__)}/preops/mongodb_preop"
|
2
2
|
require "#{File.dirname(__FILE__)}/../plugin"
|
3
3
|
|
4
4
|
##
|
@@ -9,164 +9,141 @@ require "#{File.dirname(__FILE__)}/../plugin"
|
|
9
9
|
module Cloudscale
|
10
10
|
module Plugins
|
11
11
|
class MongoServerStatus < Plugins::Plugin
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :menu_generalInformation, :menu_idxCounter, :menu_globalLock, :menu_opCounter, :menu_memory, :menu_network,
|
15
|
-
:indexCountersBtreeHits, :indexCountersBtreeAccesses, :indexCountersBtreeMisses, :globalLockLockTime,
|
16
|
-
:globalLockTotalTime, :opcountersInsert, :opcountersQuery, :opcountersUpdate, :opcountersDelete, :opcountersGetMore,
|
17
|
-
:generalInformation, :memBits, :memResident, :memVirtual, :memMapped, :memMappedWithJournal,
|
18
|
-
:networkBytesIn, :networkBytesOut, :networkNumOfRequests
|
19
|
-
def log
|
20
|
-
@log = Logger.new(STDOUT)
|
21
|
-
end
|
22
|
-
|
12
|
+
attr_reader :db
|
13
|
+
|
23
14
|
def is_enabled
|
24
|
-
|
15
|
+
Preops::MongodbPreop.instance.is_enabled
|
25
16
|
end
|
26
|
-
|
17
|
+
|
27
18
|
def initialize
|
28
19
|
super
|
29
20
|
if is_enabled
|
30
|
-
|
31
|
-
@menu_generalInformation = load_menu(menus["mongodb-server-stats"], "generalInformation")
|
32
|
-
@menu_idxCounter = load_menu(menus["mongodb-server-stats"], "indexCounters")
|
33
|
-
@menu_globalLock = load_menu(menus["mongodb-server-stats"], "globalLock")
|
34
|
-
@menu_opCounter = load_menu(menus["mongodb-server-stats"], "opCounters")
|
35
|
-
@menu_memory = load_menu(menus["mongodb-server-stats"], "memory")
|
36
|
-
@menu_network = load_menu(menus["mongodb-server-stats"], "network")
|
37
|
-
|
38
|
-
@db = Plugins::PluginPreop.instance.db
|
39
|
-
components = Plugins::PluginComponents.load_hash()
|
40
|
-
@indexCountersBtreeHits = load_metric(components["mongodb-server-stats"], "indexCountersBtreeHits")
|
41
|
-
@indexCountersBtreeAccesses = load_metric(components["mongodb-server-stats"], "indexCountersBtreeAccesses")
|
42
|
-
@indexCountersBtreeMisses = load_metric(components["mongodb-server-stats"], "indexCountersBtreeMisses")
|
43
|
-
|
44
|
-
@globalLockLockTime = load_metric(components["mongodb-server-stats"], "globalLockLockTime")
|
45
|
-
@globalLockTotalTime = load_metric(components["mongodb-server-stats"], "globalLockTotalTime")
|
46
|
-
|
47
|
-
@opcountersInsert = load_metric(components["mongodb-server-stats"], "opcountersInsert")
|
48
|
-
@opcountersQuery = load_metric(components["mongodb-server-stats"], "opcountersQuery")
|
49
|
-
@opcountersUpdate = load_metric(components["mongodb-server-stats"], "opcountersUpdate")
|
50
|
-
@opcountersDelete = load_metric(components["mongodb-server-stats"], "opcountersDelete")
|
51
|
-
@opcountersGetMore = load_metric(components["mongodb-server-stats"], "opcountersGetMore")
|
52
|
-
|
53
|
-
@generalInformation = load_metric(components["mongodb-server-stats"], "generalInformation")
|
54
|
-
|
55
|
-
@memBits = load_metric(components["mongodb-server-stats"], "memBits")
|
56
|
-
@memResident = load_metric(components["mongodb-server-stats"], "memResident")
|
57
|
-
@memVirtual = load_metric(components["mongodb-server-stats"], "memVirtual")
|
58
|
-
@memMapped = load_metric(components["mongodb-server-stats"], "memMapped")
|
59
|
-
@memMappedWithJournal = load_metric(components["mongodb-server-stats"], "memMappedWithJournal")
|
60
|
-
|
61
|
-
@networkBytesIn = load_metric(components["mongodb-server-stats"], "networkBytesIn")
|
62
|
-
@networkBytesOut = load_metric(components["mongodb-server-stats"], "networkBytesOut")
|
63
|
-
@networkNumOfRequests = load_metric(components["mongodb-server-stats"], "networkNumOfRequests")
|
21
|
+
@db = Preops::MongodbPreop.instance.db
|
64
22
|
end
|
65
23
|
end
|
66
|
-
|
67
|
-
def collect(
|
24
|
+
|
25
|
+
def collect()
|
26
|
+
registry = Monitor::Registry.instance
|
27
|
+
metrics = Metrics::Agent.new
|
68
28
|
log.info("Calling Collect on MongoServerStatus")
|
69
|
-
report_index_counters(
|
70
|
-
report_global_lock_times(
|
71
|
-
report_op_counters(
|
72
|
-
report_general_information(
|
73
|
-
report_memory(
|
74
|
-
report_network(
|
29
|
+
report_index_counters(registry, metrics)
|
30
|
+
report_global_lock_times(registry, metrics)
|
31
|
+
report_op_counters(registry, metrics)
|
32
|
+
report_general_information(registry, metrics)
|
33
|
+
report_memory(registry, metrics)
|
34
|
+
report_network(registry, metrics)
|
75
35
|
end
|
76
|
-
|
77
|
-
def report_memory(
|
36
|
+
|
37
|
+
def report_memory(registry, metrics)
|
78
38
|
stats = @db.command('serverStatus' => 1)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
"
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
39
|
+
registry.metrics["mongo.mem.bits"] = metrics.gauge :mem_bits do
|
40
|
+
{ :value => stats['mem']['bits'] }
|
41
|
+
end
|
42
|
+
|
43
|
+
registry.metrics["mongo.mem.resident"] = metrics.gauge :mem_resident do
|
44
|
+
{ :value => stats['mem']['resident'] }
|
45
|
+
end
|
46
|
+
|
47
|
+
registry.metrics["mongo.mem.virtual"] = metrics.gauge :mem_virtual do
|
48
|
+
{ :value => stats['mem']['virtual'] }
|
49
|
+
end
|
50
|
+
|
51
|
+
registry.metrics["mongo.mem.mapped"] = metrics.gauge :mem_mapped do
|
52
|
+
{ :value => stats['mem']['mapped'] }
|
53
|
+
end
|
54
|
+
|
55
|
+
registry.metrics["mongo.mem.mappedWithJournal"] = metrics.gauge :mem_mappedWithJournal do
|
56
|
+
{ :value => stats['mem']['mappedWithJournal'] }
|
57
|
+
end
|
94
58
|
end
|
95
|
-
|
96
|
-
def report_network(
|
59
|
+
|
60
|
+
def report_network(registry, metrics)
|
97
61
|
stats = @db.command('serverStatus' => 1)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
"
|
104
|
-
|
105
|
-
|
106
|
-
|
62
|
+
|
63
|
+
registry.metrics["mongo.network.bytes.in"] = metrics.gauge :mem_bytesIn do
|
64
|
+
{ :value => stats['mem']['bytesIn'] }
|
65
|
+
end
|
66
|
+
|
67
|
+
registry.metrics["mongo.network.bytes.out"] = metrics.gauge :mem_bytesOut do
|
68
|
+
{ :value => stats['mem']['bytesOut'] }
|
69
|
+
end
|
70
|
+
|
71
|
+
registry.metrics["mongo.network.num.requests"] = metrics.gauge :mem_numRequests do
|
72
|
+
{ :value => stats['mem']['numRequests'] }
|
73
|
+
end
|
107
74
|
end
|
108
|
-
|
109
|
-
def report_general_information(
|
75
|
+
|
76
|
+
def report_general_information(registry, metrics)
|
110
77
|
stats = @db.command('serverStatus' => 1)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
78
|
+
|
79
|
+
registry.metrics["mongo.general.uptime"] = metrics.gauge :general_uptime do
|
80
|
+
{ :value => stats['uptime'] }
|
81
|
+
end
|
82
|
+
|
83
|
+
registry.metrics["mongo.general.connections.currently"] = metrics.gauge :general_connections_current do
|
84
|
+
{ :value => stats['connections']['current'] }
|
85
|
+
end
|
86
|
+
|
87
|
+
registry.metrics["mongo.general.connections.available"] = metrics.gauge :general_connections_available do
|
88
|
+
{ :value => stats['connections']['available'] }
|
89
|
+
end
|
123
90
|
end
|
124
|
-
|
125
|
-
def report_op_counters(
|
91
|
+
|
92
|
+
def report_op_counters(registry, metrics)
|
126
93
|
stats = @db.command('serverStatus' => 1)
|
127
|
-
|
128
|
-
"
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
"
|
141
|
-
|
94
|
+
|
95
|
+
registry.metrics["mongo.opcounts.insert"] = metrics.gauge :opcounters_inserts do
|
96
|
+
{ :value => stats['opcounters']['insert'] }
|
97
|
+
end
|
98
|
+
|
99
|
+
registry.metrics["mongo.opcounts.query"] = metrics.gauge :opcounters_query do
|
100
|
+
{ :value => stats['opcounters']['query'] }
|
101
|
+
end
|
102
|
+
|
103
|
+
registry.metrics["mongo.opcounts.update"] = metrics.gauge :opcounters_update do
|
104
|
+
{ :value => stats['opcounters']['update'] }
|
105
|
+
end
|
106
|
+
|
107
|
+
registry.metrics["mongo.opcounts.delete"] = metrics.gauge :opcounters_delete do
|
108
|
+
{ :value => stats['opcounters']['delete'] }
|
109
|
+
end
|
110
|
+
|
111
|
+
registry.metrics["mongo.opcounts.getmore"] = metrics.gauge :opcounters_getmore do
|
112
|
+
{ :value => stats['opcounters']['getmore'] }
|
113
|
+
end
|
142
114
|
end
|
143
|
-
|
144
|
-
def report_index_counters(
|
115
|
+
|
116
|
+
def report_index_counters(registry, metrics)
|
145
117
|
stats = @db.command('serverStatus' => 1)
|
146
|
-
|
118
|
+
|
147
119
|
if (stats["indexCounters"] and stats["indexCounters"]["btree"])
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
"
|
153
|
-
|
154
|
-
|
155
|
-
|
120
|
+
registry.metrics["mongo.index.counters.btree.accesses"] = metrics.gauge :counters_btree_accesses do
|
121
|
+
{ :value => stats['indexCounters']['btree']['accesses'] }
|
122
|
+
end
|
123
|
+
|
124
|
+
registry.metrics["mongo.index.counters.btree.misses"] = metrics.gauge :counters_btree_misses do
|
125
|
+
{ :value => stats['indexCounters']['btree']['misses'] }
|
126
|
+
end
|
127
|
+
|
128
|
+
registry.metrics["mongo.index.counters.btree.hits"] = metrics.gauge :counters_btree_hits do
|
129
|
+
{ :value => stats['indexCounters']['btree']['hits'] }
|
130
|
+
end
|
156
131
|
end
|
157
132
|
end
|
158
|
-
|
159
|
-
def report_global_lock_times(
|
133
|
+
|
134
|
+
def report_global_lock_times(registry, metrics)
|
160
135
|
stats = @db.command('serverStatus' => 1)
|
161
136
|
if stats['globalLock']
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
"
|
137
|
+
registry.metrics["mongo.global.lock.time"] = metrics.gauge :global_lock_time do
|
138
|
+
{ :value => stats['globalLock']['lockTime'] }
|
139
|
+
end
|
140
|
+
|
141
|
+
registry.metrics["mongo.global.lock.total.time"] = metrics.gauge :global_lock_total_time do
|
142
|
+
{ :value => stats['globalLock']['totalTime'] }
|
143
|
+
end
|
167
144
|
end
|
168
145
|
end
|
169
|
-
|
146
|
+
|
170
147
|
end
|
171
148
|
end
|
172
|
-
end
|
149
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require "logger"
|
2
|
+
begin
|
3
|
+
require "mongo"
|
4
|
+
rescue LoadError
|
5
|
+
puts "WARNING: Load error Mongo 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 MongodbPreop < Preops::PluginPreop
|
18
|
+
include Singleton
|
19
|
+
|
20
|
+
def is_enabled
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_accessor :db, :connection
|
25
|
+
@@options = {
|
26
|
+
:"mongo-host" => {
|
27
|
+
:argument => "--mongo-host",
|
28
|
+
:description => "Host for your MongoDB Instance (e.g. host.mongodb.com)",
|
29
|
+
:required => true,
|
30
|
+
:value => nil
|
31
|
+
},
|
32
|
+
:"mongo-port" => {
|
33
|
+
:argument => "--mongo-port",
|
34
|
+
:description => "Port for your MongoDB Instance (Standard 27017)",
|
35
|
+
:required => false,
|
36
|
+
:value => 27017
|
37
|
+
},
|
38
|
+
:"mongo-db" => {
|
39
|
+
:argument => "--mongo-db",
|
40
|
+
:description => "Database of your MongoDB instance",
|
41
|
+
:required => true,
|
42
|
+
:value => nil
|
43
|
+
},
|
44
|
+
:"mongo-ssl" => {
|
45
|
+
:argument => "--mongo-ssl",
|
46
|
+
:description => "Usage SSL of your MongoDB instance",
|
47
|
+
:required => false,
|
48
|
+
:value => false
|
49
|
+
},
|
50
|
+
:"mongo-username" => {
|
51
|
+
:argument => "--mongo-username",
|
52
|
+
:description => "Username for your MongoDB instance",
|
53
|
+
:required => false,
|
54
|
+
:value => nil
|
55
|
+
},
|
56
|
+
:"mongo-password" => {
|
57
|
+
:argument => "--mongo-password",
|
58
|
+
:description => "Password for your MongoDB instance",
|
59
|
+
:required => false,
|
60
|
+
:value => nil
|
61
|
+
},
|
62
|
+
:"mongo-connect-timeout" => {
|
63
|
+
:argument => "--mongo-connect-timeout",
|
64
|
+
:description => "Connection Timeout for your MongoDB instance",
|
65
|
+
:required => false,
|
66
|
+
:value => 30
|
67
|
+
},
|
68
|
+
:"mongo-op-timeout" => {
|
69
|
+
:argument => "--mongo-timeout",
|
70
|
+
:description => "Operation Timeout for your MongoDB instance",
|
71
|
+
:required => false,
|
72
|
+
:value => 30
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
def options
|
77
|
+
@@options
|
78
|
+
end
|
79
|
+
|
80
|
+
def initialize
|
81
|
+
self.init
|
82
|
+
if defined? Mongo
|
83
|
+
begin Mongo
|
84
|
+
@connection = Mongo::Connection.new(options[:host][:value], options[:port][:value])
|
85
|
+
rescue Mongo::ConnectionFailure
|
86
|
+
puts "Unable to connect to the MongoDB Daemon.",
|
87
|
+
"Please ensure it is running on #{@host}:#{@port}\n\nException Message: #{$!.message}. Also confirm if SSL should be enabled or disabled."
|
88
|
+
end
|
89
|
+
|
90
|
+
if @connection != nil
|
91
|
+
begin
|
92
|
+
@db = @connection.db(options[:db][:value])
|
93
|
+
if (@username != nil)
|
94
|
+
@db.authenticate(options[:username][:value], options[:password][:value])
|
95
|
+
end
|
96
|
+
rescue Exception
|
97
|
+
puts "Unable to authenticate to MongoDB Database." << $!.message
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def connection
|
104
|
+
@connection
|
105
|
+
end
|
106
|
+
|
107
|
+
def db
|
108
|
+
@db
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require "optparse"
|
2
1
|
require "logger"
|
3
2
|
require "csigar"
|
4
|
-
require "#{File.dirname(__FILE__)}
|
3
|
+
require "#{File.dirname(__FILE__)}/../../preops/plugin_preop"
|
5
4
|
|
6
5
|
##
|
7
6
|
#
|
@@ -9,7 +8,7 @@ require "#{File.dirname(__FILE__)}/../../../monitor/agent/preops/preop"
|
|
9
8
|
#
|
10
9
|
##
|
11
10
|
module Cloudscale
|
12
|
-
module
|
11
|
+
module Preops
|
13
12
|
class NullLogger < Logger
|
14
13
|
def initialize
|
15
14
|
end
|
@@ -19,7 +18,7 @@ module Cloudscale
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
class
|
21
|
+
class OsPreop < Preops::PluginPreop
|
23
22
|
include Singleton
|
24
23
|
@@options = {
|
25
24
|
}
|
@@ -28,6 +27,10 @@ module Cloudscale
|
|
28
27
|
@@options
|
29
28
|
end
|
30
29
|
|
30
|
+
def is_enabled
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
31
34
|
def register
|
32
35
|
init_charts("#{File.dirname(__FILE__)}/../data/os_chart.json")
|
33
36
|
init_menus("#{File.dirname(__FILE__)}/../data/os_menu.json")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/preops/
|
1
|
+
require "#{File.dirname(__FILE__)}/preops/os_preop"
|
2
2
|
require "#{File.dirname(__FILE__)}/../plugin"
|
3
3
|
|
4
4
|
##
|
@@ -11,13 +11,13 @@ module Cloudscale
|
|
11
11
|
class SigarCpuPerc < Plugins::Plugin
|
12
12
|
|
13
13
|
def is_enabled
|
14
|
-
|
14
|
+
Preops::OsPreop.instance.is_enabled
|
15
15
|
end
|
16
16
|
|
17
17
|
def initialize
|
18
18
|
super
|
19
19
|
if is_enabled
|
20
|
-
@sigar =
|
20
|
+
@sigar = Preops::OsPreop.instance.sigar
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|