官方文档
https://book.open-falcon.org/...
安装包下载地址
- 百度网盘地址
链接: https://pan.baidu.com/s/1xLzUzZpAagtJHpnX5SjUiw 提取码: ve3u
环境准备
安装redis
yum install -y mysql-server
安装mysql
yum install -y mysql-server
- 创建数据库用户并为用户分配权限
GRANT ALL PRIVILEGES ON *.* TO 'real_user'@'localhost' IDENTIFIED BY 'real_password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
安装git
#查看linux版本信息:
$ cat /etc/redhat-release
#输入命令安装git:
$ yum install git
#等待下载,自动安装完毕,查看git版本
$ git --version
安装GO
- 下载go
- 解压
tar -C /usr/local/ -xzvf go1.13.5.linux-amd64.tar.gz
- 配置环境变量
vim /etc/profile
export GOROOT=/usr/local/go
export GOPATH=/home/bruce/goProject
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:$GOPATH/bin
export FALCON_HOME=/home/work
export WORKSPACE=$FALCON_HOME/open-falcon
source /etc/profile
mkdir -p $WORKSPACE
- 查询安装结果
go version
go version go1.13.5 linux/amd64
安装后台
tar -xzvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE
- 在一台机器上启动所有的后端组件
#首先确认配置文件中数据库账号密码与实际相同,否则需要修改配置文件。
cd $WORKSPACE
grep -Ilr 3306 ./ | xargs -n1 -- sed -i 's/root:/real_user:real_password/g'
#编辑agent采集端配置文件
vim agent/config/cfg.json
{
"debug": true,
"hostname": "10.159.42.37",
"ip": "",
"plugin": {
"enabled": false,
"dir": "./plugin",
"git": "https://github.com/open-falcon/plugin.git",
"logs": "./logs"
},
"heartbeat": {
"enabled": true,
"addr": "10.159.44.248:6030",
"interval": 60,
"timeout": 1000
},
"transfer": {
"enabled": true,
"addrs": [
"10.159.44.248:8433"
],
"interval": 60,
"timeout": 1000
},
"http": {
"enabled": true,
"listen": ":1988",
"backdoor": false
},
"collector": {
"ifacePrefix": ["eth", "em"],
"mountPoint": []
},
"default_tags": {
},
"ignore": {
"cpu.busy": false,
"df.bytes.free": false,
"df.bytes.total": false,
"df.bytes.used": false,
"df.bytes.used.percent": false,
"df.inodes.total": false,
"df.inodes.free": false,
"df.inodes.used": false,
"df.inodes.used.percent": false,
"mem.memtotal": false,
"mem.memused": false,
"mem.memused.percent": false,
"mem.memfree": false,
"mem.swaptotal": false,
"mem.swapused": false,
"mem.swapfree": false
}
- 启动
cd $WORKSPACE
./open-falcon start
or
./open-falcon start agent
# 检查所有模块的启动状况
./open-falcon check
# 查看某个模块的日志
./open-falcon monitor agent
- 更多的命令行工具用法
# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent
./open-falcon check
falcon-graph UP 53007
falcon-hbs UP 53014
falcon-judge UP 53020
falcon-transfer UP 53026
falcon-nodata UP 53032
falcon-aggregator UP 53038
falcon-agent UP 53044
falcon-gateway UP 53050
falcon-api UP 53056
falcon-alarm UP 53063
For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log
- 关闭防火墙
1.使用命令:systemctl status firewalld.service查看防火墙状态
2.执行后可以看到绿色字样标注的“active(running)”,说明防火墙是开启状态
3.使用命令:systemctl stop firewalld.service 关闭运行的防火墙
4.关闭后,使用命令systemctl status firewalld.service查看防火墙状态可以看到,disavtive(dead...
5.前面的方法,一旦重启操作系统,防火墙就自动开启了,该怎么设置才能永久关闭防火墙呢?
部署前端:
建议使用centos7.0以上版本部署,python3版本兼容,如果使用centos6版本,python2版本不兼容。详细使用手册可以参考官网。
- 参考文档
https://book.open-falcon.org/...
- 克隆前端代码
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"
cd $WORKSPACE/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
- 修改dashboard配置信息
#其中数据库用户名和密码改一下,还有API服务的访问地址
vim /home/work/open-falcon/dashboard/rrd/config.py
# Falcon+ API
API_ADDR = os.environ.get("API_ADDR","http://10.159.44.248:8080/api/v1")
API_USER = os.environ.get("API_USER","admin")
API_PASS = os.environ.get("API_PASS","password")
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","10.159.44.248")
PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",3306))
PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","")
PORTAL_DB_NAME = os.environ.get("PORTAL_DB_NAME","falcon_portal")
# alarm database
# TODO: read from api instead of db
ALARM_DB_HOST = os.environ.get("ALARM_DB_HOST","10.159.44.248")
ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",3306))
ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")
- 启动
#以开发者模式启动
./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.
- 停止
bash control stop
- 查看日志
bash control tail
- 展示
邮件报警
- 编辑ALERM服务配置文件
vim /home/work/open-falcon/alarm/config/cfg.json
#红框位置修改成邮件接收接口地址
#保存退出
wq!
- 重启
cd /home/work/open-falcon
./open-falcon restart alerm
修改报警接口
/**
* OPEN-FALLCON发送报警邮件
* @param request
* @return 消息列表json
* @throws Exception
*/
@RequestMapping(value = "/senderFalEmail", method = RequestMethod.POST)
public @ResponseBody
BaseRestResponse senderFalEmail(HttpServletRequest request){
log.info("========进入senderFalEmail Controller");
String to_addrs = request.getParameter("tos");
String subject = request.getParameter("subject");
String content = request.getParameter("content");
log.info("========进入senderFalEmail Controller==========收件人:"+to_addrs+",主题:"+subject+",邮件内容:"+content);
MimeMessage message = mailSender.createMimeMessage();
try{
MimeMessageHelper helper = new MimeMessageHelper(message, true,"utf-8");//构造消息helper,第二个参数表明这个消息是multipart类型的
helper.setFrom("[email protected]");
helper.setTo(to_addrs);
helper.setSubject(subject);
helper.setText(content, true);//第二个参数表明这是一个HTML
mailSender.send(message);
}catch (MailException mailException){
log.info("发送邮件报警异常!content="+content+mailException.getMessage());
return new BaseRestResponseData(MessageError.EMAIL_SEND_ERROR).data(mailException.getMessage());
}catch (MessagingException messageException){
log.info("发送邮件报警内容异常!content="+content+messageException.getMessage());
return new BaseRestResponseData(MessageError.EMAIL_SEND_ERROR).data(messageException.getMessage());
}
log.info("senderFalEmail邮件发送完毕");
return new BaseRestResponseData();
}
报警测试邮件展示
PROBLEM P0 Endpoint:10.199.96.152 Metric:mem.memfree.percent Tags: all(#3): 7.43705<=10 Note:服务器内存告警,请及时处理 Max:3, Current:1 Timestamp:2019-12-25 09:58:00 http://portalip:8081/portal/template/view/4
OK P0 Endpoint:10.199.96.152 Metric:mem.memfree.percent Tags: all(#3): 13.87895<=10 Note:服务器内存告警,请及时处理 Max:3, Current:1 Timestamp:2019-12-25 09:59:00 http://portalip:8081/portal/template/view/4