diff options
Diffstat (limited to 'collectors/python.d.plugin/gearman/gearman.chart.py')
-rw-r--r-- | collectors/python.d.plugin/gearman/gearman.chart.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/collectors/python.d.plugin/gearman/gearman.chart.py b/collectors/python.d.plugin/gearman/gearman.chart.py index 26f3533c4..5e280a4d8 100644 --- a/collectors/python.d.plugin/gearman/gearman.chart.py +++ b/collectors/python.d.plugin/gearman/gearman.chart.py @@ -4,9 +4,9 @@ # Gearman Netdata Plugin -from bases.FrameworkServices.SocketService import SocketService from copy import deepcopy +from bases.FrameworkServices.SocketService import SocketService CHARTS = { 'total_workers': { @@ -29,6 +29,7 @@ def job_chart_template(job_name): ] } + def build_result_dict(job): """ Get the status for each job @@ -46,6 +47,7 @@ def build_result_dict(job): '{0}_running'.format(job['job_name']): running, } + def parse_worker_data(job): job_name = job[0] job_metrics = job[1:] @@ -119,6 +121,7 @@ class Service(SocketService): Example output returned from _get_raw_data(): + prefix generic_worker4 78 78 500 generic_worker2 78 78 500 generic_worker3 0 0 760 generic_worker1 0 0 500 @@ -135,13 +138,24 @@ class Service(SocketService): self.debug("Gearman returned no data") raise GearmanReadException() - job_lines = raw.splitlines()[:-1] - job_lines = [job.split() for job in sorted(job_lines)] + workers = list() + + for line in raw.splitlines()[:-1]: + parts = line.split() + if not parts: + continue + + name = '_'.join(parts[:-3]) + try: + values = [int(w) for w in parts[-3:]] + except ValueError: + continue - for line in job_lines: - line[1:] = map(int, line[1:]) + w = [name] + w.extend(values) + workers.append(w) - return job_lines + return workers def process_jobs(self, active_jobs): |