1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Update task's states to work with Celery 3.0

This commit is contained in:
Alisson Patricio 2012-07-17 13:19:22 -03:00
parent fd2a8b3bb1
commit 3ec624e844
2 changed files with 23 additions and 23 deletions

View file

@ -64,11 +64,13 @@ URL_ENDPOINTS = {
'task_details': '/api/task/name/%s',
}
TASK_STATES = (
'task-accepted',
'task-received',
'task-succeeded',
'task-failed',
'task-retried',
'PENDING',
'RECEIVED',
'STARTED',
'SUCCESS',
'FAILURE',
'REVOKED',
'RETRY'
)
def get_data(what, api_url, *args):
@ -90,7 +92,7 @@ def check_web_server_status(api_url):
sys.exit(-1)
def clean_state_name(state_name):
return state_name.replace('task-', '')
return state_name.lower()
# Config
def print_config(workers = None):
@ -115,18 +117,14 @@ def print_values(workers = None, api_url = None):
data = get_data('tasks', api_url)
counters = dict([(key, 0) for key in TASK_STATES])
for task_name, task_data in data.iteritems():
for entry in task_data:
if not entry.get('state', None):
continue
state = entry.get('state', None)
hostname = entry.get('hostname', None)
if workers and hostname not in workers:
continue
counters[state] += 1
for task_name, task_data in data:
state = task_data['state']
hostname = task_data['worker']['hostname']
if workers and hostname not in workers:
continue
counters[state] += 1
for name in TASK_STATES:
name_cleaned = clean_state_name(name)

View file

@ -61,11 +61,13 @@ URL_ENDPOINTS = {
'task_details': '/api/task/name/%s',
}
TASK_STATES = (
'task-accepted',
'task-received',
'task-succeeded',
'task-failed',
'task-retried',
'PENDING',
'RECEIVED',
'STARTED',
'SUCCESS',
'FAILURE',
'REVOKED',
'RETRY'
)
def get_data(what, api_url, *args):