-
Notifications
You must be signed in to change notification settings - Fork 12
/
prometheusjmeter.py
43 lines (34 loc) · 1.17 KB
/
prometheusjmeter.py
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
"""
*******************
*Copyright 2017, MapleLabs, All Rights Reserved.
*
********************
"""
""" A collectd-python plugin for retrieving
metrics from prometheus Jmeter status module. """
import signal
import collectd
import prometheus_poller
from constants import *
class PrometheusJmeter(prometheus_poller.PrometheusStat):
def __init__(self):
self.interval = DEFAULT_INTERVAL
self.port = None
self.conf = {}
def config(self, cfg):
for children in cfg.children:
if children.key == INTERVAL:
self.interval = children.values[0]
if children.key == PORT:
self.port = children.values[0]
self.conf.update({'interval': self.interval, 'port': self.port, 'name': 'prometheusjmeter'})
super(PrometheusJmeter, self).__init__(self.conf)
def read_temp(self):
collectd.unregister_read(self.read_temp)
collectd.register_read(self.read, interval=int(self.interval))
def init():
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
OBJ = PrometheusJmeter()
collectd.register_init(init)
collectd.register_config(OBJ.config)
collectd.register_read(OBJ.read_temp)