Linux processes control and monitoring

Post on 22-May-2015

231 views 2 download

Tags:

description

Контроль и мониторинг Linux процессов для Рython разработчиков

Transcript of Linux processes control and monitoring

Monitoring for Web Applications

Контроль и мониторинг Linux процессов для Рython разработчиков

• sudo apt-get install nginx• ls /etc/init.d/nginx• sudo service nginx restart

• sudo apt-get install mongodb-10gen• ls /etc/init.d/mongodb• sudo service mongodb status• ls /etc/mongodb.conf

• sudo apt-get install rabbitmq-server• ls /etc/init.d/rabbitmq-server• service rabbitmq-server status

Monitoring system which just works

• sudo apt-get install monit• ls /etc/init.d/monit• service monit status• cat sudo cat /etc/monit/monitrc

1. set daemon 120 # check services at 2-minute intervals2. set logfile /var/log/monit.log

1. check process nginx with pidfile /var/run/nginx.pid2. start program = "/etc/init.d/nginx start"3. stop program = "/etc/init.d/nginx stop"4. if failed port 80 protocol http then alert5. if cpu usage is greater than 60 percent for 2 cycles6. then alert7. if cpu usage > 98% for 5 cycles then restart8. if 2 restarts within 3 cycles then timeout9. alert admin@bar.com

Installation & Configuration

Monit Web Server

MongoDB process detail

• /home/user/venv/bin/pip install tornado• ls venv/lib/python2.7/site-packages/tornado• venv/bin/python my_web_project/app.py

• /home/user/venv/bin/pip install celery• ls venv/lib/python2.7/site-packages/celery• venv/bin/celery worker -A myproject.tasks --

config=myproject.celeryconfig

Virtualev based Python stack

A process control system

• supervisord• supervisorctl• Web Server• XML RPC Interface

• /home/user/venv/bin/pip install supervisor• ls venv/lib/python2.7/site-packages/supervisor• /venv/bin/echo_supervisord_conf > supervisord.conf• venv/bin/supervisord -c supervisord.conf• venv/bin/supervisorctl -c supervisord.conf shutdown

Supervisor Web Interface

Configuring Supervisor

Celery supervisor config

Plugin source code