51Testing软件测试论坛
标题: nagios监控mysql [打印本页]
作者: TimiZheng 时间: 2019-9-29 15:35
标题: nagios监控mysql
一般的监控内容nagios都自带了监控程序,比如mysql等,也有一些网上可以去下载,比较特殊的才需要自己写,一般我们自己定义的监控能处理比较特殊的监控。
这里只记录了一个常用的mysql的配置。
mysql 的监控主要通过check_mysql命令(nagios自带),首先测试下命令
- /usr/local/nagios/libexec/check_mysql -H 192.168.AAA.BBB -u USER -p YOURPASSWORD
复制代码 报错:- /usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
复制代码
解决:
这个动态库一般在安装mysql的时候都是已经有的,查找下,然后在/usr/lib64
下做个连接
- ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
复制代码配置命令commands.cfg
- #check mysql
- define command{
- command_name check_mysql
- command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u USER -p YOURPASSWORD
- }
复制代码如果host中没有的,要现在hosts.fg中先登记下
- define service {
- host_name slave144
- service_description MysqlDB
- check_period 24x7
- max_check_attempts 2
- normal_check_interval 1
- retry_check_interval 1
- contact_groups dbagroup
- notification_interval 5
- notification_period 24x7
- notification_options w,u,c,r
- check_command check_mysql
- }
- define service {
- host_name slave145
- service_description MysqlDB
- check_period 24x7
- max_check_attempts 2
- normal_check_interval 1
- retry_check_interval 1
- contact_groups sagroup,dbagroup
- notification_interval 5
- notification_period 24x7
- notification_options w,u,c,r
- check_command check_mysql
- }
- define servicegroup{
- servicegroup_name Mysql-service-group
- alias NA
- members slave144, MysqlDB,slave145, MysqlDB
- }
复制代码检查下配置是否有问题
- /usr/local/nagios/bin/nagios
- -v /usr/local/nagios/etc/nagios.cfg
复制代码有问题会提示错误信息
重启下service nagios restart
[attach]126684[/attach]
文章来源:新浪博客沧海大声啸 作者:kervin(博为峰网校金牌讲师)
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |