Nagios is a powerful monitoring tool for your server and you Know immediately on the browser when problems arise. You will need to configure a part of mysql monitoring in easy way follow the below steps,
Client side Configuration:
By default check_mysql script located under /usr/local/nagios/libexec directory, before configure the check_mysql need to create a nagios user and give full permissions.
Open MySQL on terminal and execute the below queries.
# mysql
mysql> CREATE USER 'nagios'@'%' IDENTIFIED BY 'nagios';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
mysql> CREATE USER 'nagios'@'%' IDENTIFIED BY 'nagios';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Execute the below command for testing,
# /usr/local/nagios/libexec/check_mysql -u nagios -p nagios -H host.hostname.com -P 3306
Uptime: 873000 Threads: 10 Questions: 25999491 Slow queries: 34692 Opens: 939970 Flush tables: 1 Open tables: 400 Queries per second avg: 29.781|Connections=645881c;;; Open_files=708;;; Open_tables=400;;; Qcache_free_memory=0;;; Qcache_hits=0c;;; Qcache_inserts=0c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=0c;;; Qcache_queries_in_cache=0;;; Queries=25999491c;;; Questions=25996858c;;; Table_locks_waited=2762c;;; Threads_connected=7;;; Threads_running=3;;; Uptime=873000c;;;
Uptime: 873000 Threads: 10 Questions: 25999491 Slow queries: 34692 Opens: 939970 Flush tables: 1 Open tables: 400 Queries per second avg: 29.781|Connections=645881c;;; Open_files=708;;; Open_tables=400;;; Qcache_free_memory=0;;; Qcache_hits=0c;;; Qcache_inserts=0c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=0c;;; Qcache_queries_in_cache=0;;; Queries=25999491c;;; Questions=25996858c;;; Table_locks_waited=2762c;;; Threads_connected=7;;; Threads_running=3;;; Uptime=873000c;;;
u - User Name
p - Password
H - Host Name
P - Port Number
You may get an above output can add the command in nrep.cfg file /usr/local/nagios/etc/nrpe.cfg
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -u nagios -p nagios -H host.hostname.com -P 3306
Server side Configuration:
Enter services to be monitored in host configuration file.
# vi /usr/local/nagios/etc/objects/host.hostname.cfg
define service{
use generic-service
host_name host.hostname.com
service_description MYSQL
check_command check_nrpe!check_mysql
}
define service{
use generic-service
host_name host.hostname.com
service_description MYSQL
check_command check_nrpe!check_mysql
}
You will need to verify before starting nagios using command,
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
Restart the Nagios server.
# /etc/init.d/nagios restart
Comments (0)