Nagios监控mysql

Nagios监控mysql

工作原理

利用特定的用户定期访问指定的mysql数据库。当不能访问或连不通时则报警。

配置过程如下

1、          在生产库上安装nagios插件,

以nagios-plugins-1.4.15为例来讲述整个配置过程

进入nagios-plugins-1.4.15 目录

./configure  编译

然后是 编译完显示一定要有mysql支持,不然没有check_mysql这个插件

config.status: creating po/Makefile

            --with-apt-get-command:

              --with-ping6-command: /bin/ping6-n -U -w %d -c %d %s

               --with-ping-command: /bin/ping-n -U -w %d -c %d %s

                       --with-ipv6: yes

                      --with-mysql:/usr/bin/mysql_config

                    --with-openssl: yes

                     --with-gnutls: no

               --enable-extra-opts: no

                       --with-perl:/usr/bin/perl

             --enable-perl-modules: no

                     --with-cgiurl:/nagios/cgi-bin

              --with-trusted-path:/bin:/sbin:/usr/bin:/usr/sbin

                   --enable-libtap: no

Make all&&make install

插件安装完毕

再安装nrpe 安装过程略同时是编译安装三步曲:./configure     make make install

2、          配置mysql

mysql>create database nagios;         //建立nagios专用数据

QueryOK, 1 row affected (0.00 sec)

 

mysql>grant select on nagios.* to nagios@'%' identified by '######';  //建立nagios专用用户权限只给selectOK,给多了不安全。###是密码

QueryOK, 0 rows affected (0.00 sec)

 

mysql>flush privileges;                 //刷新权限让数据库接受新的配置

QueryOK, 0 rows affected (0.00 sec)

 

mysql>select User,Password,Host from user;//查询一下

+--------+-----------------------------------------------------------------------+------------------------------------+

|User   | Password                                  | Host                  |

+--------+-----------------------------------------------------------------------+------------------------------------+

|root   |*FD571203974BA9AFE270FE62151AE967ECA5E0AA | localhost             |

|root   |                                           | localhost.localdomain |

|root   |                                           |127.0.0.1             |

|        |                                           |localhost             |

|        |                                           |localhost.localdomain |

|nagios | *34194D8AE12BBBCB89E1755EF0337452C18FF325 | %                     |

+-----------+-----------------------------------------------------------------------+--------------------------------+

6rows in set (0.00 sec)

 用以下命令来验证一下,

[root@localhost/]# /usr/local/nagios/libexec/check_mysql -H 192.168.12.88 -u nagios -d nagios-p 3j5Power

Uptime:3552  Threads: 1  Questions: 56 Slow queries: 0  Opens: 30  Flush tables: 1  Open tables: 23  Queries per second avg: 0.15

[root@localhost /]#

3、            配置nrpe.cfg

[root@localhost/]# vim /usr/local/nagios/etc/nrpe.cfg,加入下面一行

command[check_mysql]=/usr/local/nagios/libexec/check_mysql-H 192.168.12.88 -u nagios -d nagios -p ######   //后面的###代表你设的密码

4、            配置nagios服务端

[root@station1/]# vim /usr/local/nagios/etc/objects/192.168.12.88.cfg   //加入如下内容

defineservice{

        use                    generic-service

        host_name           LDS

        service_description  check_mysql

        check_command     check_nrpe!check_mysql

        action_url           /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$'class='tips'rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$

}

                             //标蓝的部分是加了图形显示的设置,要是你没配置pnp4nagios这行可注掉

 

 

重起nrpe 和服务端的nagios就可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值