diff options
Diffstat (limited to 'collectors/python.d.plugin')
62 files changed, 747 insertions, 580 deletions
diff --git a/collectors/python.d.plugin/apache/apache.chart.py b/collectors/python.d.plugin/apache/apache.chart.py index a9ac72581f..655616d072 100644 --- a/collectors/python.d.plugin/apache/apache.chart.py +++ b/collectors/python.d.plugin/apache/apache.chart.py @@ -5,63 +5,60 @@ from bases.FrameworkServices.UrlService import UrlService -# default module values (can be overridden per job in `config`) -# update_every = 2 -priority = 60000 -# default job configuration (overridden by python.d.plugin) -# config = {'local': { -# 'update_every': update_every, -# 'retries': retries, -# 'priority': priority, -# 'url': 'http://www.apache.org/server-status?auto' -# }} - -# charts order (can be overridden if you want less charts, or different order) -ORDER = ['requests', 'connections', 'conns_async', 'net', 'workers', 'reqpersec', 'bytespersec', 'bytesperreq'] +ORDER = [ + 'requests', + 'connections', + 'conns_async', + 'net', + 'workers', + 'reqpersec', + 'bytespersec', + 'bytesperreq', +] CHARTS = { 'bytesperreq': { - 'options': [None, 'apache Lifetime Avg. Response Size', 'bytes/request', + 'options': [None, 'Lifetime Avg. Request Size', 'KiB', 'statistics', 'apache.bytesperreq', 'area'], 'lines': [ - ['size_req'] + ['size_req', 'size', 'absolute', 1, 1024 * 100000] ]}, 'workers': { - 'options': [None, 'apache Workers', 'workers', 'workers', 'apache.workers', 'stacked'], + 'options': [None, 'Workers', 'workers', 'workers', 'apache.workers', 'stacked'], 'lines': [ ['idle'], ['busy'], ]}, 'reqpersec': { - 'options': [None, 'apache Lifetime Avg. Requests/s', 'requests/s', 'statistics', + 'options': [None, 'Lifetime Avg. Requests/s', 'requests/s', 'statistics', 'apache.reqpersec', 'area'], 'lines': [ - ['requests_sec'] + ['requests_sec', 'requests', 'absolute', 1, 100000] ]}, 'bytespersec': { - 'options': [None, 'apache Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics', + 'options': [None, 'Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics', 'apache.bytesperreq', 'area'], 'lines': [ - ['size_sec', None, 'absolute', 8, 1000] + ['size_sec', None, 'absolute', 8, 1000 * 100000] ]}, 'requests': { - 'options': [None, 'apache Requests', 'requests/s', 'requests', 'apache.requests', 'line'], + 'options': [None, 'Requests', 'requests/s', 'requests', 'apache.requests', 'line'], 'lines': [ ['requests', None, 'incremental'] ]}, 'net': { - 'options': [None, 'apache Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'], + 'options': [None, 'Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'], 'lines': [ ['sent', None, 'incremental', 8, 1] ]}, 'connections': { - 'options': [None, 'apache Connections', 'connections', 'connections', 'apache.connections', 'line'], + 'options': [None, 'Connections', 'connections', 'connections', 'apache.connections', 'line'], 'lines': [ ['connections'] ]}, 'conns_async': { - 'options': [None, 'apache Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'], + 'options': [None, 'Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'], 'lines': [ ['keepalive'], ['closing'], @@ -85,6 +82,14 @@ ASSIGNMENT = { 'ConnsAsyncWriting': 'writing' } +FLOAT_VALUES = [ + 'BytesPerReq', + 'ReqPerSec', + 'BytesPerSec', +] + +LIGHTTPD_MARKER = 'idle_servers' + class Service(UrlService): def __init__(self, configuration=None, name=None): @@ -95,20 +100,15 @@ class Service(UrlService): def check(self): self._manager = self._build_manager() + data = self._get_data() + if not data: return None - if 'idle_servers' in data: - self.module_name = 'lighttpd' - for chart in self.definitions: - if chart == 'workers': - lines = self.definitions[chart]['lines'] - lines[0] = ['idle_servers', 'idle'] - lines[1] = ['busy_servers', 'busy'] - opts = self.definitions[chart]['options'] - opts[1] = opts[1].replace('apache', 'lighttpd') - opts[4] = opts[4].replace('apache', 'lighttpd') + if LIGHTTPD_MARKER in data: + self.turn_into_lighttpd() + return True def _get_data(self): @@ -117,15 +117,44 @@ class Service(UrlService): :return: dict """ raw_data = self._get_raw_data() + if not raw_data: return None + data = dict() - for row in raw_data.split('\n'): - tmp = row.split(':') - if tmp[0] in ASSIGNMENT: - try: - data[ASSIGNMENT[tmp[0]]] = int(float(tmp[1])) - except (IndexError, ValueError): - continue + for line in raw_data.split('\n'): + try: + parse_line(line, data) + except ValueError: + continue + return data or None + + def turn_into_lighttpd(self): + self.module_name = 'lighttpd' + for chart in self.definitions: + if chart == 'workers': + lines = self.definitions[chart]['lines'] + lines[0] = ['idle_servers', 'idle'] + lines[1] = ['busy_servers', 'busy'] + opts = self.definitions[chart]['options'] + opts[1] = opts[1].replace('apache', 'lighttpd') + opts[4] = opts[4].replace('apache', 'lighttpd') + + +def parse_line(line, data): + parts = line.split(':') + + if len(parts) != 2: + return + + key, value = parts[0], parts[1] + + if key not in ASSIGNMENT: + return + + if key in FLOAT_VALUES: + data[ASSIGNMENT[key]] = int((float(value) * 100000)) + else: + data[ASSIGNMENT[key]] = int(value) diff --git a/collectors/python.d.plugin/beanstalk/beanstalk.chart.py b/collectors/python.d.plugin/beanstalk/beanstalk.chart.py index 8651eee5bb..ed945a7810 100644 --- a/collectors/python.d.plugin/beanstalk/beanstalk.chart.py +++ b/collectors/python.d.plugin/beanstalk/beanstalk.chart.py @@ -12,12 +12,18 @@ except ImportError: from bases.FrameworkServices.SimpleService import SimpleService from bases.loaders import safe_load -# default module values (can be overridden per job in `config`) -# update_every = 2 -priority = 60000 -ORDER = ['cpu_usage', 'jobs_rate', 'connections_rate', 'commands_rate', 'current_tubes', 'current_jobs', - 'current_connections', 'binlog', 'uptime'] +ORDER = [ + 'cpu_usage', + 'jobs_rate', + 'connections_rate', + 'commands_rate', + 'current_tubes', + 'current_jobs', + 'current_connections', + 'binlog', + 'uptime', +] CHARTS = { 'cpu_usage': { diff --git a/collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py b/collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py index c67aafc194..7ac1bc3dc1 100644 --- a/collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py +++ b/collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py @@ -11,10 +11,15 @@ from subprocess import Popen from bases.collection import find_binary from bases.FrameworkServices.SimpleService import SimpleService -priority = 60000 + update_every = 30 -ORDER = ['name_server_statistics', 'incoming_queries', 'outgoing_queries', 'named_stats_size'] +ORDER = [ + 'name_server_statistics', + 'incoming_queries', + 'outgoing_queries', + 'named_stats_size', +] CHARTS = { 'name_server_statistics': { @@ -43,7 +48,7 @@ CHARTS = { 'lines': [ ]}, 'named_stats_size': { - 'options': [None, 'Named Stats File Size', 'MB', 'file size', 'bind_rndc.stats_size', 'line'], + 'options': [None, 'Named Stats File Size', 'MiB', 'file size', 'bind_rndc.stats_size', 'line'], 'lines': [ ['stats_size', None, 'absolute', 1, 1 << 20] ] @@ -91,10 +96,20 @@ class Service(SimpleService): self.definitions = CHARTS self.named_stats_path = self.configuration.get('named_stats_path', '/var/log/bind/named.stats') self.rndc = find_binary('rndc') - self.data = dict(nms_requests=0, nms_responses=0, nms_failure=0, nms_auth=0, - nms_non_auth=0, nms_nxrrset=0, nms_success=0, nms_nxdomain=0, - nms_recursion=0, nms_duplicate=0, nms_rejected_queries=0, - nms_dropped_queries=0) + self.data = dict( + nms_requests=0, + nms_responses=0, + nms_failure=0, + nms_auth=0, + nms_non_auth=0, + nms_nxrrset=0, + nms_success=0, + nms_nxdomain=0, + nms_recursion=0, + nms_duplicate=0, + nms_rejected_queries=0, + nms_dropped_queries=0, + ) def check(self): if not self.rndc: diff --git a/collectors/python.d.plugin/boinc/boinc.chart.py b/collectors/python.d.plugin/boinc/boinc.chart.py index d14754c4bb..e10b28ceaf 100644 --- a/collectors/python.d.plugin/boinc/boinc.chart.py +++ b/collectors/python.d.plugin/boinc/boinc.chart.py @@ -10,7 +10,12 @@ from bases.FrameworkServices.SimpleService import SimpleService from third_party import boinc_client -ORDER = ['tasks', 'states', 'sched_states', 'process_states'] +ORDER = [ + 'tasks', + 'states', + 'sched_states', + 'process_states', +] CHARTS = { 'tasks': { @@ -141,14 +146,16 @@ class Service(SimpleService): def _get_data(self): if not self.is_alive(): return None + data = dict(_DATA_TEMPLATE) - results = [] + try: results = self.client.get_tasks() except socket.error: self.error('Connection is dead') self.alive = False return None + for task in results: data['total'] += 1 data[_TASK_MAP[task.state]] += 1 @@ -159,4 +166,5 @@ class Service(SimpleService): data[_PROC_MAP[task.active_task_state]] += 1 except AttributeError: pass - return data + + return data or None diff --git a/collectors/python.d.plugin/ceph/ceph.chart.py b/collectors/python.d.plugin/ceph/ceph.chart.py index 2f0c9211c2..6fd774d61a 100644 --- a/collectors/python.d.plugin/ceph/ceph.chart.py +++ b/collectors/python.d.plugin/ceph/ceph.chart.py @@ -9,13 +9,13 @@ try: except ImportError: CEPH = False -import os import json +import os + from bases.FrameworkServices.SimpleService import SimpleService # default module values (can be overridden per job in `config`) update_every = 10 -priority = 60000 ORDER = [ 'general_usage', @@ -36,7 +36,7 @@ ORDER = [ CHARTS = { 'general_usage': { - 'options': [None, 'Ceph General Space', 'KB', 'general', 'ceph.general_usage', 'stacked'], + 'options': [None, 'Ceph General Space', 'KiB', 'general', 'ceph.general_usage', 'stacked'], 'lines': [ ['general_available', 'avail', 'absolute'], ['general_usage', 'used', 'absolute'] @@ -49,7 +49,7 @@ CHARTS = { ] }, 'general_bytes': { - 'options': [None, 'Ceph General Read/Write Data/s', 'KB', 'general', 'ceph.general_bytes', + 'options': [None, 'Ceph General Read/Write Data/s', 'KiB/s', 'general', 'ceph.general_bytes', 'area'], 'lines': [ ['general_read_bytes', 'read', 'absolute', 1, 1024], @@ -73,7 +73,7 @@ CHARTS = { ] }, 'pool_usage': { - 'options': [None, 'Ceph Pools', 'KB', 'pool', 'ceph.pool_usage', 'line'], + 'options': [None, 'Ceph Pools', 'KiB', 'pool', 'ceph.pool_usage', 'line'], 'lines': [] }, 'pool_objects': { @@ -81,11 +81,11 @@ CHARTS = { 'lines': [] }, 'pool_read_bytes': { - 'options': [None, 'Ceph Read Pool Data/s', 'KB', 'pool', 'ceph.pool_read_bytes', 'area'], + 'options': [None, 'Ceph Read Pool Data/s', 'KiB/s', 'pool', 'ceph.pool_read_bytes', 'area'], 'lines': [] }, 'pool_write_bytes': { - 'options': [None, 'Ceph Write Pool Data/s', 'KB', 'pool', 'ceph.pool_write_bytes', 'area'], + 'options': [None, 'Ceph Write Pool Data/s', 'KiB/s', 'pool', 'ceph.pool_write_bytes', 'area'], 'lines': [] }, 'pool_read_operations': { @@ -97,7 +97,7 @@ CHARTS = { 'lines': [] }, 'osd_usage': { - 'options': [None, 'Ceph OSDs', 'KB', 'osd', 'ceph.osd_usage', 'line'], + 'options': [None, 'Ceph OSDs', 'KiB', 'osd', 'ceph.osd_usage', 'line'], 'lines': [] }, 'osd_apply_latency': { diff --git a/collectors/python.d.plugin/chrony/chrony.chart.py b/collectors/python.d.plugin/chrony/chrony.chart.py index 07fc3d1fcc..91f7250011 100644 --- a/collectors/python.d.plugin/chrony/chrony.chart.py +++ b/collectors/python.d.plugin/chrony/chrony.chart.py @@ -7,10 +7,19 @@ from bases.FrameworkServices.ExecutableService import ExecutableService # default module values (can be overridden per job in `config`) update_every = 5 -priority = 60000 + +CHRONY_COMMAND = 'chronyc -n tracking' # charts order (can be overridden if you want less charts, or different order) -ORDER = ['system', 'offsets', 'stratum', 'root', 'frequency', 'residualfreq', 'skew'] +ORDER = [ + 'system', + 'offsets', + 'stratum', + 'root', + 'frequency', + 'residualfreq', + 'skew', +] CHARTS = { 'system': { @@ -76,9 +85,9 @@ class Service(ExecutableService): def __init__(self, configuration=None, name=None): ExecutableService.__init__( self, configuration=configuration, name=name) - self.command = 'chronyc -n tracking' self.order = ORDER self.definitions = CHARTS + self.command = CHRONY_COMMAND def _get_data(self): """ diff --git a/collectors/python.d.plugin/couchdb/couchdb.chart.py b/collectors/python.d.plugin/couchdb/couchdb.chart.py index 7b30b4200c..a58694d705 100644 --- a/collectors/python.d.plugin/couchdb/couchdb.chart.py +++ b/collectors/python.d.plugin/couchdb/couchdb.c |