Commit a035ee2d by nadeemshahzad

Added cron for rabbitmq mem usage

parent 77d54170
......@@ -52,11 +52,24 @@
group: "{{ rabbitmq_group }}"
mode: "0755"
- name: Set up a cron job to run the script
- name: Add RabbitMQ memory usage script
template:
src: "edx/app/rabbitmq/log-rabbitmq-memory.py.j2"
dest: "{{ rabbitmq_app_dir }}/log-rabbitmq-memory.py"
owner: "{{ rabbitmq_user }}"
group: "{{ rabbitmq_group }}"
mode: "0775"
- name: Set up a cron job to run queue script
cron:
name: "log-queue-lenghts"
job: "{{ rabbitmq_app_dir }}/log-rabbitmq-queues.sh >/dev/null 2>&1"
- name: Set up a cron job to run the script
cron:
name: "log-rabbitmq-memory-usage"
job: "{{ rabbitmq_app_dir }}/log-rabbitmq-memory.py >/dev/null 2>&1"
- name: install logrotate configuration
template:
src: etc/logrotate.d/rabbitmq.j2
......
#!/usr/bin/python
from subprocess import Popen,PIPE
import logging
log_file="{{ rabbitmq_log_dir }}/rabbitmq.memory.log"
def run_cmd(cmd):
process=Popen(cmd,stdout=PIPE,stderr=PIPE,shell=True)
output=process.communicate()[0]
return output
if __name__=='__main__':
process_mem=run_cmd("/usr/sbin/rabbitmqctl status | grep total | awk -F',|}' 'NR==1{print $2}'")
logging.basicConfig(filename=log_file,
format='%(asctime)s - %(message)s',level=logging.DEBUG)
if process_mem:
process_mem_mb=float(process_mem)/(1024 * 1024)
logging.debug("RabbitMQ Memory Usage(MB): {}".format(process_mem_mb))
else:
logging.debug("error connecting RabbitMQ process")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment