diff options
author | Austin S. Hemmelgarn <ahferroin7@gmail.com> | 2018-09-27 07:03:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 07:03:56 -0400 |
commit | 3938fa3065830d79705d08856f1ab4f8c0431cf8 (patch) | |
tree | 7de138a096e4fe48dfb63367082abd2f41aa0e7d | |
parent | 8156681797d31d2fb38038ccbb4269a6e95f7cca (diff) |
Python.d PEP 8 cleanup, modules M (#4289)
* python.d/mdstat.chart.py PEP 8 cleanups
Fixes formatting for container literals and quoting of strings.
* python.d/megacli.chart.py PEP 8 cleanup
Fixes quoting of strings and formatting of container literals.
* python.d/memcached.chart.py PEP 8 cleanup
Fixes string quoting and formatting of container literals.
* python.d/mongodb.chart.py PEP 8 cleanup
Fixes string quoting and formatting of container literals.
* python.d/monit.chart.py PEP 8 cleanup
Fixes quoting of strings and formatting of container literals.
* python.d/mysql.chart.py PEP 8 cleanups
Fix formatting of container literals and usage of blank lines.
-rw-r--r-- | python.d/mdstat.chart.py | 17 | ||||
-rw-r--r-- | python.d/megacli.chart.py | 31 | ||||
-rw-r--r-- | python.d/memcached.chart.py | 58 | ||||
-rw-r--r-- | python.d/mongodb.chart.py | 132 | ||||
-rw-r--r-- | python.d/monit.chart.py | 48 | ||||
-rw-r--r-- | python.d/mysql.chart.py | 418 |
6 files changed, 430 insertions, 274 deletions
diff --git a/python.d/mdstat.chart.py b/python.d/mdstat.chart.py index 410c4ffa38..ffc8fffa88 100644 --- a/python.d/mdstat.chart.py +++ b/python.d/mdstat.chart.py @@ -17,7 +17,7 @@ ORDER = ['mdstat_health'] CHARTS = { 'mdstat_health': { 'options': [None, 'Faulty Devices In MD', 'failed disks', 'health', 'md.health', 'line'], - 'lines': list() + 'lines': [] } } @@ -33,12 +33,13 @@ RE_STATUS = re.compile(r' (?P<array>[a-zA-Z_0-9]+) : active .+ ' def md_charts(name): - order = ['{0}_disks'.format(name), - '{0}_operation'.format(name), - '{0}_mismatch_cnt'.format(name), - '{0}_finish'.format(name), - '{0}_speed'.format(name) - ] + order = [ + '{0}_disks'.format(name), + '{0}_operation'.format(name), + '{0}_mismatch_cnt'.format(name), + '{0}_finish'.format(name), + '{0}_speed'.format(name) + ] charts = dict() charts[order[0]] = { @@ -85,7 +86,7 @@ def md_charts(name): class MD: def __init__(self, raw_data): - self.name = raw_data["array"] + self.name = raw_data['array'] self.d = raw_data def data(self): diff --git a/python.d/megacli.chart.py b/python.d/megacli.chart.py index 22622e07b7..c1e7b54a7a 100644 --- a/python.d/megacli.chart.py +++ b/python.d/megacli.chart.py @@ -23,8 +23,7 @@ def adapter_charts(ads): charts = { 'adapter_degraded': { - 'options': [ - None, 'Adapter State', 'is degraded', 'adapter', 'megacli.adapter_degraded', 'line'], + 'options': [None, 'Adapter State', 'is degraded', 'adapter', 'megacli.adapter_degraded', 'line'], 'lines': dims(ads) }, } @@ -43,15 +42,14 @@ def pd_charts(pds): charts = { 'pd_media_error': { - 'options': [ - None, 'Physical Drives Media Errors', 'errors/s', 'pd', 'megacli.pd_media_error', 'line' - ], - 'lines': dims("media_error", pds)}, + 'options': [None, 'Physical Drives Media Errors', 'errors/s', 'pd', 'megacli.pd_media_error', 'line'], + 'lines': dims('media_error', pds) + }, 'pd_predictive_failure': { - 'options': [ - None, 'Physical Drives Predictive Failures', 'failures/s', 'pd', 'megacli.pd_predictive_failure', 'line' - ], - 'lines': dims("predictive_failure", pds)} + 'options': [None, 'Physical Drives Predictive Failures', 'failures/s', 'pd', + 'megacli.pd_predictive_failure', 'line'], + 'lines': dims('predictive_failure', pds) + } } return order, charts @@ -66,8 +64,8 @@ def battery_charts(bats): charts.update( { 'bbu_{0}_relative_charge'.format(b.id): { - 'options': [ - None, 'Relative State of Charge', '%', 'battery', 'megacli.bbu_relative_charge', 'line'], + 'options': [None, 'Relative State of Charge', '%', 'battery', + 'megacli.bbu_relative_charge', 'line'], 'lines': [ ['bbu_{0}_relative_charge'.format(b.id), 'adapter {0}'.format(b.id)], ] @@ -80,8 +78,7 @@ def battery_charts(bats): charts.update( { 'bbu_{0}_cycle_count'.format(b.id): { - 'options': [ - None, 'Cycle Count', 'cycle count', 'battery', 'megacli.bbu_cycle_count', 'line'], + 'options': [None, 'Cycle Count', 'cycle count', 'battery', 'megacli.bbu_cycle_count', 'line'], 'lines': [ ['bbu_{0}_cycle_count'.format(b.id), 'adapter {0}'.format(b.id)], ] @@ -106,13 +103,13 @@ RE_BATTERY = re.compile( def find_adapters(d): - keys = ("Adapter #", "State") + keys = ('Adapter #', 'State') d = ' '.join(v.strip() for v in d if v.startswith(keys)) return [Adapter(*v) for v in RE_ADAPTER.findall(d)] def find_pds(d): - keys = ("Slot Number", "Media Error Count", "Predictive Failure Count") + keys = ('Slot Number', 'Media Error Count', 'Predictive Failure Count') d = ' '.join(v.strip() for v in d if v.startswith(keys)) return [PD(*v) for v in RE_VD.findall(d)] @@ -131,7 +128,7 @@ class Adapter: def data(self): return { 'adapter_{0}_degraded'.format(self.id): self.state, - } + } class PD: diff --git a/python.d/memcached.chart.py b/python.d/memcached.chart.py index 4e1112f82d..8dbc52a4da 100644 --- a/python.d/memcached.chart.py +++ b/python.d/memcached.chart.py @@ -29,92 +29,106 @@ CHARTS = { 'lines': [ ['avail', 'available', 'absolute', 1, 1048576], ['used', 'used', 'absolute', 1, 1048576] - ]}, + ] + }, 'net': { 'options': [None, 'Network', 'kilobits/s', 'network', 'memcached.net', 'area'], 'lines': [ ['bytes_read', 'in', 'incremental', 8, 1024], ['bytes_written', 'out', 'incremental', -8, 1024] - ]}, + ] + }, 'connections': { 'options': [None, 'Connections', 'connections/s', 'connections', 'memcached.connections', 'line'], 'lines': [ ['curr_connections', 'current', 'incremental'], ['rejected_connections', 'rejected', 'incremental'], ['total_connections', 'total', 'incremental'] - ]}, + ] + }, 'items': { 'options': [None, 'Items', 'items', 'items', 'memcached.items', 'line'], 'lines': [ ['curr_items', 'current', 'absolute'], ['total_items', 'total', 'absolute'] - ]}, + ] + }, 'evicted_reclaimed': { 'options': [None, 'Items', 'items', 'items', 'memcached.evicted_reclaimed', 'line'], 'lines': [ ['reclaimed', 'reclaimed', 'absolute'], ['evictions', 'evicted', 'absolute'] - ]}, + ] + }, 'get': { 'options': [None, 'Requests', 'requests', 'get ops', 'memcached.get', 'stacked'], 'lines': [ ['get_hits', 'hits', 'percent-of-absolute-row'], ['get_misses', 'misses', 'percent-of-absolute-row'] - ]}, + ] + }, 'get_rate': { 'options': [None, 'Rate', 'requests/s', 'get ops', 'memcached.get_rate', 'line'], 'lines': [ ['cmd_get', 'rate', 'incremental'] - ]}, + ] + }, 'set_rate': { 'options': [None, 'Rate', 'requests/s', 'set ops', 'memcached.set_rate', 'line'], 'lines': [ ['cmd_set', 'rate', 'incremental'] - ]}, + ] + }, 'delete': { 'options': [None, 'Requests', 'requests', 'delete ops', 'memcached.delete', 'stacked'], 'lines': [ ['delete_hits', 'hits', 'percent-of-absolute-row'], ['delete_misses', 'misses', 'percent-of-absolute-row'], - ]}, + ] + }, 'cas': { 'options': [None, 'Requests', 'requests', 'check and set ops', 'memcached.cas', 'stacked'], 'lines': [ ['cas_hits', 'hits', 'percent-of-absolute-row'], ['cas_misses', 'misses', 'percent-of-absolute-row'], ['cas_badval', 'bad value', 'percent-of-absolute-row'] - ]}, + ] + }, 'increment': { 'options': [None, 'Requests', 'requests', 'increment ops', 'memcached.increment', 'stacked'], 'lines': [ ['incr_hits', 'hits', 'percent-of-absolute-row'], ['incr_misses', 'misses', 'percent-of-absolute-row'] - ]}, + ] + }, 'decrement': { 'options': [None, 'Requests', 'requests', 'decrement ops', 'memcached.decrement', 'stacked'], 'lines': [ ['decr_hits', 'hits', 'percent-of-absolute-row'], ['decr_misses', 'misses', 'percent-of-absolute-row'] - ]}, + ] + }, 'touch': { 'options': [None, 'Requests', 'requests', 'touch ops', 'memcached.touch', 'stacked'], 'lines': [ ['touch_hits', 'hits', 'percent-of-absolute-row'], ['touch_misses', 'misses', 'percent-of-absolute-row'] - ]}, + ] + }, 'touch_rate': { 'options': [None, 'Rate', 'requests/s', 'touch ops', 'memcached.touch_rate', 'line'], 'lines': [ ['cmd_touch', 'rate', 'incremental'] - ]} + ] + } } class Service(SocketService): def __init__(self, configuration=None, name=None): SocketService.__init__(self, configuration=configuration, name=name) - self.request = "stats\r\n" - self.host = "localhost" + self.request = 'stats\r\n' + self.host = 'localhost' self.port = 11211 self._keep_alive = True self.unix_socket = None @@ -132,13 +146,13 @@ class Service(SocketService): return None if response.startswith('ERROR'): - self.error("received ERROR") + self.error('received ERROR') return None try: - parsed = response.split("\n") + parsed = response.split('\n') except AttributeError: - self.error("response is invalid/empty") + self.error('response is invalid/empty') return None # split the response @@ -149,7 +163,7 @@ class Service(SocketService): t = line[5:].split(' ') data[t[0]] = t[1] except (IndexError, ValueError): - self.debug("invalid line received: " + str(line)) + self.debug('invalid line received: ' + str(line)) if not data: self.error("received data doesn't have any records") @@ -166,10 +180,10 @@ class Service(SocketService): def _check_raw_data(self, data): if data.endswith('END\r\n'): - self.debug("received full response from memcached") + self.debug('received full response from memcached') return True - self.debug("waiting more data from memcached") + self.debug('waiting more data from memcached') return False def check(self): diff --git a/python.d/mongodb.chart.py b/python.d/mongodb.chart.py index c0b50be4d9..aad3b2b54b 100644 --- a/python.d/mongodb.chart.py +++ b/python.d/mongodb.chart.py @@ -32,7 +32,8 @@ REPL_SET_STATES = [ ('6', 'unknown'), ('9', 'rollback'), ('10', 'removed'), - ('0', 'startup')] + ('0', 'startup') +] def multiply_by_100(value): @@ -142,12 +143,37 @@ DBSTATS = [ ] # charts order (can be overridden if you want less charts, or different order) -ORDER = ['read_operations', 'write_operations', 'active_clients', 'journaling_transactions', - 'journaling_volume', 'background_flush_average', 'background_flush_last', 'background_flush_rate', - 'wiredtiger_read', 'wiredtiger_write', 'cursors', 'connections', 'memory', 'page_faults', - 'queued_requests', 'record_moves', 'wiredtiger_cache', 'wiredtiger_pages_evicted', 'asserts', - 'locks_collection', 'locks_database', 'locks_global', 'locks_metadata', 'locks_oplog', - 'dbstats_objects', 'tcmalloc_generic', 'tcmalloc_metrics', 'command_total_rate', 'command_failed_rate'] +ORDER = [ + 'read_operations', + 'write_operations', + 'active_clients', + 'journaling_transactions', + 'journaling_volume', + 'background_flush_average', + 'background_flush_last', + 'background_flush_rate', + 'wiredtiger_read', + 'wiredtiger_write', + 'cursors', + 'connections', + 'memory', + 'page_faults', + 'queued_requests', + 'record_moves', + 'wiredtiger_cache', + 'wiredtiger_pages_evicted', + 'asserts', + 'locks_collection', + 'locks_database', + 'locks_global', + 'locks_metadata', + 'locks_oplog', + 'dbstats_objects', + 'tcmalloc_generic', + 'tcmalloc_metrics', + 'command_total_rate', + 'command_failed_rate' +] CHARTS = { 'read_operations': { @@ -156,7 +182,8 @@ CHARTS = { 'lines': [ ['query', None, 'incremental'], ['getmore', None, 'incremental'] - ]}, + ] + }, 'write_operations': { 'options': [None, 'Received write requests', 'requests/s', 'throughput metrics', 'mongodb.write_operations', 'line'], @@ -164,57 +191,66 @@ CHARTS = { ['insert', None, 'incremental'], ['update', None, 'incremental'], ['delete', None, 'incremental'] - ]}, + ] + }, 'active_clients': { 'options': [None, 'Clients with read or write operations in progress or queued', 'clients', 'throughput metrics', 'mongodb.active_clients', 'line'], 'lines': [ ['activeClients_readers', 'readers', 'absolute'], ['activeClients_writers', 'writers', 'absolute'] - ]}, + ] + }, 'journaling_transactions': { 'options': [None, 'Transactions that have been written to the journal', 'commits', 'database performance', 'mongodb.journaling_transactions', 'line'], 'lines': [ ['commits', None, 'absolute'] - ]}, + ] + }, 'journaling_volume': { 'options': [None, 'Volume of data written to the journal', 'MB', 'database performance', 'mongodb.journaling_volume', 'line'], 'lines': [ ['journaledMB', 'volume', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_average': { 'options': [None, 'Average time taken by flushes to execute', 'ms', 'database performance', 'mongodb.background_flush_average', 'line'], 'lines': [ ['average_ms', 'time', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_last': { 'options': [None, 'Time taken by the last flush operation to execute', 'ms', 'database performance', 'mongodb.background_flush_last', 'line'], 'lines': [ ['last_ms', 'time', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_rate': { 'options': [None, 'Flushes rate', 'flushes', 'database performance', 'mongodb.background_flush_rate', 'line'], 'lines': [ ['flushes', 'flushes', 'incremental', 1, 1] - ]}, + ] + }, 'wiredtiger_read': { 'options': [None, 'Read tickets in use and remaining', 'tickets', 'database performance', 'mongodb.wiredtiger_read', 'stacked'], 'lines': [ ['wiredTigerRead_available', 'available', 'absolute', 1, 1], ['wiredTigerRead_out', 'inuse', 'absolute', 1, 1] - ]}, + ] + }, 'wiredtiger_write': { 'options': [None, 'Write tickets in use and remaining', 'tickets', 'database performance', 'mongodb.wiredtiger_write', 'stacked'], 'lines': [ ['wiredTigerWrite_available', 'available', 'absolute', 1, 1], ['wiredTigerWrite_out', 'inuse', 'absolute', 1, 1] - ]}, + ] + }, 'cursors': { 'options': [None, 'Currently openned cursors, cursors with timeout disabled and timed out cursors', 'cursors', 'database performance', 'mongodb.cursors', 'stacked'], @@ -222,14 +258,16 @@ CHARTS = { ['cursor_total', 'openned', 'absolute', 1, 1], ['noTimeout', None, 'absolute', 1, 1], ['timedOut', None, 'incremental', 1, 1] - ]}, + ] + }, 'connections': { 'options': [None, 'Currently connected clients and unused connections', 'connections', 'resource utilization', 'mongodb.connections', 'stacked'], 'lines': [ ['connections_available', 'unused', 'absolute', 1, 1], ['connections_current', 'connected', 'absolute', 1, 1] - ]}, + ] + }, 'memory': { 'options': [None, 'Memory metrics', 'MB', 'resource utilization', 'mongodb.memory', 'stacked'], 'lines': [ @@ -237,26 +275,30 @@ CHARTS = { ['resident', None, 'absolute', 1, 1], ['nonmapped', None, 'absolute', 1, 1], ['mapped', None, 'absolute', 1, 1] - ]}, + ] + }, 'page_faults': { 'options': [None, 'Number of times MongoDB had to fetch data from disk', 'request/s', 'resource utilization', 'mongodb.page_faults', 'line'], 'lines': [ ['page_faults', None, 'incremental', 1, 1] - ]}, + ] + }, 'queued_requests': { 'options': [None, 'Currently queued read and write requests', 'requests', 'resource saturation', 'mongodb.queued_requests', 'line'], 'lines': [ ['currentQueue_readers', 'readers', 'absolute', 1, 1], ['currentQueue_writers', 'writers', 'absolute', 1, 1] - ]}, + ] + }, 'record_moves': { 'options': [None, 'Number of times documents had to be moved on-disk', 'number', 'resource saturation', 'mongodb.record_moves', 'line'], 'lines': [ ['moves', None, 'incremental', 1, 1] - ]}, + ] + }, 'asserts': { 'options': [ None, @@ -267,32 +309,36 @@ CHARTS = { ['warning', None, 'incremental', 1, 1], ['regular', None, 'incremental', 1, 1], ['user', None, 'incremental', 1, 1] - ]}, + ] + }, 'wiredtiger_cache': { 'options': [None, 'The percentage of the wiredTiger cache that is in use and cache with dirty bytes', 'percent', 'resource utilization', 'mongodb.wiredtiger_cache', 'stacked'], 'lines': [ ['wiredTiger_percent_clean', 'inuse', 'absolute', 1, 1000], ['wiredTiger_percent_dirty', 'dirty', 'absolute', 1, 1000] - ]}, + ] + }, 'wiredtiger_pages_evicted': { 'options': [None, 'Pages evicted from the cache', 'pages', 'resource utilization', 'mongodb.wiredtiger_pages_evicted', 'stacked'], 'lines': [ ['unmodified', None, 'absolute', 1, 1], ['modified', None, 'absolute', 1, 1] - ]}, + ] + }, 'dbstats_objects': { 'options': [None, 'Number of documents in the database among all the collections', 'documents', 'storage size metrics', 'mongodb.dbstats_objects', 'stacked'], - 'lines': [ - ]}, + 'lines': [] + }, 'tcmalloc_generic': { 'options': [None, 'Tcmalloc generic metrics', 'MB', 'tcmalloc', 'mongodb.tcmalloc_generic', 'stacked'], 'lines': [ ['current_allocated_bytes', 'allocated', 'absolute', 1, 1048576], ['heap_size', 'heap_size', 'absolute', 1, 1048576] - ]}, + ] + }, 'tcmalloc_metrics': { 'options': [None, 'Tcmalloc metrics', 'KB', 'tcmalloc', 'mongodb.tcmalloc_metrics', 'stacked'], 'lines': [ @@ -302,7 +348,8 @@ CHARTS = { ['pageheap_unmapped_bytes', 'pageheap_unmapped', 'absolute', 1, 1024], ['thread_cache_free_bytes', 'thread_cache_free', 'absolute', 1, 1024], ['transfer_cache_free_bytes', 'transfer_cache_free', 'absolute', 1, 1024] - ]}, + ] + }, 'command_total_rate': { 'options': [None, 'Commands total rate', 'commands/s', 'commands', 'mongodb.command_total_rate', 'stacked'], 'lines': [ @@ -313,7 +360,8 @@ CHARTS = { ['findAndModify_total', 'findAndModify', 'incremental', 1, 1], ['insert_total', 'insert', 'incremental', 1, 1], ['update_total', 'update', 'incremental', 1, 1] - ]}, + ] + }, 'command_failed_rate': { 'options': [None, 'Commands failed rate', 'commands/s', 'commands', 'mongodb.command_failed_rate', 'stacked'], 'lines': [ @@ -324,7 +372,8 @@ CHARTS = { ['findAndModify_failed', 'findAndModify', 'incremental', 1, 1], ['insert_failed', 'insert', 'incremental', 1, 1], ['update_failed', 'update', 'incremental', 1, 1] - ]}, + ] + }, 'locks_collection': { 'options': [None, 'Collection lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_collection', 'stacked'], @@ -333,7 +382,8 @@ CHARTS = { ['Collection_W', 'exclusive', 'incremental'], ['Collection_r', 'intent_shared', 'incremental'], ['Collection_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_database': { 'options': [None, 'Database lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_database', 'stacked'], @@ -342,7 +392,8 @@ CHARTS = { ['Database_W', 'exclusive', 'incremental'], ['Database_r', 'intent_shared', 'incremental'], ['Database_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_global': { 'options': [None, 'Global lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_global', 'stacked'], @@ -351,21 +402,24 @@ CHARTS = { ['Global_W', 'exclusive', 'incremental'], ['Global_r', 'intent_shared', 'incremental'], ['Global_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_metadata': { 'options': [None, 'Metadata lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_metadata', 'stacked'], 'lines': [ ['Metadata_R', 'shared', 'incremental'], ['Metadata_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_oplog': { 'options': [None, 'Lock on the oplog. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_oplog', 'stacked'], 'lines': [ ['oplog_r', 'intent_shared', 'incremental'], ['oplog_w', 'intent_exclusive', 'incremental'] - ]} + ] + } } @@ -565,9 +619,9 @@ class Service(SimpleService): raw_data['getReplicationInfo'] = dict() try: raw_data['getReplicationInfo']['ASCENDING'] = self.connection.local.oplog.rs.find().sort( - "$natural", ASCENDING).limit(1)[0] + '$natural', ASCENDING).limit(1)[0] raw_data['getReplicationInfo']['DESCENDING'] = self.connection.local.oplog.rs.find().sort( - "$natural", DESCENDING).limit(1)[0] + '$natural', DESCENDING).limit(1)[0] return raw_data except PyMongoError: return None diff --git a/python.d/monit.chart.py b/python.d/monit.chart.py index 24595ffaa2..f6544ab384 100644 --- a/python.d/monit.chart.py +++ b/python.d/monit.chart.py @@ -12,17 +12,26 @@ priority = 60000 retries = 60 # see enum State_Type from monit.h (https://bitbucket.org/tildeslash/monit/src/master/src/monit.h) -MONIT_SERVICE_NAMES = [ 'Filesystem', 'Directory', 'File', 'Process', 'Host', 'System', 'Fifo', 'Program', 'Net' ] -DEFAULT_SERVICES_IDS = [ 0, 1, 2, 3, 4, 6, 7, 8 ] +MONIT_SERVICE_NAMES = ['Filesystem', 'Directory', 'File', 'Process', 'Host', 'System', 'Fifo', 'Program', 'Net'] +DEFAULT_SERVICES_IDS = [0, 1, 2, 3, 4, 6, 7, 8] # charts order (can be overridden if you want less charts, or different order) -ORDER = [ 'filesystem', 'directory', 'file', 'process', 'process_uptime', 'process_threads', 'process_children', 'host', 'host_latency', 'system', 'fifo', 'program', 'net' ] +ORDER = [ + 'filesystem', + 'directory', + 'file', + 'process', + 'process_uptime', + 'process_threads', + 'process_children', + 'host', + 'host_latency', + 'system', + 'fifo', + 'program', + 'net' +] CHARTS = { - # id: { - # 'options': [name, title, units, family, context, charttype], - # 'lines': [ - # [unique_dimension_name, name, algorithm, multiplier, divisor] - # ]} 'filesystem': { 'options': ['filesystems', 'Filesystems', 'filesystems', 'filesystem', 'monit.filesystems', 'line'], 'lines': [] @@ -48,15 +57,18 @@ CHARTS = { 'lines': [] }, 'process_uptime': { - 'options': ['processes uptime', 'Processes uptime', 'seconds', 'applications', 'monit.process_uptime', 'line', 'hidden'], + 'options': ['processes uptime', 'Processes uptime', 'seconds', 'applications', + 'monit.process_uptime', 'line', 'hidden'], 'lines': [] }, 'process_threads': { - 'options': ['processes threads', 'Processes threads', 'threads', 'applications', 'monit.process_threads', 'line'], + 'options': ['processes threads', 'Processes threads', 'threads', 'applications', + 'monit.process_threads', 'line'], 'lines': [] }, 'process_children': { - 'options': ['processes childrens', 'Child processes', 'childrens', 'applications', 'monit.process_childrens', 'line'], + 'options': ['processes childrens', 'Child processes', 'childrens', 'applications', + 'monit.process_childrens', 'line'], 'lines': [] }, 'host': { @@ -68,11 +80,13 @@ CHARTS = { 'lines': [] }, 'net': { - 'options': ['interfaces', 'Network interfaces and addresses', 'interfaces', 'network', 'monit.networks', 'line'], + 'options': ['interfaces', 'Network interfaces and addresses', 'interfaces', 'network', + 'monit.networks', 'line'], 'lines': [] }, } + class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) @@ -112,18 +126,19 @@ class Service(UrlService): continue xpath_query = "./service[@type='{0}']".format(service_id) - self.debug("Searching for {0} as {1}".format(service_category, xpath_query)) + self.debug('Searching for {0} as {1}'.format(service_category, xpath_query)) for service_node in xml.findall(xpath_query): service_name = service_node.find('name').text service_status = service_node.find('status').text service_monitoring = service_node.find('monitor').text - self.debug('=> found {0} with type={1}, status={2}, monitoring={3}'.format(service_name, service_id, service_status, service_monitoring)) + self.debug('=> found {0} with type={1}, status={2}, monitoring={3}'.format(service_name, + service_id, service_status, service_monitoring)) dimension_key = service_category + '_' + service_name if dimension_key not in self.charts[service_category]: self.charts[service_category].add_dimension([dimension_key, service_name, 'absolute']) - data[dimension_key] = 1 if service_status == "0" and service_monitoring == "1" else 0 + data[dimension_key] = 1 if service_status == '0' and service_monitoring == '1' else 0 if service_category == 'process': for subnode in ('uptime', 'threads', 'children'): @@ -144,7 +159,8 @@ class Service(UrlService): continue dimension_key = 'host_latency_{0}'.format(service_name) if dimension_key not in self.charts['host_latency']: - self.charts['host_latency'].add_dimension([dimension_key, service_name, 'absolute', 1000, 1000000]) + self.charts['host_latency'].add_dimension([dimension_key, service_name, + 'absolute', 1000, 1000000]) data[dimension_key] = float(subnode_value.text) * 1000000 return data or None diff --git a/python.d/mysql.chart.py b/python.d/mysql.chart.py index e3f4be8a1f..a2a32f6747 100644 --- a/python.d/mysql.chart.py +++ b/python.d/mysql.chart.py @@ -17,117 +17,119 @@ QUERY_SLAVE = 'SHOW SLAVE STATUS;' QUERY_VARIABLES = 'SHOW GLOBAL VARIABLES LIKE \'max_connections\';' GLOBAL_STATS = [ - 'Bytes_received', - 'Bytes_sent', - 'Queries', - 'Questions', - 'Slow_queries', - 'Handler_commit', - 'Handler_delete', - 'Handler_prepare', - 'Handler_read_first', - 'Handler_read_key', - 'Handler_read_next', - 'Handler_read_prev', - 'Handler_read_rnd', - 'Handler_read_rnd_next', - 'Handler_rollback', - 'Handler_savepoint', - 'Handler_savepoint_rollback', - 'Handler_update', - 'Handler_write', - 'Table_locks_immediate', - 'Table_locks_waited', - 'Select_full_join', - 'Select_full_range_join', - 'Select_range', - 'Select_range_check', - 'Select_scan', - 'Sort_merge_passes', - 'Sort_range', - 'Sort_scan', - 'Created_tmp_disk_tables', - 'Created_tmp_files', - 'Created_tmp_tables', - 'Connections', - 'Aborted_connects', - 'Max_used_connections', - 'Binlog_cache_disk_use', - 'Binlog_cache_use', - 'Threads_connected', - 'Threads_created', - 'Threads_cached', - 'Threads_running', - 'Thread_cache_misses', - 'Innodb_data_read', - 'Innodb_data_written', - 'Innodb_data_reads', - 'Innodb_data_writes', - 'Innodb_data_fsyncs', - 'Innodb_data_pending_reads', - 'Innodb_data_pending_writes', - 'Innodb_data_pending_fsyncs', - 'Innodb_log_waits', - 'Innodb_log_write_requests', - 'Innodb_log_writes', - 'Innodb_os_log_fsyncs', - 'Innodb_os_log_pending_fsyncs', - 'Innodb_os_log_pending_writes', - 'Innodb_os_log_written', - 'Innodb_row_lock_current_waits', - 'Innodb_rows_inserted', - 'Innodb_rows_read', - 'Innodb_rows_updated', - 'Innodb_rows_deleted', - 'Innodb_buffer_pool_pages_data', - 'Innodb_buffer_pool_pages_dirty', - 'Innodb_buffer_pool_pages_free', - 'Innodb_buffer_pool_pages_flushed', - 'Innodb_buffer_pool_pages_misc', - 'Innodb_buffer_pool_pages_total', - 'Innodb_buffer_pool_bytes_data', - 'Innodb_buffer_pool_bytes_dirty', - 'Innodb_buffer_pool_read_ahead', - 'Innodb_buffer_pool_read_ahead_evicted', - 'Innodb_buffer_pool_read_ahead_rnd', - 'Innodb_buffer_pool_read_requests', - 'Innodb_buffer_pool_write_requests', - 'Innodb_buffer_pool_reads', - 'Innodb_buffer_pool_wait_free', - 'Qcache_hits', - 'Qcache_lowmem_prunes', - 'Qcache_inserts', - 'Qcache_not_cached', - 'Qcache_queries_in_cache', - 'Qcache_free_memory', - 'Qcache_free_blocks', - 'Qcache_total_blocks', - 'Key_blocks_unused', - 'Key_blocks_used', - 'Key_blocks_not_flushed', - 'Key_read_requests', - 'Key_write_requests', - 'Key_reads', - 'Key_writes', - 'Open_files', - 'Opened_files', - 'Binlog_stmt_cache_disk_use', - 'Binlog_stmt_cache_use', - 'Connection_errors_accept', - 'Connection_errors_internal', - 'Connection_errors_max_connections', - 'Connection_errors_peer_address', - 'Connection_errors_select', - 'Connection_errors_tcpwrap', - 'wsrep_local_recv_queue', - 'wsrep_local_send_queue', - 'wsrep_received', - 'wsrep_replicated', - 'wsrep_received_bytes', - 'wsrep_replicated_bytes', - 'wsrep_local_bf_aborts', - 'wsrep_local_cert_failures', - 'wsrep_flow_control_paused_ns'] + 'Bytes_received', + 'Bytes_sent', + 'Queries', + 'Questions', + 'Slow_queries', + 'Handler_commit', + 'Handler_delete', + 'Handler_prepare', + 'Handler_read_first', + 'Handler_read_key', + 'Handler_read_next', + 'Handler_read_prev', + 'Handler_read_rnd', + 'Handler_read_rnd_next', + 'Handler_rollback', + 'Handler_savepoint', + 'Handler_savepoint_rollback', + 'Handler_update', + 'Handler_write', + 'Table_locks_immediate', + 'Table_locks_waited', + 'Select_full_join', + 'Select_full_range_join', + 'Select_range', + 'Select_range_check', + 'Select_scan', + 'Sort_merge_passes', + 'Sort_range', + 'Sort_scan', + 'Created_tmp_disk_tables', + 'Created_tmp_files', + 'Created_tmp_tables', + 'Connections', + 'Aborted_connects', + 'Max_used_connections', + 'Binlog_cache_disk_use', + 'Binlog_cache_use', + 'Threads_connected', + 'Threads_created', + 'Threads_cached', + 'Threads_running', + 'Thread_cache_misses', + 'Innodb_data_read', + 'Innodb_data_written', + 'Innodb_data_reads', + 'Innodb_data_writes', + 'Innodb_data_ |