From: Paul Cuzner Date: Mon, 21 Aug 2017 04:51:18 +0000 (+1200) Subject: rgw: handle the scenario where the socket doesn't respond X-Git-Tag: v1.0~30^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dec8b78511e3d1705cf99061f29f901291274d14;p=cephmetrics.git rgw: handle the scenario where the socket doesn't respond The perf dump to the socket could fail, so this change handles this scenario by just reporting the issue avoiding connectionerror problems --- diff --git a/collectors/rgw.py b/collectors/rgw.py index 8a0095a..45f9749 100644 --- a/collectors/rgw.py +++ b/collectors/rgw.py @@ -41,9 +41,12 @@ class RGW(BaseCollector): response = self._admin_socket() - key_name = 'client.rgw.{}'.format(self.host_name) - - return response.get(key_name) + if response: + key_name = 'client.rgw.{}'.format(self.host_name) + return response.get(key_name) + else: + # admin_socket call failed + return {} def _filter(self, stats): # pick out the simple metrics @@ -62,8 +65,10 @@ class RGW(BaseCollector): start = time.time() raw_stats = self._get_rgw_data() - - stats = self._filter(raw_stats) + if raw_stats: + stats = self._filter(raw_stats) + else: + stats = {} stats['ceph_version'] = self.version