系统环境:CentOS 6.3 x64  http://www.linuxidc.com/Linux/2012-12/76583.htm

mysql:    mysql-5.6.10 http://www.linuxidc.com/Linux/2013-02/79162.htm

zabbix:  zabbix-2.06

一.修改mysql客户端zabbix_agentd.conf配置:

# vi /usr/local/etc/zabbix_agentd.conf

这里注意mysql账号密码与你的数据库账户需对应

末行添加如下内容:

-----------------

UserParameter=mysql.Ping,mysqladmin -uroot -p123456  ping|grep alive|wc -l

UserParameter=mysql.Threads,mysqladmin -uroot -p123456  status|cut -f3 -d":"|cut -f1 -d"Q"

UserParameter=mysql.Questions,mysqladmin -uroot -p123456  status|cut -f4 -d":"|cut -f1 -d"S"

UserParameter=mysql.Slowqueries,mysqladmin -uroot -p123456  status|cut -f5 -d":"|cut -f1 -d"O"

UserParameter=mysql.Qps,mysqladmin -uroot -p123456  status|cut -f9 -d":"

UserParameter=mysql.Slave_IO_State,if [ "$(mysql -uroot -p123456  -e "show slave status\G"| grep Slave_IO_Running|awk '{print $2}')" == "Yes" ];then echo 1; else echo 0;fi

UserParameter=mysql.Slave_SQL_State,if [ "$(mysql -uroot -p123456  -e "show slave status\G"| grep Slave_SQL_Running|awk '{print $2}')" == "Yes" ];then echo 1; else echo 0;fi

UserParameter=mysql.Key_buffer_size,mysql -uroot -p123456  -e "show variables like 'key_buffer_size';"| grep -v Value |awk '{print $2/1024^2}'

UserParameter=mysql.Key_reads,mysql -uroot -p123456  -e "show status like 'key_reads';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Key_read_requests,mysql -uroot -p123456  -e "show status like 'key_read_requests';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Key_cache_miss_rate,echo $(mysql -uroot -p123456  -e "show status like 'key_reads';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'key_read_requests';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Key_blocks_used,mysql -uroot -p123456  -e "show status like 'key_blocks_used';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Key_blocks_unused,mysql -uroot -p123456  -e "show status like 'key_blocks_unused';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Key_blocks_used_rate,echo $(mysql -uroot -p123456  -e "show status like 'key_blocks_used';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'key_blocks_unused';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/($1+$2)*100)}'

UserParameter=mysql.Innodb_buffer_pool_size,mysql -uroot -p123456  -e "show variables like 'innodb_buffer_pool_size';"| grep -v Value |awk '{print $2/1024^2}'

UserParameter=mysql.Innodb_log_file_size,mysql -uroot -p123456  -e "show variables like 'innodb_log_file_size';"| grep -v Value |awk '{print $2/1024^2}'

UserParameter=mysql.Innodb_log_buffer_size,mysql -uroot -p123456  -e "show variables like 'innodb_log_buffer_size';"| grep -v Value |awk '{print $2/1024^2}'

UserParameter=mysql.Table_open_cache,mysql -uroot -p123456  -e "show variables like 'table_open_cache';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Open_tables,mysql -uroot -p123456  -e "show status like 'open_tables';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Opened_tables,mysql -uroot -p123456  -e "show status like 'opened_tables';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Open_tables_rate,echo $(mysql -uroot -p123456  -e "show status like 'open_tables';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'opened_tables';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/($1+$2)*100)}'

UserParameter=mysql.Table_open_cache_used_rate,echo $(mysql -uroot -p123456  -e "show status like 'open_tables';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show variables like 'table_open_cache';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/($1+$2)*100)}'

UserParameter=mysql.Thread_cache_size,mysql -uroot -p123456  -e "show variables like 'thread_cache_size';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Threads_cached,mysql -uroot -p123456  -e "show status like 'Threads_cached';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Threads_connected,mysql -uroot -p123456  -e "show status like 'Threads_connected';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Threads_created,mysql -uroot -p123456  -e "show status like 'Threads_created';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Threads_running,mysql -uroot -p123456  -e "show status like 'Threads_running';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_free_blocks,mysql -uroot -p123456  -e "show status like 'Qcache_free_blocks';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_free_memory,mysql -uroot -p123456  -e "show status like 'Qcache_free_memory';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_hits,mysql -uroot -p123456  -e "show status like 'Qcache_hits';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_inserts,mysql -uroot -p123456  -e "show status like 'Qcache_inserts';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_lowmem_prunes,mysql -uroot -p123456  -e "show status like 'Qcache_lowmem_prunes';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_not_cached,mysql -uroot -p123456  -e "show status like 'Qcache_not_cached';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_queries_in_cache,mysql -uroot -p123456  -e "show status like 'Qcache_queries_in_cache';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_total_blocks,mysql -uroot -p123456  -e "show status like 'Qcache_total_blocks';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Qcache_fragment_rate,echo $(mysql -uroot -p123456  -e "show status like 'Qcache_free_blocks';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'Qcache_total_blocks';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Qcache_used_rate,echo $(mysql -uroot -p123456  -e "show variables like 'query_cache_size';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'Qcache_free_memory';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",($1-$2)/$1*100)}'

UserParameter=mysql.Qcache_hits_rate,echo $(mysql -uroot -p123456  -e "show status like 'Qcache_hits';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'Qcache_inserts';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",($1-$2)/$1*100)}'

UserParameter=mysql.Query_cache_limit,mysql -uroot -p123456  -e "show variables like 'query_cache_limit';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Query_cache_min_res_unit,mysql -uroot -p123456  -e "show variables like 'query_cache_min_res_unit';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Query_cache_size,mysql -uroot -p123456  -e "show variables like 'query_cache_size';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Sort_merge_passes,mysql -uroot -p123456  -e "show status like 'Sort_merge_passes';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Sort_range,mysql -uroot -p123456  -e "show status like 'Sort_range';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Sort_rows,mysql -uroot -p123456  -e "show status like 'Sort_rows';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Sort_scan,mysql -uroot -p123456  -e "show status like 'Sort_scan';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_first,mysql -uroot -p123456  -e "show status like 'Handler_read_first';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_key,mysql -uroot -p123456  -e "show status like 'Handler_read_key';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_next,mysql -uroot -p123456  -e "show status like 'Handler_read_next';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_prev,mysql -uroot -p123456  -e "show status like 'Handler_read_prev';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_rnd,mysql -uroot -p123456  -e "show status like 'Handler_read_rnd';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Handler_read_rnd_next,mysql -uroot -p123456  -e "show status like 'Handler_read_rnd_next';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_select,mysql -uroot -p123456  -e "show status like 'com_select';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_insert,mysql -uroot -p123456  -e "show status like 'com_insert';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_insert_select,mysql -uroot -p123456  -e "show status like 'com_insert_select';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_update,mysql -uroot -p123456  -e "show status like 'com_update';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_replace,mysql -uroot -p123456  -e "show status like 'com_replace';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Com_replace_select,mysql -uroot -p123456  -e "show status like 'com_replace_select';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Table_scan_rate,echo $(mysql -uroot -p123456  -e "show status like 'Handler_read_rnd_next';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'com_select';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Open_files,mysql -uroot -p123456  -e "show status like 'open_files';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Open_files_limit,mysql -uroot -p123456  -e "show variables like 'open_files_limit';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Open_files_rate,echo $(mysql -uroot -p123456  -e "show status like 'open_files';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show variables like 'open_files_limit';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Created_tmp_disk_tables,mysql -uroot -p123456  -e "show status like 'created_tmp_disk_tables';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Created_tmp_tables,mysql -uroot -p123456  -e "show status like 'created_tmp_tables';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Created_tmp_disk_tables_rate,echo $(mysql -uroot -p123456  -e "show status like 'created_tmp_disk_tables';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'created_tmp_tables';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Max_connections,mysql -uroot -p123456  -e "show variables like 'max_connections';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Max_used_connections,mysql -uroot -p123456  -e "show status like 'Max_used_connections';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Max_connections_used_rate,echo $(mysql -uroot -p123456  -e "show status like 'Max_used_connections';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show variables like 'max_connections';"| grep -v Value |awk '{print $2}')| awk '{printf("%1.4f\n",$1/$2*100)}'

UserParameter=mysql.Table_locks_immediate,mysql -uroot -p123456  -e "show status like 'Table_locks_immediate';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Table_locks_waited,mysql -uroot -p123456  -e "show status like 'table_locks_waited';"| grep -v Value |awk '{print $2}'

UserParameter=mysql.Engine_select,echo $(mysql -uroot -p123456  -e "show status like 'Table_locks_immediate';"| grep -v Value |awk '{print $2}') $(mysql -uroot -p123456  -e "show status like 'table_locks_waited';"| grep -v Value |awk '{print $2}')| awk '{printf("%5.4f\n",$1/$2)}'

二.访问zabbix web后台导入模板

1.访问zabbix-配置-模板,点击右上角的载入:

2.本地导入文件:

下载本博附件mysql_template.xml文件导入zabbix模板,点击载入保存

3.访问zabbix-配置-模板,查看模板:

4.访问zabbix-配置-主机-Zabbix server,找到apache客户端关联mysql_template.xml模版:

重启zabbix_agentd服务

# /etc/init.d/zabbix_agentd restart

添加完毕,查看效果

zabbix agent配置文件 与 mysql模板 下载地址:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2013年资料/5月/24日/CentOS 6.3下Zabbix监控MySQL数据库参数

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

CentOS 6.3下Zabbix监控MySQL数据库参数的更多相关文章

  1. CentOS 6.5 下 QT4 连接 mysql 数据库的步骤

    QT4 的安装请参考: CentOS 6.5 下安装 QT 4 mysql 的安装请参考: CentOS 6.5 下安装配置 mysql 1. 预防万一,先安装一下mysql-devel(一定要装!) ...

  2. zabbix监控 -mysql数据库

    1.禁用安装防护[root@mysql213 ~]# vi /etc/selinux/config #关闭安装 SELINUX=disabled 2.授权zabbix监控账号 mysql -uroot ...

  3. zabbix监控mysql数据库信息脚本

    ---恢复内容开始--- 在/usr/local/zabbix/etc/zabbix_agentd.conf增加 # 获取mysql性能指标 UserParameter=mysql.status[*] ...

  4. zabbix实现mysql数据库的监控(四)

    前面介绍的内容都是用第三方开发好的插件进行mysql监控的,可能有些我们关心的监控内容并不在其中,这时一种常用的方法就是定义我们自己的脚本并将它整合到zabbix中,从而在原有监控的基础上进行有力的补 ...

  5. zabbix通过第三方插件percona监控mysql数据库

     zabbix通过第三方插件percona监控mysql数据库                                                                     ...

  6. zabbix利用自带的模板监控mysql数据库

    zabbix利用自带的模板监控mysql数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 有些东西你不会的时候觉得它特别难,但是当你去做的时候就发现如此的简单~zabbix功能 ...

  7. CentOS下zabbix监控mysql5.6版本主从

    目录 CentOS下zabbix监控mysql5.6版本主从 1. Zabbix添加自定义监控流程 2. 具体步骤 1. 编写监控mysql主从脚本 2. mysql赋权 3. 查看脚本执行效果 4. ...

  8. zabbix实现mysql数据库的监控(三)

    上面一章“zabbix实现mysql数据库的监控(二)”使用MPM来监控mysql,但是遇到安装问题始终解决不了,这里改用percona-monitoring-plugins进行zabbxi上监控my ...

  9. zabbix实现mysql数据库的监控(二)

    上章我们把zabbix的服务端和客户端都部署完成了,本章接着进行两部分的设置: 1  添加对mysql数据库主机的监控 2  添加对mysql数据库的监控 一.对数据库服务器主机监控 1 创建主机 步 ...

随机推荐

  1. 使用Git上传本地项目到http://git.oschina.net

    本文前言,因倡导开源精神,我也把代码传上了开源社区,可是,当初使用http://git.oschina.net 网站上传代码的时候不知道使用工具.我竟然一个文件一个文件复制粘贴,可费了我好大一个劲儿, ...

  2. iOS即时通讯之CocoaAsyncSocket源码解析四

    原文 前言: 本文为CocoaAsyncSocket源码系列中第二篇:Read篇,将重点涉及该框架是如何利用缓冲区对数据进行读取.以及各种情况下的数据包处理,其中还包括普通的.和基于TLS的不同读取操 ...

  3. 查看在linux中下载的图片

    1.安装   yum install lrzsz -y 2.找到文件所在的位置选中之后 3.点击那个蓝色的框框里面有一个 用ZMODEM下载 4.选择要保存的位置就可以查看了

  4. scrapy 配置文件指定如何导出数据

    1.导出文件路径 FEED_URI = 'export_data/%(name)s.data' 2.导出数据格式 FEED_FORMAT = 'csv' 3.导出文件编码 FEED_EXPORT_EN ...

  5. Django路由小知识

    from django.urls import path,re_path from app01 import views urlpatterns = [ re_path(r'^articles/200 ...

  6. Mysql 免安装版本配置

    1. 安装命令 (制定安装目录的my.ini文件) mysqld --install MySQL --defaults-file="C:\mysql-5.7.26-winx64\bin\my ...

  7. 重置Docker里的gitlab管理员用户密码

    1.docker ps  找出容器的唯一标识 2.docker exec -it ad9b8c3e20f0 /bin/bash  进入Docker容器运行环境 3.开始重置gitlab管理员用户密码 ...

  8. Linux下杀进程

    $ ps -ef | grep firefox smx : ? :: /usr/lib/firefox-/firefox-bin smx : pts/ :: grep --color=auto fir ...

  9. 史上最全的ORACLE基础教程

    ORACLE命令和语句挺多,全部记忆下来不现实,况且有不常用的指令.下面把大部分的指令做了记录和详细的注释.建议收藏.转发此篇文章,如果忘记可以翻出来查查.关注公众号it_learn获取更多学习资源 ...

  10. 多线程12-ManualResetEventSlim

        ));             ));             ));             t1.Start();             t2.Start();              ...