]> arthur.barton.de Git - netdata.git/blobdiff - python.d/apache_cache.chart.py
Merge pull request #2021 from ktsaou/master
[netdata.git] / python.d / apache_cache.chart.py
index 115414abaa075f8716646610035364bde255dbcb..3681a85112ec51762e245fe8b9a40ff05b87b933 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf-8 -*-
-# Description: apache cache netdata python.d plugin
+# Description: apache cache netdata python.d module
 # Author: Pawel Krupa (paulfantom)
 
 from base import LogService
 
 priority = 60000
-retries = 5
-update_every = 3
+retries = 60
+update_every = 3
 
 ORDER = ['cache']
 CHARTS = {
@@ -14,7 +14,8 @@ CHARTS = {
         'options': [None, 'apache cached responses', 'percent cached', 'cached', 'apache_cache.cache', 'stacked'],
         'lines': [
             ["hit", 'cache', "percentage-of-absolute-row"],
-            ["miss", None, "percentage-of-absolute-row"]
+            ["miss", None, "percentage-of-absolute-row"],
+            ["other", None, "percentage-of-absolute-row"]
         ]}
 }
 
@@ -27,29 +28,33 @@ class Service(LogService):
         self.order = ORDER
         self.definitions = CHARTS
 
-    def _formatted_data(self):
+    def _get_data(self):
         """
         Parse new log lines
         :return: dict
         """
         try:
-            raw = self._get_data()
+            raw = self._get_raw_data()
             if raw is None:
                 return None
+            elif not raw:
+                return {'hit': 0,
+                        'miss': 0,
+                        'other': 0}
         except (ValueError, AttributeError):
             return None
 
         hit = 0
         miss = 0
+        other = 0
         for line in raw:
             if "cache hit" in line:
                 hit += 1
             elif "cache miss" in line:
                 miss += 1
+            else:
+                other += 1
 
-        total = hit + miss
-        if total == 0:
-            return None
-
-        return {'hit': int(hit/float(total) * 100),
-                'miss': int(miss/float(total) * 100)}
+        return {'hit': hit,
+                'miss': miss,
+                'other': other}