安装mysql之后,需要对mysql服务进行监控。

 
nagios开源自带的check_mysql 对 mysql 的slave 机监控倒是不错。但是对数据库主机监控就略显不足了。
 
使用一个监控插件:check_mysql_health
 
下载和使用方法见:
 
http://exchange.nagios.org/directory/MySQL/check_mysql_health/details
 
具体监控:
 
对于slave 机 ,使用nagios 自带的 check_mysql 监控
 
command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql -H localhost -s /tmp/mysql.sock -u root -p xxx -S -w 1 -c 3
 
其中用户和密码有可能会更改。延迟1秒警告,延迟3秒报警。
 
check_mysql_health 监控mysql master 服务器
 
/usr/local/nagios/libexec/custom/check_mysql_health --hostname localhost --socket /tmp/mysql.sock --username root --password xxxxxx --mode xxxxx --warning xxxxx --criticalxxxxx
 
mode:

connection-time (Time to connect to the server)

uptime (Time the server is running)

threads-connected (Number of currently open connections)

threadcache-hitrate (线程缓存命中率)

slave-lag (Seconds behind master)

slave-io-running (Slave io running: Yes)

slave-sql-running (Slave sql running: Yes)

qcache-hitrate (查询命中率,如果这个值接近100%,说明服务器select的优化就越好)

qcache-lowmem-prunes (因为内存小,从内存删除缓存查询的数量,可以增大query_cache_size,减小lowmem,增加命中率的优化)

keycache-hitrate (MyISAM key 缓存命中率,如果命中率太低,增大key_buffer_size)

bufferpool-hitrate (InnoDB 缓冲池命中率)

bufferpool-wait-free (InnoDB 缓冲池等待清理的页面)

log-waits (InnoDB log 等待写入时间,如果这个等待时间太大,增大log缓冲池大小)

tablecache-hitrate (Table 缓存命中率)

table-lock-contention (Table 的lock率)

index-usage (索引使用率,越大说明索引越好,越小说明索引优化不充分)

tmp-disk-tables (临时表创建的数量)

slow-queries (慢查询占所有查询的比率,这个值如果很高说明mysql数据库优化不够)

long-running-procs (长期运行的进程)

cluster-ndbd-running (mysql集群监控)

sql (执行一个返回一个数字的SQL,检查mysql是否可以链接查询)

 
举例:
nrpe.cfg:
command[check_mysql_health]=/usr/local/nagios/libexec/custom/check_mysql_health --hostname localhost --socket /tmp/mysql.sock --username xxxxx --password xxxxx --mode $ARG1$ --warning $ARG2$ --critical $ARG3$ 
 
xxx.cfg:
define service{
        use                     xxxxxx
        host_name               xxxxxx
        service_description     mysql数据库连接数
        check_command           check_nrpe_args!check_mysql_health!threads-connected!80!120
}
 
define service{
        use                     xxxxx
        host_name               xxxxx
        service_description     mysql数据库innodb缓存命中
        check_command           check_nrpe_args!check_mysql_health!bufferpool-hitrate
}
define service{
        use                     xxxxx
        host_name               xxxxx
        service_description     mysql数据库innodb缓冲池等待清理的页
        check_command           check_nrpe_args!check_mysql_health!bufferpool-wait-free
}
define service{
        use                     xxxxx
        host_name               xxxxx
        service_description     mysql数据库innodblog写入等待时间
        check_command           check_nrpe_args!check_mysql_health!log-waits
}
define service{
        use                     xxxxx
        host_name               xxxxx                                                                                   
        service_description     mysql数据库锁表率
        check_command           check_nrpe_args!check_mysql_health!table-lock-contention
}
define service{
        use                     xxxxx                                                                                  
        host_name               xxxxx
        service_description     mysql数据库打开文件数
        check_command           check_nrpe_args!check_mysql_health!open-files!80!90
}
define service{
        use                     xxxxx                                                                                 
        host_name               xxxxx
        service_description     mysql数据库慢查询率
        check_command           check_nrpe_args!check_mysql_health!slow-queries!5!10
}
 
搞定。
 
PS:对 warnging 和 critical 的值 :  10 就是 大于10%报警, 10: 就是小于10%报警, 不填就是默认的数值。
mode 一个语句只能一个,
 
--mode xxx1  xxx2    : xxx1 生效
--mode xxx1  --mode xxx2  : xxx2 生效

最新文章

  1. Perl碎碎念
  2. WCF传输大数据的设置2
  3. BZOJ 1026: [SCOI2009]windy数
  4. 你好,欢迎来到我的博客,我是博主royalmice1
  5. mui禁止横屏显示,仅支持竖屏显示
  6. WPF 自定义控件
  7. 《构建之法》第8、9、10章读书笔记、读后感以及Sprint1总结
  8. Cheatsheet: 2014 07.01 ~ 07.31
  9. rsync服务架设(数据同步|文件增量备份)
  10. UVA 796 Critical Links(无向图求桥)
  11. 提高效率的便签By番茄时间管理 win7标签,小功能,大作用
  12. res/drawable目录
  13. 【Vue-Cli3.0】【2】渲染
  14. vue-cli 发布部署IIS
  15. Fiddler抓包6-get请求(url详解)
  16. 测试中Android与IOS分别关注的点
  17. Beta阶段敏捷冲刺三
  18. Android Camera2 Opengles2.0 实时滤镜(冷暖色/放大镜/模糊/美颜)
  19. java UTC时间和local时间相互转换
  20. css学习之LInk & import

热门文章

  1. 一台电脑上的git同时使用两个github账户
  2. 【JUC】JDK1.8源码分析之LinkedBlockingQueue(四)
  3. 7.Struts2复杂类型数据的接受
  4. MySQL数据迁移到SQL Server
  5. Windows Server配置Jenkins,实现监测SVN提交自动构建.net4.5的项目
  6. GitHub-版本控制
  7. C#循环测试题
  8. anonymousIdentification 与匿名访问
  9. Solr3.6.1 在Tomcat6下的环境搭建
  10. Suggestion(搜索建议)产品和技术