使用open-falcon的插件mymon监控mysql指标

环境准备

需要已经安装了open-falcon。

没有golang环境的话首先在golang官网下载压缩包,解压后进入文件bin目录,把go执行文件 ln -s 绝对源文件路径/go /usr/local/bin/go 配置到系统bin执行文件

然后配置GOPATH

比如我要在/downloads/下运行这个项目,则设置gopath环境变量
export GOPATH=/downloads/

安装mymon

cd /downloads/

go get -u github.com/open-falcon/mymon

get下来之后,修改项目etc下的myMon.cfg里的mysql地址与帐号密码

添加到定时任务,定时读取mysql指标并输出给open-falcon
echo '* * * * * /downloads/go/src/github.com/open-falcon/mymon/mymon -c /downloads/go/src/github.com/open-falcon/mymon/etc/myMon.cfg' > /etc/cron.d/mymon

/etc/init.d/cron restart
/etc/init.d/cron status

查看效果

使用浏览器进入open-falcon前端网页,发现增加了mysql的很多指标,如图所示:
使用open-falcon的插件mymon监控mysql指标

常用监控指标

吞吐量
	Questions        已执行的由客户端发出的语句
	Com_select       执行SELECT语句的数量,通常也就是QPS
	Writes           Com_insert+Com_update+Com_delete,也就是TPS

执行性能
	Slow_queries         慢查询的数量

连接情况
	Threads_connected                   已经建立的连接
	Threads_running                     正在运行的连接
	Connection_errors_internal          由于服务器内部本身导致的错误
	Aborted_connects                    尝试与服务器建立连接但是失败的次数
	Connection_errors_max_connections   由于到达最大连接数导致的错误

指标参考:https://jin-yang.github.io/post/mysql-monitor.html

相关地址:

https://github.com/open-falcon/mymon