]> arthur.barton.de Git - netdata.git/commitdiff
fix squid data parsing
authorpaulfantom <paulfantom@gmail.com>
Wed, 13 Jul 2016 10:12:28 +0000 (12:12 +0200)
committerpaulfantom <paulfantom@gmail.com>
Wed, 13 Jul 2016 10:12:28 +0000 (12:12 +0200)
python.d/squid.chart.py

index 884adc8086e7a8f45873aaed5fc5b91219d29f89..c34c5924c086859e9cd61885490fdb54c4bb800f 100644 (file)
@@ -56,22 +56,23 @@ class Service(SocketService):
         Get data via http request
         :return: dict
         """
+        data = {}
         try:
-            raw = self._get_raw_data().split('\n')
-            if "200 OK" not in raw[0]:
+            raw = self._get_raw_data().split('\r\n')[-1]
+            if raw.startswith('<'):
                 return None
-            data = {}
-            for row in raw:
+            for row in raw.split('\n'):
                 if row.startswith(("client", "server.all")):
                     tmp = row.split("=")
                     data[tmp[0].replace('.', '_').strip(' ')] = int(tmp[1])
-
-            if len(data) == 0:
-                return None
-            return data
         except (ValueError, AttributeError):
             return None
 
+        if len(data) == 0:
+            return None
+        else:
+            return data
+
     def check(self):
         """
         Parse essential configuration, autodetect squid configuration (if needed), and check if data is available
@@ -100,7 +101,6 @@ class Service(SocketService):
         #                 return True
         # else:
         if True:
-            self.error("NEED: " + str(self._get_data()))
             if self._get_data() is not None:
                 return True
             else: