nagios监控mysql方法
nagios中添加mysql监控:
1.在要监控的数据库服务器新建库和用户:
CREATE DATABASE nagdb DEFAULT CHARSET=utf8;
GRANT SELECT ON nagdb.* TO ‘nagios’@'192.168.100.%’;
UPDATE mysql.user SET `Password` = PASSWORD(‘********’) WHERE `User` = ‘nagios’
FLUSH PRIVILEGES;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
2.被监控端安装:
apt-get install libmysqlclient15-dev
./configure –with-mysql=/opt/mysql or /var/mysql/ #针对每台数据库服务器的路径不同
make
make distclean
make all
vi /usr/local/nagios/etc/nrpe.cfg
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
添加:
command[check_mysql_status]=/usr/local/nagios/libexec/check_mysql -H 192.168.100.200 -u nagios -d nagdb -p ‘nagios_4_dxy!’
- 1.
- 2.
3.监控端服务器:
vi /usr/local/nagios/etc/objects/commands.cfg
- 1.
- 2.
添加:
#check_mysql
define command{
command_name check_mysql
command_line $USER1$/check_Mysql -H $HOSTADDRESS$ -u nagios -d nagdb -p *******
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
4.在监控端服务器的*.cfg中添加:
define service{
use generic-service
host_name Stalingrad-server
service_description check_mysql
check_command check_nrpe!check_mysql_status
notifications_enabled 0
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
5.重启nagios。Nagios监控Mysql就可以啦。
【编辑推荐】