@cryptotaxi247 / netdata-1 / commits / 805362d0b

rabbitmq: survive lack of vhosts (#7019)

* rabbitmq: do not return None from get_data if there is no vhosts + more debug output

Ilya Mashchenko committed Oct 9, 2019 at 14:30 UTC 805362d0b29a333c6bc42feaf33cc882aa398815
1 file changed +18 -6
collectors/python.d.plugin/rabbitmq/rabbitmq.chart.py
+18 -6
@@ -198,34 +198,45 @@ class Service(UrlService):
198 data.update(stats)
199
200 stats = self.get_vhosts_stats()
201 - if not stats:
202 - return None
203 -
204 - data.update(stats)
201 + if stats:
202 + data.update(stats)
203
204 return data or None
205
206 def get_overview_stats(self):
207 url = '{0}/{1}'.format(self.url, API_OVERVIEW)
208 + self.debug("doing http request to '{0}'".format(url))
209 raw = self._get_raw_data(url)
210 if not raw:
211 return None
212
213 data = loads(raw)
214 self.node_name = data['node']
216 - return fetch_data(raw_data=data, metrics=OVERVIEW_STATS)
215 + self.debug("found node name: '{0}'".format(self.node_name))
216 +
217 + stats = fetch_data(raw_data=data, metrics=OVERVIEW_STATS)
218 + self.debug("number of metrics: {0}".format(len(stats)))
219 + return stats
220
221 def get_nodes_stats(self):
222 + if self.node_name == "":
223 + self.error("trying to get node stats, but node name is not set")
224 + return None
225 +
226 url = '{0}/{1}/{2}'.format(self.url, API_NODE, self.node_name)
227 + self.debug("doing http request to '{0}'".format(url))
228 raw = self._get_raw_data(url)
229 if not raw:
230 return None
231
232 data = loads(raw)
225 - return fetch_data(raw_data=data, metrics=NODE_STATS)
233 + stats = fetch_data(raw_data=data, metrics=NODE_STATS)
234 + self.debug("number of metrics: {0}".format(len(stats)))
235 + return stats
236
237 def get_vhosts_stats(self):
238 url = '{0}/{1}'.format(self.url, API_VHOSTS)
239 + self.debug("doing http request to '{0}'".format(url))
240 raw = self._get_raw_data(url)
241 if not raw:
242 return None
@@ -245,6 +256,7 @@ class Service(UrlService):
256
257 data.update(self.vhost.msg_stats())
258
259 + self.debug("number of vhosts: {0}, metrics: {1}".format(len(vhosts), len(data)))
260 return data
261
262 def add_vhost_charts(self, vhost_name):