X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python.d%2Fapache_cache.chart.py;h=3681a85112ec51762e245fe8b9a40ff05b87b933;hb=0d6e3714113d50a5f197c9035cf1bd22d2259714;hp=2510cd43000e7d1187b22fa5055bfb64f3eaf98a;hpb=2f42d45beabbb4ec75e50201416d626a094fdd70;p=netdata.git diff --git a/python.d/apache_cache.chart.py b/python.d/apache_cache.chart.py index 2510cd43..3681a851 100644 --- a/python.d/apache_cache.chart.py +++ b/python.d/apache_cache.chart.py @@ -1,11 +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 +retries = 60 +# update_every = 3 ORDER = ['cache'] CHARTS = { @@ -13,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"] ]} } @@ -22,30 +24,37 @@ class Service(LogService): def __init__(self, configuration=None, name=None): LogService.__init__(self, configuration=configuration, name=name) if len(self.log_path) == 0: - self.log_path = "/var/log/httpd/cache.log" + self.log_path = "/var/log/apache2/cache.log" 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 - if hit + miss == 0: - return None - - return {'hit': int(hit/float(hit+miss) * 100), - 'miss': int(miss/float(hit+miss) * 100)} + return {'hit': hit, + 'miss': miss, + 'other': other}