diff --git a/beanstalk/README.mkdn b/beanstalk/README.mkdn new file mode 100644 index 00000000..88fb766d --- /dev/null +++ b/beanstalk/README.mkdn @@ -0,0 +1,21 @@ +beanstalk +=============== + +python module for ganglia 3.1. + +*NOTE*: [beanstalkc](https://github.com/earl/beanstalkc/) *must* be in your python path. + +This module connects to a [beanstalkd](http://kr.github.com/beanstalkd/) instance and grabs some metrics: + + * current-connections + * total-jobs + * current-jobs-ready + * current-jobs-buried + * current-jobs-delayed + * current-waiting + * job-timeouts + * cmd-bury + +## AUTHOR + +Stephen Holiday \ No newline at end of file diff --git a/beanstalk/conf.d/beanstalk.conf b/beanstalk/conf.d/beanstalk.conf new file mode 100644 index 00000000..67e57306 --- /dev/null +++ b/beanstalk/conf.d/beanstalk.conf @@ -0,0 +1,52 @@ +modules { + module { + name = "beanstalk" + language = "python" + } +} +collection_group { + collect_every = 20 + time_threshold = 90 + metric { + name = "current-connections" + title = "Number of Current Connections to Beanstalkd" + value_threshold = 0 + } + metric { + name = "total-jobs" + title = "Number of Beanstalkd Jobs" + value_threshold = 0 + } + metric { + name = "current-jobs-ready" + title = "Number of Beanstalkd Jobs 'ready'" + value_threshold = 0 + } + metric { + name = "current-jobs-buried" + title = "Number of Beanstalkd Jobs 'buried'" + value_threshold = 0 + } + + metric { + name = "current-jobs-delayed" + title = "Number of Beanstalkd Jobs 'delayed'" + value_threshold = 0 + } + metric { + name = "current-waiting" + title = "Number of Beanstalkd Jobs 'waiting'" + value_threshold = 0 + } + + metric { + name = "job-timeouts" + title = "Number of Beanstalkd Jobs Timeouts" + value_threshold = 0 + } + metric { + name = "cmd-bury" + title = "Number of Beanstalkd Burries" + value_threshold = 0 + } +} diff --git a/beanstalk/python_modules/beanstalk.py b/beanstalk/python_modules/beanstalk.py new file mode 100644 index 00000000..3e5aec21 --- /dev/null +++ b/beanstalk/python_modules/beanstalk.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import beanstalkc + +def stat_handler(name): + bean=beanstalkc.Connection(host='localhost',port=14711) + return bean.stats()[name] + +def metric_init(params): + global descriptors + + descriptors = [{'name': 'current-connections', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'connections', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Current Connections to Beanstalkd', + 'groups': 'beanstalkd'}, + {'name': 'total-jobs', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'total jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs', + 'groups': 'beanstalkd'}, + {'name': 'current-jobs-ready', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs \'ready\'', + 'groups': 'beanstalkd'}, + {'name': 'current-jobs-buried', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs \'buried\'', + 'groups': 'beanstalkd'}, + {'name': 'current-jobs-delayed', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs \'delayed\'', + 'groups': 'beanstalkd'}, + {'name': 'current-waiting', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs \'waiting\'', + 'groups': 'beanstalkd'}, + {'name': 'job-timeouts', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Jobs Timeouts', + 'groups': 'beanstalkd'}, + {'name': 'cmd-bury', + 'call_back': stat_handler, + 'time_max': 90, + 'value_type': 'uint', + 'units': 'jobs', + 'slope': 'both', + 'format': '%u', + 'description': 'Number of Beanstalkd Burries', + 'groups': 'beanstalkd'} + ] + + return descriptors + +def metric_cleanup(): + '''Clean up the metric module.''' + pass + +#This code is for debugging and unit testing +if __name__ == '__main__': + metric_init(None) + for d in descriptors: + v = d['call_back'](d['name']) + print 'value for %s is %u' % (d['name'], v)