grafana4.5.2 整合 open-falcon-0.21

96
k小男生
2017.11.09 10:54* 字数 1034

由于公司监控需要 需对线上所有TOMCAT进行 GC监控  故采用已下方案:

1:通过jmxmon采集tomcat服务状态 上报给open-falcon-agent

2:open-falcon通过api接口上报数据给grafana

3: grafana配置数据源连接open-falcon-2.0 并进行数据展示

环境准备:

部署open-falcon-2.0 不啰嗦直接上命令 不懂自己gb:

yum install -y redis

yum install -y mysql-server

初始化数据库:

cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git

cd /tmp/falcon-plus/scripts/mysql/db_schema/

mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql

mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql

mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql

mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql

mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql

rm -rf /tmp/falcon-plus/

下载二进制包:

https://github.com/open-falcon/falcon-plus/releases  #这是地址我下载的是open-falcon-v0.2.1.tar.gz

环境变量设置:

export FALCON_HOME=/data/open-falcon-0.21

export WORKSPACE=$FALCON_HOME/open-falcon

source /etc/profile

tar zxvf  open-falcon-v0.2.1.2.tar.gz  -C  /data/open-falcon-0.21/open-falcon

cd /data/open-falcon-0.21/open-falcon

./open-falcon start

./open-falcon check

记得更改mysql 用户名和密码 如果不一致 默认为空

安装前端代码也就是dashboard:

cd /data/open-falcon-0.21/open-falcon

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 /data/open-falcon-0.21/open-falcon/dashboard

virtualenv ./env

./env/bin/pip install -r pip_requirements.txt

如无报错说明安装完成

dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改

## API_ADDR 表示后端api组件的地址

API_ADDR = "http://127.0.0.1:8080/api/v1"

## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""

## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""

启动dashboard:

cd /data/open-falcon-0.21/open-falcon/dashboard

./control start

./control status|tail

port:8081  可浏览器访问

Grafana4.5.2  部署:

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.0-1.x86_64.rpm

yum localinstallgrafana-4.6.0-1.x86_64.rpm

vim /etc/grafana/grafana.ini 


/etc/init.d/grafana-server restart

访问地址:falcon.uxin001.com:3000

访问:https://grafana.com/plugins/fastweb-openfalcon-datasource/installation

解压至/var/lib/grafana/plugins 下  如图:此配置要检查配置文件下的plugins = /var/lib/grafana/plugins配置

登录grafana4.5 增加数据源:

dff

此处注意:http://192.168.5.161:8080/api/v1/grafana  为open-falcon-0.21版本的api接口 和0.1版本有所区别 建议安装最新版本open-falcon

为监控机器添加变量模板  看图说话:




获取监控值 $tomcat 为IP列表模板

grafana暂时不支持open-falcon数据的报警   故我们还是用的falcon邮件和微信报警 具体详见另一篇文章

jmxmon部署:

部署之前请确保tomcat开启JMX

vim  /data/soft/tomcat_home/bin/catalina.sh

# ----- Execute The Requested Command -----------------------------------------

在此之上添加:

CATALINA_OPTS="$CATALINA_OPTS

-Dcom.sun.management.jmxremote

-Djava.rmi.server.hostname=192.168.5.161

-Dcom.sun.management.jmxremote.port=9999

-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.authenticate=false"

hostname:本地IP

port:自定义端口 给远程连接使用

authenticate=false 不开启远程用户名和密码验证

重启tomacat

https://github.com/toomanyopenfiles/jmxmon/releases/tag/v0.0.2 #jmxmon下载地址

tar zxvf  jmxmon-v0.0.2.tar.gz -C  /data/open-falcon/falcon-jmxmon/

配置参考:

cat  conf.properties

# the working dir

workDir=./

# localhost jmx ports, split by comma

jmx.ports=9999

# agent port url

agent.posturl=http://127.0.0.1:1988/v1/push

./control start 启动

./control status|tail

登录open-falcon查看 Gc数据是否过来

http://47.95.194.238:8081/

参考连接:

https://book.open-falcon.org/zh_0_2/quick_install/prepare.html  #open-falcon 官网地址

https://github.com/open-falcon/falcon-plus/releases    #open-falcon-v0.2.1.tar.gz 下载地址

https://github.com/toomanyopenfiles/jmxmon  #jmxmon采集指标

https://github.com/toomanyopenfiles/jmxmon/releases/tag/v0.0.2 #jmxmon下载地址

https://grafana.com/plugins/fastweb-openfalcon-datasource/installation  grafana-4.5 open-falcon插件支持

https://grafana.com/grafana/download  grafana安装下载

日记本
Web note ad 1