From: Ilya Date: Tue, 21 Mar 2017 07:28:40 +0000 (+0900) Subject: mongodb_plugin: take "arbiter" replica set member into account X-Git-Tag: ab-debian_0.20170323.01-0ab1~1^2~3^2 X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=commitdiff_plain;h=0707208c1797d51cc9f650c83857742e18b3e4fb mongodb_plugin: take "arbiter" replica set member into account --- diff --git a/python.d/mongodb.chart.py b/python.d/mongodb.chart.py index c01bd293..953f025e 100644 --- a/python.d/mongodb.chart.py +++ b/python.d/mongodb.chart.py @@ -391,13 +391,18 @@ class Service(SimpleService): self.build_metrics_to_collect_(server_status) try: - self._get_data() + data = self._get_data() except (LookupError, SyntaxError, AttributeError): self.error('Type: %s, error: %s' % (str(exc_info()[0]), str(exc_info()[1]))) return False else: - self.create_charts_(server_status) - return True + if isinstance(data, dict) and data: + self._data_from_check = data + self.create_charts_(server_status) + return True + else: + self.error('_get_data() returned no data or type is not ') + return False def build_metrics_to_collect_(self, server_status): @@ -473,7 +478,7 @@ class Service(SimpleService): lines.append([dim_id, description, 'absolute', 1, 1]) return lines - all_hosts = server_status['repl']['hosts'] + all_hosts = server_status['repl']['hosts'] + server_status['repl'].get('arbiters', list()) this_host = server_status['repl']['me'] other_hosts = [host for host in all_hosts if host != this_host] @@ -620,7 +625,7 @@ class Service(SimpleService): if not member.get('self'): other_hosts.append(member) # Replica set time diff between current time and time when last entry from the oplog was applied - if member['optimeDate'] != unix_epoch: + if member.get('optimeDate', unix_epoch) != unix_epoch: member_optimedate = member['name'] + '_optimedate' to_netdata.update({member_optimedate: int(delta_calculation(delta=utc_now - member['optimeDate'], multiplier=1000))})