Tutorial on installing and configuring MySQL performance monitoring software Nagios,
Nagios is an open-source IT infrastructure monitoring system that monitors the running status and network information of mature Linux systems. Nagios can monitor specified local or remote hosts and services, for example, the HTTP service and FTP service provide exception notifications, event processing, and other functions. When a host or service fails, nagios can also send notifications by email or text message. Nagios runs on Linux and Unix platforms and provides an optional browser-based Web interface, this allows the system administrator to view the system running status, network status, various system problems, and log exceptions.
Environment: 192.168.0.201 mysql host rhel6.4
192.186.0.202 nagios host rhel6.4
Install related software packages:
yum install httpd gcc make perl-ExtUtils-Embed.x86_64 -y yum localinstall gd-devel-2.0.35-11.el6.x86_64.rpm -y
Install nagios:
Useradd nagiosusermod-G nagios apache # compile the required software package # the user who runs the nagios service # grant the apache user the write permission to the nagios directory, otherwise web page operation failed tar jxf nagios-cn-3.2.3.tar.bz2 # nagios software installation cd nagios-cn-3.2.3. /configure-enable-embedded-perlmake all // follow the prompts to install make installmake install-initmake install-commandmodemake install-configmake install-webconf // you can use this command under apache to quickly integrate
Install nagios-plugins:
yum install mysql-devel openssl-devel -ytar zxf nagios-plugins-1.4.15.tar.gzcd nagios-plugins-1.4.15./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-libtap --enable-perl-modulesmakemake install
Configure nagios:
vi /usr/local/nagios/etc/nagios.cfg
# Export _file =/usr/local/nagios/etc/objects/localhost. cfg # comment out localhost. cfg file export _file =/usr/local/nagios/etc/objects/services. cfg # create services. cfg file, which stores the service and service group definitions pai_file =/usr/local/nagios/etc/objects/hosts. cfg # create a hosts. cfg file, which stores host and Host group definitions
Configure hosts. cfg:
vi /usr/local/nagios/etc/objects/hosts.cfg
Define host {// host management use linux-server // use the default host rule host_name vm2.example.com // host name alias Nagios vm2 // host alias address 127.0.0.1 // host IP address icon_image switch.gif/ /icon statusmap_image switch. gd2 2d_coords 100,200 // 2D image coordinate 3d_coords 100,200,100 // 3D image coordinate} define hostgroup {// host Group Management hostgroup_name linux-servers // host group name alias Linux Servers // alias members * // * indicates all hosts above
Configure mysql
---- Create a dedicated nagdb Database
mysql> create database nagdb default CHARSET=utf8;
Query OK, 1 row affected (0.01 sec)
mysql> grant select on nagdb.* to 'nagios'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> update mysql.user set 'Password' = PASSWORD('nagios') where 'User'='nagios';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Password' = PASSWORD('nagios') where 'User'='nagios'' at line 1mysql> update mysql.user set Password = PASSWORD('nagios') where user='nagios';Query OK, 1 row affected (0.03 sec)Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
---- Verify it with the following command:
[root@node2 etc]# /usr/local/nagios/libexec/check_mysql -H 192.168.1.152 -u nagios -d nagdb -p nagios
Uptime: 3374 Threads: 1 Questions: 11 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.003
NOTE: If/usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient. so.18: cannot open shared object file: No such file or directory appears
Please refer to $ MYSQL_HOME/lib
[root@node2 lib]# ln -s ./libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so.18
Configure nrpe. cfg
[root@node2 etc]# tail /usr/local/nagios/etc/nrpe.cfg
Command [check_mysql] =/usr/local/nagios/libexec/check_mysql-H 192.168.1.152-u nagios-d nagdb-p nagios // Add this row
Configure the nagios Server
[Root @ node1 etc] # cat services. cfg // Add the following content
define service{ use local-service host_name node2 service_description mysql check_command check_nrpe!check_mysql notifications_enabled 1 }
At last, restart the nrpe and nagios on the server.
Articles you may be interested in:
- Introduction and configuration of Innotop mysql Performance Monitoring Tool
- Install and configure Zabbix to monitor MySQL.