Skip to content

Commit

Permalink
Adding beanstalk plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sholiday authored and Ganglia Development Team committed Dec 4, 2010
1 parent 19083de commit e3cf911
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 0 deletions.
21 changes: 21 additions & 0 deletions beanstalk/README.mkdn
Original file line number Diff line number Diff line change
@@ -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 <stephen.holiday@gmail.com>
52 changes: 52 additions & 0 deletions beanstalk/conf.d/beanstalk.conf
Original file line number Diff line number Diff line change
@@ -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
}
}
97 changes: 97 additions & 0 deletions beanstalk/python_modules/beanstalk.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit e3cf911

Please sign in to comment.