sensu-plugins-mongodb-boutetnico 1.0.1 → 1.4.0
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/README.md +1 -0
- data/bin/check-mongodb-query-count.rb +267 -0
- data/bin/check-mongodb.py +416 -243
- data/bin/metrics-mongodb-replication.rb +15 -30
- data/lib/sensu-plugins-mongodb/metrics.rb +23 -31
- data/lib/sensu-plugins-mongodb/version.rb +2 -2
- metadata +8 -6
@@ -112,30 +112,23 @@ class MongoDB < Sensu::Plugin::Metric::CLI::Graphite
|
|
112
112
|
rs.documents[0]
|
113
113
|
end
|
114
114
|
|
115
|
-
# connects to mongo and sets @db, works with MongoClient < 2.0.0
|
116
115
|
def connect_mongo_db
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
client_opts[:ssl] = true
|
131
|
-
client_opts[:ssl_cert] = config[:ssl_cert]
|
132
|
-
client_opts[:ssl_key] = config[:ssl_key]
|
133
|
-
client_opts[:ssl_ca_cert] = config[:ssl_ca_cert]
|
134
|
-
client_opts[:ssl_verify] = config[:ssl_verify]
|
135
|
-
end
|
136
|
-
mongo_client = Mongo::Client.new([address_str], client_opts)
|
137
|
-
@db = mongo_client.database
|
116
|
+
address_str = "#{config[:host]}:#{config[:port]}"
|
117
|
+
client_opts = {}
|
118
|
+
client_opts[:database] = 'admin'
|
119
|
+
unless config[:user].nil?
|
120
|
+
client_opts[:user] = config[:user]
|
121
|
+
client_opts[:password] = config[:password]
|
122
|
+
end
|
123
|
+
if config[:ssl]
|
124
|
+
client_opts[:ssl] = true
|
125
|
+
client_opts[:ssl_cert] = config[:ssl_cert]
|
126
|
+
client_opts[:ssl_key] = config[:ssl_key]
|
127
|
+
client_opts[:ssl_ca_cert] = config[:ssl_ca_cert]
|
128
|
+
client_opts[:ssl_verify] = config[:ssl_verify]
|
138
129
|
end
|
130
|
+
mongo_client = Mongo::Client.new([address_str], client_opts)
|
131
|
+
@db = mongo_client.database
|
139
132
|
end
|
140
133
|
|
141
134
|
def run
|
@@ -225,8 +218,6 @@ class MongoDB < Sensu::Plugin::Metric::CLI::Graphite
|
|
225
218
|
def gather_replication_metrics(replication_status)
|
226
219
|
replication_metrics = {}
|
227
220
|
|
228
|
-
replication_metrics['replica_set'] = replication_status['set']
|
229
|
-
replication_metrics['date'] = replication_status['date']
|
230
221
|
replication_metrics['myState'] = replication_status['myState']
|
231
222
|
replication_metrics['term'] = replication_status['term']
|
232
223
|
replication_metrics['heartbeatIntervalMillis'] = replication_status['heartbeatIntervalMillis']
|
@@ -238,14 +229,11 @@ class MongoDB < Sensu::Plugin::Metric::CLI::Graphite
|
|
238
229
|
replication_member_metrics = {}
|
239
230
|
|
240
231
|
replication_member_metrics['id'] = replication_member_details['_id']
|
241
|
-
replication_member_metrics['name'] = replication_member_details['name']
|
242
232
|
replication_member_metrics['health'] = replication_member_details['health']
|
243
233
|
replication_member_metrics['state'] = replication_member_details['state']
|
244
|
-
replication_member_metrics['stateStr'] = replication_member_details['stateStr']
|
245
234
|
member_hierarchy = replication_member_details['stateStr']
|
246
235
|
if member_hierarchy == 'PRIMARY'
|
247
236
|
@primary_optime_date = replication_member_details['optimeDate']
|
248
|
-
replication_member_metrics['primary.startOptimeDate'] = @primary_optime_date
|
249
237
|
end
|
250
238
|
if member_hierarchy == 'SECONDARY'
|
251
239
|
@secondary_optime_date = replication_member_details['optimeDate']
|
@@ -256,12 +244,9 @@ class MongoDB < Sensu::Plugin::Metric::CLI::Graphite
|
|
256
244
|
replication_member_metrics['minutesBehindPrimary'] = difference_in_minutes
|
257
245
|
replication_member_metrics['hoursBehindPrimary'] = difference_in_hours
|
258
246
|
end
|
259
|
-
replication_member_metrics['optimeDate'] = replication_member_details['optimeDate']
|
260
247
|
replication_member_metrics['uptime'] = replication_member_details['uptime']
|
261
|
-
replication_member_metrics['lastHeartbeat'] = replication_member_details['lastHeartbeat']
|
262
248
|
replication_member_metrics['lastHeartbeatRecv'] = replication_member_details['lastHeartbeatiRecv']
|
263
249
|
replication_member_metrics['pingMs'] = replication_member_details['pingMs']
|
264
|
-
replication_member_metrics['syncingTo'] = replication_member_details['syncingTo']
|
265
250
|
replication_member_metrics['configVersion'] = replication_member_details['configVersion']
|
266
251
|
|
267
252
|
replication_member_metrics
|
@@ -23,16 +23,9 @@ module SensuPluginsMongoDB
|
|
23
23
|
raise 'Already connected to a database'
|
24
24
|
end
|
25
25
|
|
26
|
-
db_user = @config[:user]
|
27
|
-
db_password = @config[:password]
|
28
26
|
@mongo_client = get_mongo_client(db_name)
|
29
27
|
|
30
|
-
|
31
|
-
@db = @mongo_client.db(db_name)
|
32
|
-
@db.authenticate(db_user, db_password) unless db_user.nil?
|
33
|
-
else
|
34
|
-
@db = @mongo_client.database
|
35
|
-
end
|
28
|
+
@db = @mongo_client.database
|
36
29
|
end
|
37
30
|
|
38
31
|
# Fetches a document from the mongo db.
|
@@ -321,10 +314,13 @@ module SensuPluginsMongoDB
|
|
321
314
|
server_metrics['metrics.repl.network.getmores_totalMillis'] = repl['network']['getmores']['totalMillis']
|
322
315
|
server_metrics['metrics.repl.network.ops'] = repl['network']['ops']
|
323
316
|
server_metrics['metrics.repl.network.readersCreated'] = repl['network']['readersCreated']
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
317
|
+
|
318
|
+
if Gem::Version.new(mongo_version) <= Gem::Version.new('4.0.0')
|
319
|
+
server_metrics['metrics.repl.preload.docs_num'] = repl['preload']['docs']['num']
|
320
|
+
server_metrics['metrics.repl.preload.docs_totalMillis'] = repl['preload']['docs']['totalMillis']
|
321
|
+
server_metrics['metrics.repl.preload.indexes_num'] = repl['preload']['indexes']['num']
|
322
|
+
server_metrics['metrics.repl.preload.indexes_totalMillis'] = repl['preload']['indexes']['totalMillis']
|
323
|
+
end
|
328
324
|
|
329
325
|
# Metrics (replicaset status)
|
330
326
|
# MongoDB will fail if not running with --replSet, hence the check for nil
|
@@ -333,7 +329,7 @@ module SensuPluginsMongoDB
|
|
333
329
|
end
|
334
330
|
|
335
331
|
# Metrics (storage)
|
336
|
-
if Gem::Version.new(mongo_version)
|
332
|
+
if Gem::Version.new(mongo_version) <= Gem::Version.new('4.0.0')
|
337
333
|
freelist = server_status['metrics']['storage']['freelist']
|
338
334
|
server_metrics['metrics.storage.freelist.search_bucketExhauseted'] = freelist['search']['bucketExhausted']
|
339
335
|
server_metrics['metrics.storage.freelist.search_requests'] = freelist['search']['requests']
|
@@ -375,25 +371,21 @@ module SensuPluginsMongoDB
|
|
375
371
|
ssl_ca_cert = @config[:ssl_ca_cert]
|
376
372
|
ssl_verify = @config[:ssl_verify]
|
377
373
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
client_opts =
|
383
|
-
client_opts[:
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
client_opts[:ssl_key] = ssl_key
|
392
|
-
client_opts[:ssl_ca_cert] = ssl_ca_cert
|
393
|
-
client_opts[:ssl_verify] = ssl_verify
|
394
|
-
end
|
395
|
-
Mongo::Client.new([address_str], client_opts)
|
374
|
+
address_str = "#{host}:#{port}"
|
375
|
+
client_opts = {}
|
376
|
+
client_opts[:database] = db_name
|
377
|
+
unless db_user.nil?
|
378
|
+
client_opts[:user] = db_user
|
379
|
+
client_opts[:password] = db_password
|
380
|
+
end
|
381
|
+
if ssl
|
382
|
+
client_opts[:ssl] = true
|
383
|
+
client_opts[:ssl_cert] = ssl_cert
|
384
|
+
client_opts[:ssl_key] = ssl_key
|
385
|
+
client_opts[:ssl_ca_cert] = ssl_ca_cert
|
386
|
+
client_opts[:ssl_verify] = ssl_verify
|
396
387
|
end
|
388
|
+
Mongo::Client.new([address_str], client_opts)
|
397
389
|
end
|
398
390
|
end
|
399
391
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-mongodb-boutetnico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.93.1
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.93.1
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: yard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,10 +187,11 @@ description: |-
|
|
187
187
|
more.
|
188
188
|
email: "<sensu-users@googlegroups.com>"
|
189
189
|
executables:
|
190
|
-
- check-mongodb.rb
|
190
|
+
- check-mongodb-query-count.rb
|
191
191
|
- metrics-mongodb.rb
|
192
|
-
- check-mongodb
|
192
|
+
- check-mongodb.rb
|
193
193
|
- metrics-mongodb-replication.rb
|
194
|
+
- check-mongodb-metric.rb
|
194
195
|
extensions: []
|
195
196
|
extra_rdoc_files: []
|
196
197
|
files:
|
@@ -198,6 +199,7 @@ files:
|
|
198
199
|
- LICENSE
|
199
200
|
- README.md
|
200
201
|
- bin/check-mongodb-metric.rb
|
202
|
+
- bin/check-mongodb-query-count.rb
|
201
203
|
- bin/check-mongodb.py
|
202
204
|
- bin/check-mongodb.rb
|
203
205
|
- bin/metrics-mongodb-replication.rb
|