@cryptotaxi247 / netdata-1 / commits / 9c92673e1

mongodb_plugin: locks acquireCount charts added

Ilya committed Feb 26, 2017 at 18:18 UTC 9c92673e12eabcae2b518d0f1d36db3b5ce13013
1 file changed +88 -16
python.d/mongodb.chart.py
+88 -16
@@ -112,11 +112,30 @@ COMMANDS = [
112 ('metrics.commands.delete.failed', 'delete_failed', None)
113 ]
114
115 +LOCKS = [
116 + ('locks.Collection.acquireCount.R', 'Collection_R', None),
117 + ('locks.Collection.acquireCount.r', 'Collection_r', None),
118 + ('locks.Collection.acquireCount.W', 'Collection_W', None),
119 + ('locks.Collection.acquireCount.w', 'Collection_w', None),
120 + ('locks.Database.acquireCount.R', 'Database_R', None),
121 + ('locks.Database.acquireCount.r', 'Database_r', None),
122 + ('locks.Database.acquireCount.W', 'Database_W', None),
123 + ('locks.Database.acquireCount.w', 'Database_w', None),
124 + ('locks.Global.acquireCount.R', 'Global_R', None),
125 + ('locks.Global.acquireCount.r', 'Global_r', None),
126 + ('locks.Global.acquireCount.W', 'Global_W', None),
127 + ('locks.Global.acquireCount.w', 'Global_w', None),
128 + ('locks.Metadata.acquireCount.R', 'Metadata_R', None),
129 + ('locks.Metadata.acquireCount.w', 'Metadata_w', None),
130 + ('locks.oplog.acquireCount.r', 'oplog_r', None),
131 + ('locks.oplog.acquireCount.w', 'oplog_w', None)
132 +]
133 +
134 DBSTATS = [
116 - 'dataSize',
117 - 'indexSize',
118 - 'storageSize',
119 - 'objects'
135 + 'dataSize',
136 + 'indexSize',
137 + 'storageSize',
138 + 'objects'
139 ]
140
141 # charts order (can be overridden if you want less charts, or different order)
@@ -124,6 +143,7 @@ ORDER = ['read_operations', 'write_operations', 'active_clients', 'journaling_tr
143 'journaling_volume', 'background_flush_average', 'background_flush_last', 'background_flush_rate',
144 'wiredtiger_read', 'wiredtiger_write', 'cursors', 'connections', 'memory', 'page_faults',
145 'queued_requests', 'record_moves', 'wiredtiger_cache', 'wiredtiger_pages_evicted', 'asserts',
146 + 'locks_collection', 'locks_database', 'locks_global', 'locks_metadata', 'locks_oplog',
147 'dbstats_objects', 'tcmalloc_generic', 'tcmalloc_metrics', 'command_total_rate', 'command_failed_rate']
148
149 CHARTS = {
@@ -299,6 +319,47 @@ CHARTS = {
319 ['findAndModify_failed', 'findAndModify', 'incremental', 1, 1],
320 ['insert_failed', 'insert', 'incremental', 1, 1],
321 ['update_failed', 'update', 'incremental', 1, 1]
322 + ]},
323 + 'locks_collection': {
324 + 'options': [None, 'Collection lock. Number of times the lock was acquired in the specified mode',
325 + 'locks', 'locks metrics', 'mongodb.locks_collection', 'stacked'],
326 + 'lines': [
327 + ['Collection_R', 'shared', 'incremental'],
328 + ['Collection_W', 'exclusive', 'incremental'],
329 + ['Collection_r', 'intent_shared', 'incremental'],
330 + ['Collection_w', 'intent_exclusive', 'incremental']
331 + ]},
332 + 'locks_database': {
333 + 'options': [None, 'Database lock. Number of times the lock was acquired in the specified mode',
334 + 'locks', 'locks metrics', 'mongodb.locks_database', 'stacked'],
335 + 'lines': [
336 + ['Database_R', 'shared', 'incremental'],
337 + ['Database_W', 'exclusive', 'incremental'],
338 + ['Database_r', 'intent_shared', 'incremental'],
339 + ['Database_w', 'intent_exclusive', 'incremental']
340 + ]},
341 + 'locks_global': {
342 + 'options': [None, 'Global lock. Number of times the lock was acquired in the specified mode',
343 + 'locks', 'locks metrics', 'mongodb.locks_global', 'stacked'],
344 + 'lines': [
345 + ['Global_R', 'shared', 'incremental'],
346 + ['Global_W', 'exclusive', 'incremental'],
347 + ['Global_r', 'intent_shared', 'incremental'],
348 + ['Global_w', 'intent_exclusive', 'incremental']
349 + ]},
350 + 'locks_metadata': {
351 + 'options': [None, 'Metadata lock. Number of times the lock was acquired in the specified mode',
352 + 'locks', 'locks metrics', 'mongodb.locks_metadata', 'stacked'],
353 + 'lines': [
354 + ['Metadata_R', 'shared', 'incremental'],
355 + ['Metadata_w', 'intent_exclusive', 'incremental']
356 + ]},
357 + 'locks_oplog': {
358 + 'options': [None, 'Lock on the oplog. Number of times the lock was acquired in the specified mode',
359 + 'locks', 'locks metrics', 'mongodb.locks_oplog', 'stacked'],
360 + 'lines': [
361 + ['Metadata_r', 'intent_shared', 'incremental'],
362 + ['Metadata_w', 'intent_exclusive', 'incremental']
363 ]}
364 }
365
@@ -349,6 +410,8 @@ class Service(SimpleService):
410 self.metrics_to_collect.extend(COMMANDS)
411 if 'wiredTiger' in server_status:
412 self.metrics_to_collect.extend(WIREDTIGER)
413 + if 'Collection' in server_status['locks']:
414 + self.metrics_to_collect.extend(LOCKS)
415
416 def create_charts_(self, server_status):
417
@@ -374,6 +437,15 @@ class Service(SimpleService):
437 self.order.remove('command_total_rate')
438 self.order.remove('command_failed_rate')
439
440 + if 'Collection' not in server_status['locks']:
441 + self.order.remove('locks_collection')
442 + self.order.remove('locks_database')
443 + self.order.remove('locks_global')
444 + self.order.remove('locks_metadata')
445 +
446 + if 'oplog' not in server_status['locks']:
447 + self.order.remove('locks_oplog')
448 +
449 for dbase in self.databases:
450 self.order.append('_'.join([dbase, 'dbstats']))
451 self.definitions['_'.join([dbase, 'dbstats'])] = {
@@ -409,28 +481,28 @@ class Service(SimpleService):
481 self.order.append('oplog_window')
482 self.definitions['oplog_window'] = {
483 'options': [None, 'Interval of time between the oldest and the latest entries in the oplog',
412 - 'seconds', 'replication', 'mongodb.oplog_window', 'line'],
484 + 'seconds', 'replication and oplog', 'mongodb.oplog_window', 'line'],
485 'lines': [['timeDiff', 'window', 'absolute', 1, 1000]]}
486 # Create "heartbeat delay" chart
487 self.order.append('heartbeat_delay')
488 self.definitions['heartbeat_delay'] = {
417 - 'options': [None, 'Latency between this node and replica set members (lastHeartbeatRecv)',
418 - 'seconds', 'replication', 'mongodb.replication_heartbeat_delay', 'stacked'],
489 + 'options': [None, 'Time when last heartbeat was received'
490 + ' from the replica set member (lastHeartbeatRecv)',
491 + 'seconds ago', 'replication and oplog', 'mongodb.replication_heartbeat_delay', 'stacked'],
492 'lines': create_lines(other_hosts, 'heartbeat_lag')}
493 # Create "optimedate delay" chart
494 self.order.append('optimedate_delay')
495 self.definitions['optimedate_delay'] = {
423 - 'options': [None, '"optimeDate"(time when last entry from the oplog was applied)'
424 - ' diff between all nodes',
425 - 'seconds', 'replication', 'mongodb.replication_optimedate_delay', 'stacked'],
496 + 'options': [None, 'Time when last entry from the oplog was applied (optimeDate)',
497 + 'seconds ago', 'replication and oplog', 'mongodb.replication_optimedate_delay', 'stacked'],
498 'lines': create_lines(all_hosts, 'optimedate')}
499 # Create "replica set members state" chart
500 for host in all_hosts:
501 chart_name = '_'.join([host, 'state'])
502 self.order.append(chart_name)
503 self.definitions[chart_name] = {
432 - 'options': [None, '%s state' % host, 'state',
433 - 'replication', 'mongodb.replication_state', 'line'],
504 + 'options': [None, 'Replica set member (%s) current state' % host, 'state',
505 + 'replication and oplog', 'mongodb.replication_state', 'line'],
506 'lines': create_state_lines(REPLSET_STATES)}
507
508 def _get_raw_data(self):
@@ -512,15 +584,15 @@ class Service(SimpleService):
584
585 # serverStatus
586 for metric, new_name, function in self.metrics_to_collect:
515 - temp = serverStatus
587 + value = serverStatus
588 for key in metric.split('.'):
589 try:
518 - temp = temp[key]
590 + value = value[key]
591 except KeyError:
592 break
593
522 - if not isinstance(temp, dict):
523 - to_netdata[new_name or key] = temp if not function else function(temp)
594 + if not isinstance(value, dict) and key:
595 + to_netdata[new_name or key] = value if not function else function(value)
596
597 to_netdata['nonmapped'] = to_netdata['virtual'] - serverStatus['mem'].get('mappedWithJournal',
598 to_netdata['mapped'])