1 # -*- coding: utf-8 -*-
2 # Description: apache cache netdata python.d plugin
3 # Author: Pawel Krupa (paulfantom)
5 from base import LogService
14 'options': [None, 'apache cached responses', 'percent cached', 'cached', 'apache_cache.cache', 'stacked'],
16 ["hit", 'cache', "percentage-of-absolute-row"],
17 ["miss", None, "percentage-of-absolute-row"]
22 class Service(LogService):
23 def __init__(self, configuration=None, name=None):
24 LogService.__init__(self, configuration=configuration, name=name)
25 if len(self.log_path) == 0:
26 self.log_path = "/var/log/apache2/cache.log"
28 self.definitions = CHARTS
30 def _formatted_data(self):
36 raw = self._get_data()
39 except (ValueError, AttributeError):
46 if "cache hit" in line:
48 elif "cache miss" in line:
55 hit_percent = int(hit/float(total) * 100)
56 return {'hit': hit_percent,
57 'miss': 100 - hit_percent}