本监控为基于nagios服务器主动监控方法,利用check_mysql_health实现多种监控模式:
       connection-time          (Time to connect to the server)
       uptime                   (Time the server is running)
       threads-connected        (Number of currently open connections)线程数
       threadcache-hitrate      (Hit rate of the thread-cache)慢查询
       slave-lag                (Seconds behind master)
       slave-io-running         (Slave io running: Yes)主从热备
       slave-sql-running        (Slave sql running: Yes)主从热备
       qcache-hitrate           (Query cache hitrate)
       qcache-lowmem-prunes     (Query cache entries pruned because of low memory)
       keycache-hitrate         (MyISAM key cache hitrate)
       bufferpool-hitrate       (InnoDB buffer pool hitrate)
       bufferpool-wait-free     (InnoDB buffer pool waits for clean page available)
       log-waits                (InnoDB log waits because of a too small log buffer)
       tablecache-hitrate       (Table cache hitrate)
       table-lock-contention    (Table lock contention)锁表率
       index-usage              (Usage of indices)
       tmp-disk-tables          (Percent of temp tables created on disk)
       slow-queries             (Slow queries)
       long-running-procs       (long running processes)
       cluster-ndbd-running     (ndnd nodes are up and running)
       sql                      (any sql command returning a single number)

具体步骤如下:
1、安装
#wget http://labs.consol.de/wp-content/uploads/2009/10/check_mysql_health-2.1.tar.gz
#tar -zxvf check_mysql_health-2.1.tar.gz 
#cd check_mysql_health-2.1
#./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
#make && make install
2、命令测试
#cd /usr/local/nagios/libexec
#./check_mysql_health --hostname 192.168.0.1 --port 3306 --username myname --password mypassword --mode threads-connected --warning 700 --critical 1000
当出现Can't locate DBI.pm的错误时:
#yum install perl-DBI perl-DBD-MySQL -y
再次执行,结果如下:
OK - 607 client connection threads | threads_connected=607;700;1000

命令参数:
–hostname <hostname> 
Der Datenbankserver, der überwacht werden soll. Im Falle von "localhost" kann dieser Parameter weggelassen werden. 
–username <username> 
Der Datenbankuser. 
–password <password> 
Dessen Passwort. 
–mode <modus> 
Mit dem mode-Parameter teilt man dem Plugin mit, was es tun soll. 
–name <objektname> 
Hier kann die Prüfung auf ein einziges Objekt begrenzt werden. 
–name2 <string> 
Verwendet man –mode=sql, dann erscheint das SQL-Statement in der Ausgabe und den Performancedaten. 
–warning <range> 
–critical <range> 
–environment <variable>=<wert> 
–method <connectmethode> 
Mit diesem Parameter teilt man dem Plugin mit, wie es sich zur Datenbank verbinden soll. 
–units <%|KB|MB|GB>

3、nagios命令、服务配置
#vi /usr/local/nagios/etc/objects/commands.cfg
...
#'check_mysql_health'
define command{
        command_name    check_mysql_health
        command_line    $USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$
--warning $ARG6$ --critical $ARG7$
        }
...

#vi /usr/local/nagios/etc/objects/servers/localhost.cfg
...

define service{
        use                             local-service         ; Name of service template to use
        host_name                       myhostname
        service_description             check_mysql_connections
        check_command                   check_mysql_health!192.168.0.1!3306!myname!mypassword!threads-connected!1000!1500
        }

define service{
        use                             local-service         ; Name of service template to use
        host_name                       myhostname
        service_description             check_mysql_table_lock
        check_command                   check_mysql_health!192.168.0.1!3306!myname!mypassword!table-lock-contention!1!2
        }
...
4、重启nagios服务
#service nagios restart

nagios监控mysql的更多相关文章

  1. nagios监控mysql及邮件报警

    1.使用默认监控命令check_http命令+相关的参数来实现,如下: 在command.cfg添加如下关键词监控命令:check_http_word,参数解析:-I指定IP或者主机名,-u指定URL ...

  2. Nagios监控mysql主从复制

    因为公司的nagios用了很久监控项目很多,也在zabbix迁移中,也就先临时用nagios监控mysql主从了 mysql> show slave status\G 查看其输出,即可判定主从复 ...

  3. nagios监控mysql主机,nginx,磁盘IO,网卡流量

    http://blog.chinaunix.net/uid-28685162-id-3506260.html nagios安装完成,打开/usr/local/nagios/etc/nagios.cfg ...

  4. Nagios 监控 Mysql

    被监控机的Mysql监控创建专用数据库.专用数据库账户mysql -uroot -pcreate database nagios_monitor;grant select on nagios_moni ...

  5. nagios监控mysql主从状态

    看了网上很多mysql主从监控的,大部分都是shell的,就算是python的,也是在python下跑shell语句.我写了一个python的监控脚本,用到了mysqldb这个包.脚本如下: [roo ...

  6. nagios系列(七)nagios通过自定义脚本的方式监控mysql主从同步

    nagios监控mysql主从同步 起因:nagios可能监控到mysql服务的运行情况,但确不能监控mysql的主从复制是否正常:有时候,同步已经停止,但管理人员却不知道. 登陆mysql从服务器, ...

  7. Nagios监控平台搭建

    Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员, ...

  8. 一步步实现Nagios监控linux主机及飞信报警

    一步步实现Nagios监控linux主机及飞信报警 上篇文章介绍了在linux主机上架设nagios监控服务,并对windows主机进行服务状态变化的监控,这次我们继续上次内容.      首先实现n ...

  9. Nagios监控mongodb分片集群服务实战

    1,监控插件下载 Mongodb插件下载地址为:git clone git://github.com/mzupan/nagios-plugin-mongodb.git,刚開始本人这里没有安装gitpu ...

随机推荐

  1. u-boot中添加自定义命令

    1.u-boot命令机制u-boot中,每个命令都使用一个struct cmd_tbl_s结构体定义,该定义在include/command.h中实现:struct cmd_tbl_s{ char * ...

  2. 几种任务调度的 Java 实现方法与比较 mark

    任务调度是指基于给定时间点,给定时间间隔或者给定执行次数自动执行任务.本文由浅入深介绍四种任务调度的 Java 实现: Timer ScheduledExecutor 开源工具包 Quartz 开源工 ...

  3. Linux基础之 ---目录结构

    类Unix系统目录结构ubuntu没有盘符这个概念,只有一个根目录/,所有文件都在它下面/ 根目录bin //系统可执行程序,如命令boot //内核和启动程序,所有和启动相关的文件都保存在这里gru ...

  4. centos7添加服务

    [Unit] Description=rockae Service After=network.target [Service] ExecStart=/bin/java -jar /usr/local ...

  5. 【C++程序员学 python】python 之奇葩地方

    一.python 奇葩之一:没有花括号.没有分号 先来一个C类型的函数 void main() { int i = 0; for(int j = 0; j< 6;j++) { i = i +j; ...

  6. 2013年五大主流浏览器 HTML5 和 CSS3 兼容性大比拼【转】

    摘要: 这篇文章给大家带来<五大主流浏览器 HTML5 和 CSS3 兼容性大比拼>,让我们一起来看看2013年的浏览器现状.浏览器厂商之间的竞争促使各大浏览器对 HTML5 和 CSS3 ...

  7. 5种漂亮的纯CSS3动画按钮特效

    这次我们要来分享一款很不错的CSS3按钮动画,这款CSS3按钮一共有5种动画方式,每一种都是鼠标滑过动画形式,虽然这些动画按钮不是十分华丽,但是小编觉得不像其他按钮那样很难扩展,我们可以修改CSS代码 ...

  8. jacky自问自答-java并发编程

    1.java Web中线程不是由tomcat这类web容器负责的吗?为什么还要我控制多线程? 答:这个问题很多初学者都会有的疑惑,举一个我以前做的一个需求,java作为中间平台,是socket服务端, ...

  9. 【WPF】两个下拉列表ComboBox的级联

    需求:两个ComboBox的级联,实现城市–小区级联. 问题:个人感觉WPF的核心应该是数据绑定这块.由于时间紧迫,粗略看Binding也是一头雾水,所以用了比较简单的方法做了两个下拉列表级联的效果: ...

  10. [uboot]What is MLO file?

    转自:https://coherentmusings.wordpress.com/2012/09/05/what-is-mlo-file/ I have had the Beagle-xM for a ...