0. 运维监控工具选择
1. 安装脚本(主服务)
常规安装环境搭建太复杂, dashboard安装碰到python依赖不容易解决, 直接使用docker安装, 这里总结除了一个安装 shell script, 如下:
#!/bin/sh
## env params
MYSQL_HOST=my.falcon.local
MYSQL_PASSWORD=falcon
MYSQL_USER=falcon
## init mysql table before the first running
# cd /tmp && \
# git clone --depth=1 https://github.com/open-falcon/falcon-plus && \
# cd /tmp/falcon-plus/ && \
# for x in `ls ./scripts/mysql/db_schema/*.sql`; do
# echo init mysql table $x ...;
# docker exec -i falcon-mysql mysql -h $MYSQL_HOST -u $MYSQL_USER -p $MYSQL_PASSWORD < $x;
# done
## falcon redis
docker run --name falcon-redis --restart always -p 6380:6379 -d redis:4-alpine3.8
## falcon plus
mkdir -p /seniverse/data/falcon
mkdir -p /seniverse/log/falcon
docker run -itd --name falcon-plus \
--restart always \
--link=falcon-redis:redis.falcon \
-p 8433:8433 \
-p 8080:8080 \
-p 6060:6060 \
-p 6030:6030 \
-e MYSQL_PORT=$MYSQL_USER:$MYSQL_PASSWORD@tcp\($MYSQL_HOST:3306\) \
-e REDIS_PORT=redis.falcon:6379 \
-v /seniverse/data/falcon:/open-falcon/data \
-v /seniverse/log/falcon:/open-falcon/logs \
openfalcon/falcon-plus:v0.2.1
docker exec falcon-plus sh ctrl.sh start \
graph hbs judge transfer nodata aggregator agent gateway api alarm
ls -l /seniverse/log/falcon
## falcon dashboard
docker run -itd --name falcon-dashboard \
-p 8081:8081 \
--restart always \
--link=falcon-plus:api.falcon \
-e API_ADDR=http://api.falcon:8080/api/v1 \
-e PORTAL_DB_HOST=$MYSQL_HOST \
-e PORTAL_DB_PORT=3306 \
-e PORTAL_DB_USER=$MYSQL_USER \
-e PORTAL_DB_PASS=$MYSQL_PASSWORD \
-e PORTAL_DB_NAME=falcon_portal \
-e ALARM_DB_HOST=$MYSQL_HOST \
-e ALARM_DB_PORT=3306 \
-e ALARM_DB_USER=$MYSQL_USER \
-e ALARM_DB_PASS=$MYSQL_PASSWORD \
-e ALARM_DB_NAME=alarms \
-w /open-falcon/dashboard openfalcon/falcon-dashboard:v0.2.1 \
'./control startfg'
2. 其他机器(代理服务)
2.1 下载二进制文件
export FALCON_HOME=/home/wj
export WORKSPACE=$FALCON_HOME/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
2.2 修改host
增加一个指向主服务的别名
vim /etc/hosts
# falcon server
10.0.1.34 host.server.local
2.3 修改 agent 配置
- heartbeat.addr
- transfer.addrs
- hostname[可选]
- ip[可选]
cd $WORKSPACE
vim transfer/config/cfg.json
{
"debug": true,
"hostname": "my.servermaster.local",
"ip": "192.168.132.152",
"plugin": {
"enabled": false,
"dir": "./plugin",
"git": "https://github.com/open-falcon/plugin.git",
"logs": "./logs"
},
"heartbeat": {
"enabled": true,
"addr": "host.server.local:6030",
"interval": 60,
"timeout": 1000
},
"transfer": {
"enabled": true,
"addrs": [
"host.server.local:8433"
],
"interval": 60,
"timeout": 1000
},
"http": {
"enabled": true,
"listen": ":1988",
"backdoor": false
},
"collector": {
"ifacePrefix": ["eth", "em"],
"mountPoint": []
},
"default_tags": {
},
"ignore": {
"cpu.busy": true,
"df.bytes.free": true,
"df.bytes.total": true,
"df.bytes.used": true,
"df.bytes.used.percent": true,
"df.inodes.total": true,
"df.inodes.free": true,
"df.inodes.used": true,
"df.inodes.used.percent": true,
"mem.memtotal": true,
"mem.memused": true,
"mem.memused.percent": true,
"mem.memfree": true,
"mem.swaptotal": true,
"mem.swapused": true,
"mem.swapfree": true
}
}
2.4 启动 agent
cd $WORKSPACE
./open-falcon restart agent
./open-falcon monitor agent
通过 monitor 可以看到 agent和主服务通信.
3. 检查&体验
默认falcon没有创建用户, 需要自己创建, 第一个用户视为root用户.
- 注册: http://localhost:8081/auth/register
- 登录: http://localhost:8081/auth/login
- 查看看板: http://localhost:8081
4. 实战
配置一个监控redis的监控, 首先准备脚本redis-monitor.py, 内容略,点解链接可在github上查看到.
mkdir -p /home/wj/falcon-plugins
### 新建脚本复制github上脚本内容
touch /home/wj/falcon-plugins/redis-monitor.py
### 编辑crontab, 并创建一个定时任务, 上报redis信息
sudo crontab -e
### debug
* * * * * python /home/wj/falcon-plugins/redis-monitor.py >> /home/wj/falcon-plugins/redis-monitor.log
定时任务运行结果可以通过redis-monitor.log查看, 最后看看监控的redis.connected_clients的效果(生成环境监控了一一天):
5. 遇到问题
-
采集agent服务信息收集不上:
主服务端口可能没有开通, 可以通过monitor命令查看详情.
-
手欠/重装/其他原因删除endpoint重新收集endpoint信息
在住服务节点, 更新索引执行: curl -s http://127.0.0.1:6071/index/updateAll
6. 参考资料
- falcon-plus/docker/
- Agent
- 监控redis
- redis-monitor
- open-falcon-0.21 邮件和微信报警详解
- Open-Falcon plugin for Grafana
- mailsende
- FAQ
来源:oschina
链接:https://my.oschina.net/u/2623130/blog/2993706