@cryptotaxi247 / netdata-1 / commits / 34a77f39f

fix

Wing924 committed Feb 26, 2018 at 10:01 UTC 34a77f39f3b9d42a87cfbe17fae4bc562745c7fc
2 files changed +55 -45
conf.d/python.d/springboot.conf
+11 -12
@@ -78,7 +78,6 @@
78 # Configuration example
79 # ---------------------
80 # expample:
81 -#
81 # name: 'example'
82 # url: 'http://localhost:8080/metrics'
83 # defaults:
@@ -91,26 +90,26 @@
90 # - id: 'heap'
91 # options: { title: 'Heap Memory Usage', units: 'KB', family: 'heap memory', context: 'springboot.heap', charttype: 'stacked' }
92 # lines:
94 -# - { dimension: 'mem.free', name: 'free'}
95 -# - { dimension: 'mempool.eden.used', name: 'eden', algorithm: 'absolute', multiplier: 1, divisor: 1}
96 -# - { dimension: 'mempool.survivor.used', name: 'survivor', algorithm: 'absolute', multiplier: 1, divisor: 1}
97 -# - { dimension: 'mempool.tenured.used', name: 'tenured', algorithm: 'absolute', multiplier: 1, divisor: 1}
93 +# - { dimension: 'mem_free', name: 'free'}
94 +# - { dimension: 'mempool_eden_used', name: 'eden', algorithm: 'absolute', multiplier: 1, divisor: 1}
95 +# - { dimension: 'mempool_survivor_used', name: 'survivor', algorithm: 'absolute', multiplier: 1, divisor: 1}
96 +# - { dimension: 'mempool_tenured_used', name: 'tenured', algorithm: 'absolute', multiplier: 1, divisor: 1}
97 # - id: 'heap_eden'
98 # options: { title: 'Eden Memory Usage', units: 'KB', family: 'heap memory', context: 'springboot.heap_eden', charttype: 'area' }
99 # lines:
101 -# - { dimension: 'mempool.eden.used', name: 'used'}
102 -# - { dimension: 'mempool.eden.committed', name: 'commited'}
100 +# - { dimension: 'mempool_eden_used', name: 'used'}
101 +# - { dimension: 'mempool_eden_committed', name: 'commited'}
102 # - id: 'heap_survivor'
103 # options: { title: 'Survivor Memory Usage', units: 'KB', family: 'heap memory', context: 'springboot.heap_survivor', charttype: 'area' }
104 # lines:
106 -# - { dimension: 'mempool.survivor.used', name: 'used'}
107 -# - { dimension: 'mempool.survivor.committed', name: 'commited'}
105 +# - { dimension: 'mempool_survivor_used', name: 'used'}
106 +# - { dimension: 'mempool_survivor_committed', name: 'commited'}
107 # - id: 'heap_tenured'
108 # options: { title: 'Tenured Memory Usage', units: 'KB', family: 'heap memory', context: 'springboot.heap_tenured', charttype: 'area' }
109 # lines:
111 -# - { dimension: 'mempool.tenured.used', name: 'used'}
112 -# - { dimension: 'mempool.tenured.committed', name: 'commited'}
113 -#
110 +# - { dimension: 'mempool_tenured_used', name: 'used'}
111 +# - { dimension: 'mempool_tenured_committed', name: 'commited'}
112 +
113
114 local:
115 name: 'local'
python.d/springboot.chart.py
+44 -33
@@ -17,51 +17,54 @@ DEFAULT_CHARTS = {
17 'response_code': {
18 'options': [None, "Response Codes", "requests/s", "response", "springboot.response_code", "stacked"],
19 'lines': [
20 - ["resp.other", 'Other', 'incremental'],
21 - ["resp.1xx", '1xx', 'incremental'],
22 - ["resp.2xx", '2xx', 'incremental'],
23 - ["resp.3xx", '3xx', 'incremental'],
24 - ["resp.4xx", '4xx', 'incremental'],
25 - ["resp.5xx", '5xx', 'incremental'],
20 + ["resp_other", 'Other', 'incremental'],
21 + ["resp_1xx", '1xx', 'incremental'],
22 + ["resp_2xx", '2xx', 'incremental'],
23 + ["resp_3xx", '3xx', 'incremental'],
24 + ["resp_4xx", '4xx', 'incremental'],
25 + ["resp_5xx", '5xx', 'incremental'],
26 ]},
27 'threads': {
28 'options': [None, "Threads", "current threads", "threads", "springboot.threads", "area"],
29 'lines': [
30 - ["threads.daemon", 'daemon', 'absolute'],
30 + ["threads_daemon", 'daemon', 'absolute'],
31 ["threads", 'total', 'absolute'],
32 ]},
33 'gc_time': {
34 - 'options': [None, "GC Time", "milliseconds", "garbage collection", "springboot.gc_time", "area"],
34 + 'options': [None, "GC Time", "milliseconds", "garbage collection", "springboot.gc_time", "stacked"],
35 'lines': [
36 - ["gc.copy.time", 'Copy', 'incremental'],
37 - ["gc.marksweepcompact.time", 'MarkSweepCompact', 'incremental'],
38 - ["gc.parnew.time", 'ParNew', 'incremental'],
39 - ["gc.concurrentmarksweep.time", 'ConcurrentMarkSweep', 'incremental'],
40 - ["gc.ps_scavenge.time", 'PS Scavenge', 'incremental'],
41 - ["gc.ps_marksweep.time", 'PS MarkSweep', 'incremental'],
42 - ["gc.g1_young_generation.time", 'G1 Young Generation', 'incremental'],
43 - ["gc.g1_old_generation.time", 'G1 Old Generation', 'incremental'],
36 + ["gc_copy_time", 'Copy', 'incremental'],
37 + ["gc_marksweepcompact_time", 'MarkSweepCompact', 'incremental'],
38 + ["gc_parnew_time", 'ParNew', 'incremental'],
39 + ["gc_concurrentmarksweep_time", 'ConcurrentMarkSweep', 'incremental'],
40 + ["gc_ps_scavenge_time", 'PS Scavenge', 'incremental'],
41 + ["gc_ps_marksweep_time", 'PS MarkSweep', 'incremental'],
42 + ["gc_g1_young_generation_time", 'G1 Young Generation', 'incremental'],
43 + ["gc_g1_old_generation_time", 'G1 Old Generation', 'incremental'],
44 ]},
45 'gc_ope': {
46 - 'options': [None, "GC Operations", "operations/s", "garbage collection", "springboot.gc_ope", "area"],
46 + 'options': [None, "GC Operations", "operations/s", "garbage collection", "springboot.gc_ope", "stacked"],
47 'lines': [
48 - ["gc.copy.count", 'Copy', 'incremental'],
49 - ["gc.marksweepcompact.count", 'MarkSweepCompact', 'incremental'],
50 - ["gc.parnew.count", 'ParNew', 'incremental'],
51 - ["gc.concurrentmarksweep.count", 'ConcurrentMarkSweep', 'incremental'],
52 - ["gc.ps_scavenge.count", 'PS Scavenge', 'incremental'],
53 - ["gc.ps_marksweep.count", 'PS MarkSweep', 'incremental'],
54 - ["gc.g1_young_generation.count", 'G1 Young Generation', 'incremental'],
55 - ["gc.g1_old_generation.count", 'G1 Old Generation', 'incremental'],
48 + ["gc_copy_count", 'Copy', 'incremental'],
49 + ["gc_marksweepcompact_count", 'MarkSweepCompact', 'incremental'],
50 + ["gc_parnew_count", 'ParNew', 'incremental'],
51 + ["gc_concurrentmarksweep_count", 'ConcurrentMarkSweep', 'incremental'],
52 + ["gc_ps_scavenge_count", 'PS Scavenge', 'incremental'],
53 + ["gc_ps_marksweep_count", 'PS MarkSweep', 'incremental'],
54 + ["gc_g1_young_generation_count", 'G1 Young Generation', 'incremental'],
55 + ["gc_g1_old_generation_count", 'G1 Old Generation', 'incremental'],
56 ]},
57 'heap': {
58 'options': [None, "Heap Memory Usage", "KB", "heap memory", "springboot.heap", "area"],
59 'lines': [
60 - ["heap.committed", 'committed', "absolute"],
61 - ["heap.used", 'used', "absolute"],
60 + ["heap_committed", 'committed', "absolute"],
61 + ["heap_used", 'used', "absolute"],
62 ]},
63 }
64
65 +class ExtraChartError(ValueError):
66 + pass
67 +
68 class Service(UrlService):
69 def __init__(self, configuration=None, name=None):
70 UrlService.__init__(self, configuration=configuration, name=name)
@@ -74,24 +77,32 @@ class Service(UrlService):
77 :return: dict
78 """
79 data = None
80 + result = {
81 + 'resp_1xx': 0,
82 + 'resp_2xx': 0,
83 + 'resp_3xx': 0,
84 + 'resp_4xx': 0,
85 + 'resp_5xx': 0,
86 + 'resp_other': 0,
87 + }
88 raw_data = self._get_raw_data()
89 if raw_data:
90 try:
91 data = json.loads(raw_data)
81 - except Excepton:
92 + except ValueError:
93 self.debug('%s is not a vaild JSON page' % self.url)
94 return None
95
85 - for key in ['1xx', '2xx', '3xx', '4xx', '5xx', 'other']:
86 - data['resp.' + key] = 0
96 for key, value in data.iteritems():
97 if 'counter.status.' in key:
98 status_type = key[15:16] + 'xx'
99 if status_type[0] not in '12345':
100 status_type = 'other'
92 - data['resp.' + status_type] += value
101 + result['resp_' + status_type] += value
102 + else:
103 + result[key.replace('.', '_')] = value
104
94 - return data or None
105 + return result or None
106
107 def _setup_charts(self):
108 self.order = []
@@ -135,4 +146,4 @@ class Service(UrlService):
146
147 @classmethod
148 def die(error_message):
138 - raise Exception(error_message)
149 + raise ExtraChartError(error_message)