-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathes_jvm_pools
More file actions
executable file
·65 lines (51 loc) · 1.73 KB
/
es_jvm_pools
File metadata and controls
executable file
·65 lines (51 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <andrii.gakhov@gmail.com> #
##############################################
import json
import urllib3
from munin import MuninPlugin
class ESJvmMemPoolSizePlugin(MuninPlugin):
category = 'Elasticsearch'
args = '--base 1000 --lower-limit 0'
vlabel = 'JVM memory pools size / bytes'
info = 'Show JVM memory pools size'
@property
def title(self):
return 'Elasticsearch JVM Memory Pools size'
@property
def fields(self):
fields = [
('young', dict(
label='young generation',
type='GAUGE',
)),
('old', dict(
label='old generation',
type='GAUGE',
))
]
return fields
def __init__(self):
super(ESJvmMemPoolSizePlugin, self).__init__()
self.es_host = 'http://localhost:9200'
self.http = urllib3.PoolManager()
def execute(self):
return self._get_cache_stats()
def _get_cache_stats(self):
url = '{}/_nodes/_local/jvm/stats'.format(self.es_host)
response = self.http.request('GET', url)
if response.status != 200:
return None
data = json.loads(response.data)
if not data.get('nodes', {}).values():
return None
stats = data['nodes'].values()[0].get('jvm', {}).get('mem', {}).get('pools', {})
return {
'young': stats.get('Par Eden Space', {}).get('used_in_bytes'),
'old': stats.get('CMS Old Gen', {}).get('used_in_bytes')
}
if __name__ == '__main__':
ESJvmMemPoolSizePlugin().run()