Skip to content

Commit

Permalink
Make the Celery module work with Flower.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayamindu Dasgupta committed Oct 28, 2014
1 parent 06d9455 commit 841d288
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
9 changes: 4 additions & 5 deletions celery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ from http://docs.celeryproject.org.
Prerequisite
============

Make sure Celery exposes it's API over HTTP e.g.

curl http://localhost:8989/api/worker/

or similar needs to succeed for this module to work.
This version of the module works with Flower (https://github.com/mher/flower),
a web-based tool to monitor Celery workers and tasks.

Previous versions of this module worked with Celerymon, which has now been
obsoleted in favor of Flower (http://celery.readthedocs.org/en/latest/userguide/monitoring.html?highlight=flower#flower-real-time-celery-web-monitor).

Install
===============
Expand Down
3 changes: 1 addition & 2 deletions celery/conf.d/celery.pyconf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ modules {
module {
name = "ganglia_celery"
language = "python"
# Don't forget the trailing slash on the URL
param url {
value = "http://localhost:10000/api/worker/"
value = "http://localhost:10000/api/workers"
}

}
Expand Down
15 changes: 11 additions & 4 deletions celery/python_modules/ganglia_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_metrics():
res = urllib2.urlopen(req, None, 1)
stats = res.read()
metrics2 = json.loads(stats)
metrics = metrics2[0]
metrics = metrics2['celery@{}'.format(socket.gethostname())]
metrics['status'] = "up"

except StandardError, e:
Expand Down Expand Up @@ -148,19 +148,26 @@ def metric_init(params):
SERVER_STATUS_URL = params["url"]

descriptors.append(create_desc(Desc_Skel, {
"name" : params["metrics_prefix"] + "_active",
"name" : params["metrics_prefix"] + "_running_tasks",
"units" : "jobs",
"description": "Number of active jobs",
"call_back" : get_value
}))

descriptors.append(create_desc(Desc_Skel, {
"name" : params["metrics_prefix"] + "_processed",
"name" : params["metrics_prefix"] + "_completed_tasks",
"units" : "jobs/s",
"description": "Number of processed jobs",
"call_back" : get_delta
}))

descriptors.append(create_desc(Desc_Skel, {
"name" : params["metrics_prefix"] + "_concurrency",
"units" : "processes/s",
"description": "Number of worker processes",
"call_back" : get_value
}))

descriptors.append(create_desc(Desc_Skel, {
"name" : params["metrics_prefix"] + "_status",
"units" : "",
Expand All @@ -183,7 +190,7 @@ def create_desc(skel, prop):
if __name__ == '__main__':
try:
params = {
"url" : "http://localhost:8989/api/worker/",
"url" : "http://localhost:10000/api/workers",
}
metric_init(params)

Expand Down

0 comments on commit 841d288

Please sign in to comment.