参考https://book.open-falcon.org/zh_0_2/quick_install/prepare.html
一、安装后端
1.环境准备
yum -y install redis
yum install golang -y ##需要epel源
配置环境变量(/etc/profile)
export GOROOT=/usr/lib/golang
export GOPATH=/home
配置mysql
yum install -y mysql-server
/etc/init.d/mysqld start
初始化数据库
cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git
cd /tmp/falcon-plus/scripts/mysql/db_schema/
mysql -uroot -p0 <1_uic-db-schema.sql
mysql -uroot -p0 <2_portal-db-schema.sql
mysql -uroot -p0 <3_dashboard-db-schema.sql
mysql -uroot -p0 <4_graph-db-schema.sql
mysql -uroot -p0 <5_alarms-db-schema.sql
rm -rf /tmp/falcon-plus/
如果你是从v0.1.0升级到当前版本v0.2.0,那么只需要执行如下命令:
mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
创建工作目录
export FALCON_HOME=/usr/app/falcon
export WORKSPACE=$FALCON_HOME/open-falcon
mkdir -p $WORKSPACE
wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.1/open-falcon-v0.2.1.tar.gz
tar -xzvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE
aggregator /usr/app/falcon/aggregator/config/cfg.json
graph /usr/app/falcon/graph/config/cfg.json
hbs /usr/app/falcon/hbs/config/cfg.json
nodata /usr/app/falcon/nodata/config/cfg.json
api /usr/app/falcon/api/config/cfg.json
alarm /usr/app/falcon/alarm/config/cfg.json
修改数据库用户密码
cd $WORKSPACE
grep -Ilr 3306 ./ | xargs -n1 -- sed -i 's/root:/root:0/g'
启动
cd $WORKSPACE
./open-falcon start
# 检查所有模块的启动状况
./open-falcon check
# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent
./open-falcon monitor agent
二、安装前端
cd $WORKSPACE
git clone https://github.com/open-falcon/dashboard.git
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools"
#下载ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py --insecure
#下载pip
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
#解压并安装
tar xf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
#测试,查看版本
pip -V
#pip安装软件
cd /home/work/open-falcon/dashboard
pip install -r pip_requirements.txt
open-falcon/dashboard/rrd/config.py
dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""
bash control start
访问网站 http://IP:8081 ,刚登陆需要注册用户,注册的第一个用户名为root的帐号会被认为是超级管理员,超级管理员可以设置其他用户为管理员。
以开发者模式启动
./env/bin/python wsgi.py
open http://127.0.0.1:8081 in your browser.
在生产环境启动
bash control start
open http://127.0.0.1:8081 in your browser.
停止dashboard运行
bash control stop
查看日志
bash control tail
import urllib import requests import json f = open('qname.txt','r') content = f.read() f.close() queues = content.split("\n") queues = [ x.strip() for x in queues if x.strip() != "" ] name_template = "each(metric=bdp.ops.queue_used endpoint=bdp.ops.queue_used##qname@@{0}##cluster@@bdp##env@@prod)" query_url = "http://bdp-falcon-api.sf-express.com/api/v1/getExpression" delete_url = "http://bdp-falcon-proxy.sf-express.com/falcon/rule/deleteExpression" for q in queues: r = requests.get(query_url + "/" + urllib.pathname2url(name_template.format(q))) result = json.loads(r.text) try: result = result[0] policy_id = result['id'] delete_r = requests.get(delete_url, data="%d" % policy_id) print delete_r.text except IndexError: continue