Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New plugins proposed #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'andrii'
Empty file.
72 changes: 72 additions & 0 deletions plugins/elasticsearch/es_gc_count
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <[email protected]> #
##############################################

import json
import urllib3

from munin import MuninPlugin


class ESGarbageCollectionCountPlugin(MuninPlugin):
category = 'Elasticsearch'
args = '--base 1000 --lower-limit 0'
vlabel = 'Number of garbage collections'
info = 'Show garbage collection counts'

@property
def title(self):
return 'Elasticsearch Garbage Collection count'

@property
def fields(self):
fields = [
('total', dict(
label='total',
type='GAUGE',
)),
('young', dict(
label='young generation',
type='GAUGE',
)),
('old', dict(
label='old generation',
type='GAUGE',
))
]
return fields

def __init__(self):
super(ESGarbageCollectionCountPlugin, self).__init__()
self.es_host = 'http://localhost:9200'
self.http = urllib3.PoolManager()

def execute(self):
return self._get_gc_stats()

def _get_gc_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('gc', {})
return {
'total': stats.get('collection_count'),
'new': stats.get('collectors', {}).get(
'ParNew', {}).get('collection_count'),
'old': stats.get('collectors', {}).get(
'ConcurrentMarkSweep', {}).get('collection_count'),
}

if __name__ == '__main__':
ESGarbageCollectionCountPlugin().run()
72 changes: 72 additions & 0 deletions plugins/elasticsearch/es_gc_time
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <[email protected]> #
##############################################

import json
import urllib3

from munin import MuninPlugin


class ESGarbageCollectionTimePlugin(MuninPlugin):
category = 'Elasticsearch'
args = '--base 1000 --lower-limit 0'
vlabel = 'GC time / milliseconds'
info = 'Show garbage collection time'

@property
def title(self):
return 'Elasticsearch Garbage Collection time'

@property
def fields(self):
fields = [
('total', dict(
label='total',
type='GAUGE',
)),
('young', dict(
label='young generation',
type='GAUGE',
)),
('old', dict(
label='old generation',
type='GAUGE',
))
]
return fields

def __init__(self):
super(ESGarbageCollectionTimePlugin, self).__init__()
self.es_host = 'http://localhost:9200'
self.http = urllib3.PoolManager()

def execute(self):
return self._get_gc_stats()

def _get_gc_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('gc', {})
return {
'total': stats.get('collection_time_in_millis'),
'young': stats.get('collectors', {}).get(
'ParNew', {}).get('collection_time_in_millis'),
'old': stats.get('collectors', {}).get(
'ConcurrentMarkSweep', {}).get('collection_time_in_millis'),
}

if __name__ == '__main__':
ESGarbageCollectionTimePlugin().run()
60 changes: 60 additions & 0 deletions plugins/elasticsearch/es_http_connections
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <[email protected]> #
##############################################

import json
import urllib3

from munin import MuninPlugin


class ESHttpOpenConnectionsCountPlugin(MuninPlugin):
category = 'Elasticsearch'
args = '--base 1000 --lower-limit 0'
vlabel = 'Number of HTTP open connections'
info = 'Show HTTP open connections count'

@property
def title(self):
return 'Elasticsearch HTTP open connections count'

@property
def fields(self):
fields = [
('total', dict(
label='total',
type='GAUGE',
))
]
return fields

def __init__(self):
super(ESHttpOpenConnectionsCountPlugin, self).__init__()
self.es_host = 'http://localhost:9200'
self.http = urllib3.PoolManager()

def execute(self):
return self._get_http_stats()

def _get_http_stats(self):
url = '{}/_nodes/_local/http/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('http', {})
return {
'total': stats.get('current_open'),
}

if __name__ == '__main__':
ESHttpOpenConnectionsCountPlugin().run()
65 changes: 65 additions & 0 deletions plugins/elasticsearch/es_jvm_pools
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <[email protected]> #
##############################################

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()
60 changes: 60 additions & 0 deletions plugins/elasticsearch/es_open_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

##############################################
# Munin plugin for Elasticsearch monitoring #
# by Andrii Gakhov <[email protected]> #
##############################################

import json
import urllib3

from munin import MuninPlugin


class ESOpenFilesCountPlugin(MuninPlugin):
category = 'Elasticsearch'
args = '--base 1000 --lower-limit 0'
vlabel = 'Number of open file descriptors'
info = 'Show open file descriptors'

@property
def title(self):
return 'Elasticsearch open files count'

@property
def fields(self):
fields = [
('total', dict(
label='total',
type='GAUGE',
))
]
return fields

def __init__(self):
super(ESOpenFilesCountPlugin, self).__init__()
self.es_host = 'http://localhost:9200'
self.http = urllib3.PoolManager()

def execute(self):
return self._get_files_stats()

def _get_files_stats(self):
url = '{}/_nodes/_local/process/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('process', {})
return {
'total': stats.get('open_file_descriptors'),
}

if __name__ == '__main__':
ESOpenFilesCountPlugin().run()
Loading