Skip to content

Commit

Permalink
Add metrics for individual tubes
Browse files Browse the repository at this point in the history
  • Loading branch information
sholiday authored and Ganglia Development Team committed Dec 11, 2010
1 parent 965d728 commit adb1560
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 43 deletions.
12 changes: 11 additions & 1 deletion beanstalk/README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ This module connects to a [beanstalkd](http://kr.github.com/beanstalkd/) instanc
* current-waiting
* job-timeouts
* cmd-bury

In addition is grabs the following metrics about individual tubes:

* total-jobs
* current-watching
* current-jobs-buried
* current-jobs-ready
* current-waiting

It should be fairly easy to add a custom metric

## AUTHOR

Stephen Holiday <stephen.holiday@gmail.com>
[Stephen Holiday](http://stephenholiday.com) <stephen.holiday@gmail.com>
104 changes: 64 additions & 40 deletions beanstalk/conf.d/beanstalk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,72 @@ modules {
}
}
collection_group {
collect_every = 20
time_threshold = 90
metric {
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 = "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
}
metric {
name = "default_total-jobs"
title = "default Number of Beanstalkd Jobs"
value_threshold = 0
}
metric {
name = "default_current-watching"
title = "default Current Watchers"
value_threshold = 0
}
metric {
name = "default_current-jobs-buried"
title = "default Current Number of Jobs Burried"
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
}
metric {
name = "default_current-jobs-ready"
title = "default Current Jobs Ready"
value_threshold = 0
}
metric {
name = "default_current-waiting"
title = "default Current Number of Jobs Waiting"
value_threshold = 0
}
}
65 changes: 63 additions & 2 deletions beanstalk/python_modules/beanstalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
# -*- coding: utf-8 -*-
import beanstalkc

HOST='localhost'
PORT=14711
def stat_handler(name):
bean=beanstalkc.Connection(host='localhost',port=14711)
bean=beanstalkc.Connection(host=HOST,port=PORT)
return bean.stats()[name]

def tube_stat_handler(name):
bean=beanstalkc.Connection(host=HOST,port=PORT)
return bean.stats_tube(name.split('_')[0])[name.split('_')[1]]

def metric_init(params):
global descriptors

Expand Down Expand Up @@ -82,7 +88,62 @@ def metric_init(params):
'description': 'Number of Beanstalkd Burries',
'groups': 'beanstalkd'}
]


#now get all the tubes
bean=beanstalkc.Connection(host=HOST,port=PORT)
tubes=bean.tubes()
for tube in tubes:
descriptors.append(
{'name': tube+'_total-jobs',
'call_back': tube_stat_handler,
'time_max': 90,
'value_type': 'uint',
'units': 'total jobs',
'slope': 'both',
'format': '%u',
'description': 'Number of Beanstalkd Jobs ('+tube+')',
'groups': 'beanstalkd'})
descriptors.append(
{'name': tube+'_current-watching',
'call_back': tube_stat_handler,
'time_max': 90,
'value_type': 'uint',
'units': 'clients',
'slope': 'both',
'format': '%u',
'description': 'Number Watchers ('+tube+')',
'groups': 'beanstalkd'})
descriptors.append(
{'name': tube+'_current-jobs-buried',
'call_back': tube_stat_handler,
'time_max': 90,
'value_type': 'uint',
'units': 'jobs',
'slope': 'both',
'format': '%u',
'description': 'Current Number of Jobs Burried ('+tube+')',
'groups': 'beanstalkd'})
descriptors.append(
{'name': tube+'_current-jobs-ready',
'call_back': tube_stat_handler,
'time_max': 90,
'value_type': 'uint',
'units': 'clients',
'slope': 'both',
'format': '%u',
'description': 'Current Jobs Ready ('+tube+')',
'groups': 'beanstalkd'})
descriptors.append(
{'name': tube+'_current-waiting',
'call_back': tube_stat_handler,
'time_max': 90,
'value_type': 'uint',
'units': 'jobs',
'slope': 'both',
'format': '%u',
'description': 'Current Number of Jobs Waiting ('+tube+')',
'groups': 'beanstalkd'})

return descriptors

def metric_cleanup():
Expand Down

0 comments on commit adb1560

Please sign in to comment.