1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

Renamed plugins to their actual names

This commit is contained in:
Alisson Patricio 2012-07-17 19:30:54 -03:00
parent 3ec624e844
commit b7d577cea8
2 changed files with 77 additions and 77 deletions

View file

@ -1,8 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
"""=cut """=cut
=head1 NAME =head1 NAME
celery_tasks_states - Munin plugin to monitor the number of Celery tasks in each state. celery_tasks - Munin plugin to monitor the number of Celery tasks with specified names.
=head1 REQUIREMENTS =head1 REQUIREMENTS
@ -16,20 +17,16 @@ Note: don't forget to enable sending of the events on the celery daemon - run it
Default configuration: Default configuration:
[celery_tasks_states] None
env.api_url http://localhost:8989
env.workers all
If workers variable is not set or set to "all", task number for all the workers is monitored. You must set the name of at least one task you want to monitor (multiple names are separated by a comma).
You can optionally set the workers variable to the string of hostnames you want to monitor separated by a comma.
For example: For example:
[celery_tasks] [celery_tasks]
env.workers localhost,foo.bar.net,bar.foo.net env.tasks myapp.tasks.SendEmailTask,myapp2.tasks.FetchUserDataTask
This would only monitor the number of tasks for the workers with the hostnames "localhost", "foo.bar.net" and "bar.foo.net" This would monitor the number of task for a task with name "myapp.tasks.SendEmailTask" and "myapp2.tasks.FetchUserDataTask".
=head1 MAGIC MARKERS =head1 MAGIC MARKERS
@ -91,62 +88,46 @@ def check_web_server_status(api_url):
print 'Could not connect to the celerymon webserver' print 'Could not connect to the celerymon webserver'
sys.exit(-1) sys.exit(-1)
def clean_state_name(state_name): def clean_task_name(task_name):
return state_name.lower() return task_name.replace('.', '_')
# Config # Config
def print_config(workers = None): def print_config(task_names):
if workers: print 'graph_title Celery tasks'
print 'graph_title Celery tasks in each state [workers = %s]' % (', ' . join(workers))
else:
print 'graph_title Celery tasks in each state'
print 'graph_args --lower-limit 0' print 'graph_args --lower-limit 0'
print 'graph_scale no' print 'graph_scale no'
print 'graph_vlabel tasks per ${graph_period}' print 'graph_vlabel tasks per ${graph_period}'
print 'graph_category celery' print 'graph_category celery'
for name in TASK_STATES: for name in task_names:
name = clean_state_name(name) print '%s.label %s' % (clean_task_name(name), name)
print '%s.label %s' % (name, name) print '%s.type DERIVE' % (clean_task_name(name))
print '%s.type DERIVE' % (name) print '%s.min 0' % (clean_task_name(name))
print '%s.min 0' % (name) print '%s.info number of %s tasks' % (clean_task_name(name), name)
print '%s.info number of %s tasks' % (name, name)
# Values # Values
def print_values(workers = None, api_url = None): def print_values(task_names = None, api_url = None):
data = get_data('tasks', api_url) for task_name in task_names:
count = len(get_data('task_details', api_url, task_name))
counters = dict([(key, 0) for key in TASK_STATES]) print '%s.value %d' % (clean_task_name(task_name), count)
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)
value = counters[name]
print '%s.value %d' % (name_cleaned, value)
if __name__ == '__main__': if __name__ == '__main__':
workers = os.environ.get('workers', 'all') task_names = os.environ.get('tasks', None)
api_url = os.environ.get('api_url', API_URL) api_url = os.environ.get('api_url', API_URL)
check_web_server_status(api_url) check_web_server_status(api_url)
if workers in [None, '', 'all']: if not task_names:
workers = None print 'You need to define at least one task name'
else: sys.exit(-1)
workers = workers.split(',')
task_names = task_names.split(',')
if len(sys.argv) > 1: if len(sys.argv) > 1:
if sys.argv[1] == 'config': if sys.argv[1] == 'config':
print_config(workers) print_config(task_names)
elif sys.argv[1] == 'autoconf': elif sys.argv[1] == 'autoconf':
print 'yes' print 'yes'
else: else:
print_values(workers, api_url) print_values(task_names, api_url)

View file

@ -1,9 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
"""=cut """=cut
=head1 NAME =head1 NAME
celery_tasks - Munin plugin to monitor the number of Celery tasks with specified names. celery_tasks_states - Munin plugin to monitor the number of Celery tasks in each state.
=head1 REQUIREMENTS =head1 REQUIREMENTS
@ -17,16 +16,20 @@ Note: don't forget to enable sending of the events on the celery daemon - run it
Default configuration: Default configuration:
None [celery_tasks_states]
env.api_url http://localhost:8989
env.workers all
You must set the name of at least one task you want to monitor (multiple names are separated by a comma). If workers variable is not set or set to "all", task number for all the workers is monitored.
You can optionally set the workers variable to the string of hostnames you want to monitor separated by a comma.
For example: For example:
[celery_tasks] [celery_tasks]
env.tasks myapp.tasks.SendEmailTask,myapp2.tasks.FetchUserDataTask env.workers localhost,foo.bar.net,bar.foo.net
This would monitor the number of task for a task with name "myapp.tasks.SendEmailTask" and "myapp2.tasks.FetchUserDataTask". This would only monitor the number of tasks for the workers with the hostnames "localhost", "foo.bar.net" and "bar.foo.net"
=head1 MAGIC MARKERS =head1 MAGIC MARKERS
@ -88,46 +91,62 @@ def check_web_server_status(api_url):
print 'Could not connect to the celerymon webserver' print 'Could not connect to the celerymon webserver'
sys.exit(-1) sys.exit(-1)
def clean_task_name(task_name): def clean_state_name(state_name):
return task_name.replace('.', '_') return state_name.lower()
# Config # Config
def print_config(task_names): def print_config(workers = None):
print 'graph_title Celery tasks' if workers:
print 'graph_title Celery tasks in each state [workers = %s]' % (', ' . join(workers))
else:
print 'graph_title Celery tasks in each state'
print 'graph_args --lower-limit 0' print 'graph_args --lower-limit 0'
print 'graph_scale no' print 'graph_scale no'
print 'graph_vlabel tasks per ${graph_period}' print 'graph_vlabel tasks per ${graph_period}'
print 'graph_category celery' print 'graph_category celery'
for name in task_names: for name in TASK_STATES:
print '%s.label %s' % (clean_task_name(name), name) name = clean_state_name(name)
print '%s.type DERIVE' % (clean_task_name(name)) print '%s.label %s' % (name, name)
print '%s.min 0' % (clean_task_name(name)) print '%s.type DERIVE' % (name)
print '%s.info number of %s tasks' % (clean_task_name(name), name) print '%s.min 0' % (name)
print '%s.info number of %s tasks' % (name, name)
# Values # Values
def print_values(task_names = None, api_url = None): def print_values(workers = None, api_url = None):
for task_name in task_names: data = get_data('tasks', api_url)
count = len(get_data('task_details', api_url, task_name))
print '%s.value %d' % (clean_task_name(task_name), count) counters = dict([(key, 0) for key in TASK_STATES])
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)
value = counters[name]
print '%s.value %d' % (name_cleaned, value)
if __name__ == '__main__': if __name__ == '__main__':
task_names = os.environ.get('tasks', None) workers = os.environ.get('workers', 'all')
api_url = os.environ.get('api_url', API_URL) api_url = os.environ.get('api_url', API_URL)
check_web_server_status(api_url) check_web_server_status(api_url)
if not task_names: if workers in [None, '', 'all']:
print 'You need to define at least one task name' workers = None
sys.exit(-1) else:
workers = workers.split(',')
task_names = task_names.split(',')
if len(sys.argv) > 1: if len(sys.argv) > 1:
if sys.argv[1] == 'config': if sys.argv[1] == 'config':
print_config(task_names) print_config(workers)
elif sys.argv[1] == 'autoconf': elif sys.argv[1] == 'autoconf':
print 'yes' print 'yes'
else: else:
print_values(task_names, api_url) print_values(workers, api_url)