From 8a7b72f7cd1ccd547a03eb4243294e741d661d3f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 8 Feb 2019 08:30:37 +0100 Subject: Adding upstream version 1.12.0. Signed-off-by: Daniel Baumann --- collectors/python.d.plugin/go_expvar/README.md | 3 +- .../python.d.plugin/go_expvar/go_expvar.chart.py | 69 ++++++++++++---------- .../python.d.plugin/go_expvar/go_expvar.conf | 10 ++-- 3 files changed, 45 insertions(+), 37 deletions(-) (limited to 'collectors/python.d.plugin/go_expvar') diff --git a/collectors/python.d.plugin/go_expvar/README.md b/collectors/python.d.plugin/go_expvar/README.md index e3356e1f1..3942a7be8 100644 --- a/collectors/python.d.plugin/go_expvar/README.md +++ b/collectors/python.d.plugin/go_expvar/README.md @@ -169,7 +169,6 @@ and its base `UrlService` class. These are: update_every: 1 # the job's data collection frequency priority: 60000 # the job's order on the dashboard - retries: 60 # the job's number of restoration attempts user: admin # use when the expvar endpoint is protected by HTTP Basic Auth password: sekret # use when the expvar endpoint is protected by HTTP Basic Auth @@ -274,3 +273,5 @@ The images below show how do the final charts in netdata look. ![Custom charts](https://cloud.githubusercontent.com/assets/15180106/26762051/62ae915e-493b-11e7-8518-bd25a3886650.png) + +[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fgo_expvar%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() diff --git a/collectors/python.d.plugin/go_expvar/go_expvar.chart.py b/collectors/python.d.plugin/go_expvar/go_expvar.chart.py index 76e8b72ec..e82a87761 100644 --- a/collectors/python.d.plugin/go_expvar/go_expvar.chart.py +++ b/collectors/python.d.plugin/go_expvar/go_expvar.chart.py @@ -6,17 +6,24 @@ from __future__ import division import json +from collections import namedtuple + from bases.FrameworkServices.UrlService import UrlService -# default module values (can be overridden per job in `config`) -# update_every = 2 -priority = 60000 -retries = 60 +MEMSTATS_ORDER = [ + 'memstats_heap', + 'memstats_stack', + 'memstats_mspan', + 'memstats_mcache', + 'memstats_sys', + 'memstats_live_objects', + 'memstats_gc_pauses', +] MEMSTATS_CHARTS = { 'memstats_heap': { - 'options': ['heap', 'memory: size of heap memory structures', 'kB', 'memstats', + 'options': ['heap', 'memory: size of heap memory structures', 'KiB', 'memstats', 'expvar.memstats.heap', 'line'], 'lines': [ ['memstats_heap_alloc', 'alloc', 'absolute', 1, 1024], @@ -24,21 +31,21 @@ MEMSTATS_CHARTS = { ] }, 'memstats_stack': { - 'options': ['stack', 'memory: size of stack memory structures', 'kB', 'memstats', + 'options': ['stack', 'memory: size of stack memory structures', 'KiB', 'memstats', 'expvar.memstats.stack', 'line'], 'lines': [ ['memstats_stack_inuse', 'inuse', 'absolute', 1, 1024] ] }, 'memstats_mspan': { - 'options': ['mspan', 'memory: size of mspan memory structures', 'kB', 'memstats', + 'options': ['mspan', 'memory: size of mspan memory structures', 'KiB', 'memstats', 'expvar.memstats.mspan', 'line'], 'lines': [ ['memstats_mspan_inuse', 'inuse', 'absolute', 1, 1024] ] }, 'memstats_mcache': { - 'options': ['mcache', 'memory: size of mcache memory structures', 'kB', 'memstats', + 'options': ['mcache', 'memory: size of mcache memory structures', 'KiB', 'memstats', 'expvar.memstats.mcache', 'line'], 'lines': [ ['memstats_mcache_inuse', 'inuse', 'absolute', 1, 1024] @@ -52,7 +59,7 @@ MEMSTATS_CHARTS = { ] }, 'memstats_sys': { - 'options': ['sys', 'memory: size of reserved virtual address space', 'kB', 'memstats', + 'options': ['sys', 'memory: size of reserved virtual address space', 'KiB', 'memstats', 'expvar.memstats.sys', 'line'], 'lines': [ ['memstats_sys', 'sys', 'absolute', 1, 1024] @@ -67,8 +74,14 @@ MEMSTATS_CHARTS = { } } -MEMSTATS_ORDER = ['memstats_heap', 'memstats_stack', 'memstats_mspan', 'memstats_mcache', - 'memstats_sys', 'memstats_live_objects', 'memstats_gc_pauses'] +EXPVAR = namedtuple( + "EXPVAR", + [ + "key", + "type", + "id", + ] +) def flatten(d, top='', sep='.'): @@ -85,7 +98,6 @@ def flatten(d, top='', sep='.'): class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) - # if memstats collection is enabled, add the charts and their order if self.configuration.get('collect_memstats'): self.definitions = dict(MEMSTATS_CHARTS) @@ -118,7 +130,7 @@ class Service(UrlService): def _parse_extra_charts_config(self, extra_charts_config): # a place to store the expvar keys and their types - self.expvars = dict() + self.expvars = list() for chart in extra_charts_config: @@ -156,11 +168,8 @@ class Service(UrlService): self.info('Unsupported expvar_type "{0}". Must be "int" or "float"'.format(ev_type)) continue - if ev_key in self.expvars: - self.info('Duplicate expvar key {0}: skipping line.'.format(ev_key)) - continue - - self.expvars[ev_key] = (ev_type, line_id) + # self.expvars[ev_key] = (ev_type, line_id) + self.expvars.append(EXPVAR(ev_key, ev_type, line_id)) chart_dict['lines'].append( [ @@ -197,21 +206,21 @@ class Service(UrlService): # the rest of the data, thus avoiding needless iterating over the multiply nested memstats dict. del (data['memstats']) flattened = flatten(data) - for k, v in flattened.items(): - ev = self.expvars.get(k) - if not ev: - # expvar is not defined in config, skip it + + for ev in self.expvars: + v = flattened.get(ev.key) + + if v is None: continue + try: - key_type, line_id = ev - if key_type == 'int': - expvars[line_id] = int(v) - elif key_type == 'float': - # if the value type is float, multiply it by 1000 and set line divisor to 1000 - expvars[line_id] = float(v) * 100 + if ev.type == 'int': + expvars[ev.id] = int(v) + elif ev.type == 'float': + expvars[ev.id] = float(v) * 100 except ValueError: - self.info('Failed to parse value for key {0} as {1}, ignoring key.'.format(k, key_type)) - del self.expvars[k] + self.info('Failed to parse value for key {0} as {1}, ignoring key.'.format(ev.key, ev.type)) + return None return expvars diff --git a/collectors/python.d.plugin/go_expvar/go_expvar.conf b/collectors/python.d.plugin/go_expvar/go_expvar.conf index af89158aa..4b821cde9 100644 --- a/collectors/python.d.plugin/go_expvar/go_expvar.conf +++ b/collectors/python.d.plugin/go_expvar/go_expvar.conf @@ -27,11 +27,9 @@ # If unset, the default for python.d.plugin is used. # priority: 60000 -# retries sets the number of retries to be made in case of failures. -# If unset, the default for python.d.plugin is used. -# Attempts to restore the service are made once every update_every -# and only if the module has collected values in the past. -# retries: 60 +# penalty indicates whether to apply penalty to update_every in case of failures. +# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes. +# penalty: yes # autodetection_retry sets the job re-check interval in seconds. # The job is not deleted if check fails. @@ -53,7 +51,7 @@ # # JOBs sharing a name are mutually exclusive # update_every: 1 # the JOB's data collection frequency # priority: 60000 # the JOB's order on the dashboard -# retries: 60 # the JOB's number of restoration attempts +# penalty: yes # the JOB's penalty # autodetection_retry: 0 # the JOB's re-check interval in seconds # # Additionally to the above, this plugin also supports the following: -- cgit v1.2.3