]> arthur.barton.de Git - netdata.git/commitdiff
prevent frequent opening of log files
authorpaulfantom <paulfantom@gmail.com>
Sat, 2 Jul 2016 16:56:21 +0000 (18:56 +0200)
committerpaulfantom <paulfantom@gmail.com>
Sat, 2 Jul 2016 16:56:21 +0000 (18:56 +0200)
python.d/apache_cache.chart.py
python.d/python_modules/base.py

index 115414abaa075f8716646610035364bde255dbcb..be102129fb953ecbe6a1260e1436327147f00bf4 100644 (file)
@@ -47,9 +47,5 @@ class Service(LogService):
             elif "cache miss" in line:
                 miss += 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}
index 7b54e6a4e46624c011df86707d674a0f789cd847..6b8bef5a2d5b3ab9c9b0d23ebcd73dbed0643d21 100644 (file)
@@ -438,6 +438,8 @@ class LogService(SimpleService):
         try:
             if os.path.getsize(self.log_path) < self._last_position:
                 self._last_position = 0
+            elif os.path.getsize(self.log_path) == self._last_position:
+                return None
             with open(self.log_path, "r") as fp:
                 fp.seek(self._last_position)
                 for i, line in enumerate(fp):