summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/beanstalk/beanstalk.chart.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--collectors/python.d.plugin/beanstalk/beanstalk.chart.py (renamed from python.d/beanstalk.chart.py)43
1 files changed, 20 insertions, 23 deletions
diff --git a/python.d/beanstalk.chart.py b/collectors/python.d.plugin/beanstalk/beanstalk.chart.py
index 8880afdd9..1472b4e1a 100644
--- a/python.d/beanstalk.chart.py
+++ b/collectors/python.d.plugin/beanstalk/beanstalk.chart.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Description: beanstalk netdata python.d module
# Author: l2isbad
+# SPDX-License-Identifier: GPL-3.0-or-later
try:
import beanstalkc
@@ -8,13 +9,8 @@ try:
except ImportError:
BEANSTALKC = False
-try:
- import yaml
- YAML = True
-except ImportError:
- YAML = False
-
from bases.FrameworkServices.SimpleService import SimpleService
+from bases.loaders import safe_load
# default module values (can be overridden per job in `config`)
# update_every = 2
@@ -114,12 +110,13 @@ CHARTS = {
def tube_chart_template(name):
- order = ['{0}_jobs_rate'.format(name),
- '{0}_jobs'.format(name),
- '{0}_connections'.format(name),
- '{0}_commands'.format(name),
- '{0}_pause'.format(name)
- ]
+ order = [
+ '{0}_jobs_rate'.format(name),
+ '{0}_jobs'.format(name),
+ '{0}_connections'.format(name),
+ '{0}_commands'.format(name),
+ '{0}_pause'.format(name)
+ ]
family = 'tube {0}'.format(name)
charts = {
@@ -127,7 +124,8 @@ def tube_chart_template(name):
'options': [None, 'Job Rate', 'jobs/s', family, 'beanstalk.jobs_rate', 'area'],
'lines': [
['_'.join([name, 'total-jobs']), 'jobs', 'incremental']
- ]},
+ ]
+ },
order[1]: {
'options': [None, 'Jobs', 'jobs', family, 'beanstalk.jobs', 'stacked'],
'lines': [
@@ -136,27 +134,30 @@ def tube_chart_template(name):
['_'.join([name, 'current-jobs-reserved']), 'reserved'],
['_'.join([name, 'current-jobs-delayed']), 'delayed'],
['_'.join([name, 'current-jobs-buried']), 'buried']
- ]},
+ ]
+ },
order[2]: {
'options': [None, 'Connections', 'connections', family, 'beanstalk.connections', 'stacked'],
'lines': [
['_'.join([name, 'current-using']), 'using'],
['_'.join([name, 'current-waiting']), 'waiting'],
['_'.join([name, 'current-watching']), 'watching']
- ]},
+ ]
+ },
order[3]: {
'options': [None, 'Commands', 'commands/s', family, 'beanstalk.commands', 'stacked'],
'lines': [
['_'.join([name, 'cmd-delete']), 'deletes', 'incremental'],
['_'.join([name, 'cmd-pause-tube']), 'pauses', 'incremental']
- ]},
+ ]
+ },
order[4]: {
'options': [None, 'Pause', 'seconds', family, 'beanstalk.pause', 'stacked'],
'lines': [
['_'.join([name, 'pause']), 'since'],
['_'.join([name, 'pause-time-left']), 'left']
- ]}
-
+ ]
+ }
}
return order, charts
@@ -176,10 +177,6 @@ class Service(SimpleService):
self.error("'beanstalkc' module is needed to use beanstalk.chart.py")
return False
- if not YAML:
- self.error("'yaml' module is needed to use beanstalk.chart.py")
- return False
-
self.conn = self.connect()
return True if self.conn else False
@@ -231,7 +228,7 @@ class Service(SimpleService):
return beanstalkc.Connection(host=host,
port=port,
connect_timeout=timeout,
- parse_yaml=yaml.load)
+ parse_yaml=safe_load)
except beanstalkc.SocketError as error:
self.error('Connection to {0}:{1} failed: {2}'.format(host, port, error))
return None