Cabot简介
Cabot is a free, open-source, self-hosted infrastructure monitoring platform that provides some of the best features of PagerDuty, Server Density, Pingdom and Nagios without their cost and complexity. (Nagios, I'm mainly looking at you.)
It provides a web interface that allows you to monitor services (e.g. "Stage Redis server", "Production ElasticSearch cluster") and send telephone, sms or hipchat/email alerts to your on-duty team if those services start misbehaving or go down - all without writing a line of code. Best of all, you can use data that you're already pushing to Graphite/statsd to generate alerts, rather than implementing and maintaining a whole new system of data collectors. 官网。
Cabot环境搭建
初始化mysql数据库
$ mysql -u root -p -e "CREATE USER cabot@localhost IDENTIFIED BY 'cabot'";
$ mysql -u root -p -e "CREATE DATABASE cabot";
$ mysql -u root -p -e "GRANT ALL PRIVILEGES ON \`cabot\`.* TO \`cabot\`@localhost";
下载cabot
$ git clone https://github.com/arachnys/cabot.git
安装依赖软件
$ sudo yum install ruby
$ sudo gem install foreman
$ sudo pip install fabric
$ sudo yum install python-devel
$ sudo yum install openldap-devel
$ sudo pip install -r requirements.txt
$ sudo pip install -r requirements-plugins.txt
$ sudo pip install -r requirements-dev.txt
$ sudo pip install MySQL-python
$ sudo yum install nodejs
$ sudo npm install -g less
$ sudo npm install -g coffee-script
修改配置文件
$ cp production.env.example production.env
$ vi production.env
DEBUG=t
DATABASE_URL=mysql://cabot:cabot@localhost:3306/cabot
DJANGO_SETTINGS_MODULE=cabot.settings
LOG_FILE=log
PORT=5008
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE=Asia/Shanghai
# Django settings
CELERY_BROKER_URL=redis://localhost:6379/1
DJANGO_SECRET_KEY=2FL6ORhHwr5eX34pP9mMugnIOd3jzVuT45f7w430Mt5PnEwbcJgma0q8zUXNZ68A
# Hostname of your Graphite server instance
GRAPHITE_API=http://*.*.*.*:12346/
GRAPHITE_USER=username
GRAPHITE_PASS=password
修改启动文件
$ vi .foreman
# vi: set ft=yaml :
procfile: Procfile
env: conf/production.env
$ vi gunicorn.conf
# -*- mode: python -*-
# vi: set ft=python :
import os
bind = '0.0.0.0:%s' % os.environ['PORT']
workers = 3
$ vi Procfile
web: gunicorn cabot.wsgi:application --config gunicorn.conf
celery: celery worker -B -A cabot --loglevel=INFO --concurrency=16 -Ofair
beat: celery beat -A cabot --loglevel=INFO
初始化数据库
$ sh setup_dev.sh
安装redis
$ sudo yum install redis
使用supervisor管理redis
添加redis配置文件
$ sudo vi /etc/supervisord.d/redis.conf
[program:redis]
command=/usr/bin/redis-server
autorstart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stdout_logfile=/var/log/redis.log
directory=/usr/bin
重新加载配置文件
$ sudo supervisorctl reload
$ sudo supervisorctl status
redis RUNNING pid 17493, uptime 0:04:06
启动web程序
$ foreman start web
启动celery
foreman start celery
登录管理页面(第一次登录需要设置管理员账号)
http://localhost:5008
使用supervisor管理Cabot,Celery进程
$ sudo vi /etc/supervisord.d/cabot.conf
[program:web]
command=foreman start web
autorstart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stdout_logfile=/home/dengsc/app/cabot/log/web.log
directory=/home/dengsc/app/cabot
[program:celery]
command=foreman start celery
autorstart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stdout_logfile=/home/dengsc/app/cabot/log/celery.log
directory=/home/dengsc/app/cabot
使用supervisor管理程序
sudo supervisorctl reload
some error
配置中设置DEBUG=False时报错,ValueError: Missing staticfiles manifest entry for 'bootstrap/css/bootstrap.css'
$ foreman run python manage.py collectstatic
$ foreman run python manage.py compress
$ sudo supervisorctl restart web
# 可能引起报错的语句
# settings.py
# if not DEBUG:
# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
#
# stackoverflow: https://stackoverflow.com/questions/44160666/valueerror-missing-staticfiles-manifest-entry-for-favicon-ico
最后上一张Cabot管理页面的截图
到目前位置Cabot主题已搭建完毕,后面博客会讲一下开发自定义告警模块,目前我也还在钻研中。