Nagios使用check_mysql監控mysql
Nagios使用check_mysql監控mysql
Nagios監控伺服器:192.168.9.172
mysql伺服器:192.168.9.145
1. 建立測試用的資料庫nagios,並給許可權
[root@mysqltest1 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 288
Server version: 5.1.73-community-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> create database nagios;
Query OK, 1 row affected (0.02 sec)
mysql> grant select on nagios.* to nagios
-> @'%' identified by '123456';
Query OK, 0 rows affected (0.29 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.22 sec)
mysql>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user, password, host from user;
+-------------+-------------------------------------------+---------------+
| user | password | host |
+-------------+-------------------------------------------+---------------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost |
| root | | mysqltest1 |
| root | *4A82FDF1D80BA7470BA2E17FEEFD5A53D5D3B762 | 127.0.0.1 |
| | | localhost |
| | | mysqltest1 |
| replication | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 192.168.9.146 |
| nagios | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | % |
+-------------+-------------------------------------------+---------------+
7 rows in set (0.01 sec)
mysql>
mysql>
mysql>
2. nagios監控伺服器命令測試:
[root@nagios libexec]# mysql -uroot -p123456
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@nagios libexec]# cd /var/lib/mysql/
[root@nagios mysql]# ll
總用量 28784
drwx------. 2 mysql mysql 12288 9月 9 23:21 cacti
drwx------. 2 mysql mysql 20480 9月 9 23:22 centreon
drwx------. 2 mysql mysql 12288 9月 9 23:22 centreon_status
drwx------. 2 mysql mysql 4096 9月 18 15:28 centreon_storage
-rw-rw----. 1 mysql mysql 18874368 11月 10 15:08 ibdata1
-rw-rw----. 1 mysql mysql 5242880 11月 10 15:08 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 11月 10 15:08 ib_logfile1
drwx------. 2 mysql mysql 4096 9月 9 23:21 mysql
srwxrwxrwx 1 mysql mysql 0 9月 24 14:56 mysql.sock
drwx------. 2 mysql mysql 4096 11月 10 00:00 syslog
drwx------. 2 mysql mysql 4096 9月 9 23:21 test
-rwxrwxrwx 1 root root 49848 9月 22 16:52 tuning-primmer.sh
[root@nagios mysql]# pwd
/var/lib/mysql
[root@nagios tmp]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@nagios tmp]# ll
總用量 4
lrwxrwxrwx 1 root root 25 11月 10 15:09 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-r--r-- 1 root root 81 11月 10 08:03 ntp.log
[root@nagios tmp]# ll
總用量 4
lrwxrwxrwx 1 root root 25 11月 10 15:09 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-r--r-- 1 root root 81 11月 10 08:03 ntp.log
[root@nagios tmp]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9907711
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
#測試可連線到測試資料庫192.168.9.145
[root@nagios tmp]# mysql -h 192.168.9.145 -unagios -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 289
Server version: 5.1.73-community-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| nagios |
| test |
+--------------------+
3 rows in set (0.03 sec)
mysql>
mysql>
mysql> exit
Bye
You have new mail in /var/spool/mail/root
3.使用測試,及返回結果:
[root@nagios tmp]# /usr/local/nagios/libexec/check_mysql -H 192.168.9.145 -u nagios -d nagios -p 123456
Uptime: 953443 Threads: 3 Questions: 1480 Slow queries: 0 Opens: 52 Flush tables: 1 Open tables: 28 Queries per second avg: 0.1
[root@nagios tmp]#
Nagios監控伺服器:192.168.9.172
mysql伺服器:192.168.9.145
1. 建立測試用的資料庫nagios,並給許可權
[root@mysqltest1 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 288
Server version: 5.1.73-community-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> create database nagios;
Query OK, 1 row affected (0.02 sec)
mysql> grant select on nagios.* to nagios
-> @'%' identified by '123456';
Query OK, 0 rows affected (0.29 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.22 sec)
mysql>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user, password, host from user;
+-------------+-------------------------------------------+---------------+
| user | password | host |
+-------------+-------------------------------------------+---------------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost |
| root | | mysqltest1 |
| root | *4A82FDF1D80BA7470BA2E17FEEFD5A53D5D3B762 | 127.0.0.1 |
| | | localhost |
| | | mysqltest1 |
| replication | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 192.168.9.146 |
| nagios | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | % |
+-------------+-------------------------------------------+---------------+
7 rows in set (0.01 sec)
mysql>
mysql>
mysql>
2. nagios監控伺服器命令測試:
[root@nagios libexec]# mysql -uroot -p123456
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@nagios libexec]# cd /var/lib/mysql/
[root@nagios mysql]# ll
總用量 28784
drwx------. 2 mysql mysql 12288 9月 9 23:21 cacti
drwx------. 2 mysql mysql 20480 9月 9 23:22 centreon
drwx------. 2 mysql mysql 12288 9月 9 23:22 centreon_status
drwx------. 2 mysql mysql 4096 9月 18 15:28 centreon_storage
-rw-rw----. 1 mysql mysql 18874368 11月 10 15:08 ibdata1
-rw-rw----. 1 mysql mysql 5242880 11月 10 15:08 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 11月 10 15:08 ib_logfile1
drwx------. 2 mysql mysql 4096 9月 9 23:21 mysql
srwxrwxrwx 1 mysql mysql 0 9月 24 14:56 mysql.sock
drwx------. 2 mysql mysql 4096 11月 10 00:00 syslog
drwx------. 2 mysql mysql 4096 9月 9 23:21 test
-rwxrwxrwx 1 root root 49848 9月 22 16:52 tuning-primmer.sh
[root@nagios mysql]# pwd
/var/lib/mysql
[root@nagios tmp]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@nagios tmp]# ll
總用量 4
lrwxrwxrwx 1 root root 25 11月 10 15:09 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-r--r-- 1 root root 81 11月 10 08:03 ntp.log
[root@nagios tmp]# ll
總用量 4
lrwxrwxrwx 1 root root 25 11月 10 15:09 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-r--r-- 1 root root 81 11月 10 08:03 ntp.log
[root@nagios tmp]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9907711
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
#測試可連線到測試資料庫192.168.9.145
[root@nagios tmp]# mysql -h 192.168.9.145 -unagios -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 289
Server version: 5.1.73-community-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| nagios |
| test |
+--------------------+
3 rows in set (0.03 sec)
mysql>
mysql>
mysql> exit
Bye
You have new mail in /var/spool/mail/root
3.使用測試,及返回結果:
[root@nagios tmp]# /usr/local/nagios/libexec/check_mysql -H 192.168.9.145 -u nagios -d nagios -p 123456
Uptime: 953443 Threads: 3 Questions: 1480 Slow queries: 0 Opens: 52 Flush tables: 1 Open tables: 28 Queries per second avg: 0.1
[root@nagios tmp]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1327449/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用nagios監控oracleiOSOracle
- 將Nagios監控資訊存入MySQLiOSMySql
- MySQL伺服器部署nagios監控MySql伺服器iOS
- nagios監控例項 -- PostgreSQL監控iOSSQL
- nagios批量新增監控iOS
- Nagios 裡面監控MySQL 監控事務夯住(RUNNING)報警通知iOSMySql
- nagios的配置(監控端和被監控端)iOS
- nagios監控例項 -- Windows伺服器監控iOSWindows伺服器
- 運維監控利器nagios運維iOS
- Nagios 監控ESXI指令碼iOS指令碼
- Nagios監控系統搭建iOS
- 使用Nagios打造專業的業務狀態監控iOS
- nagios監控華為5700交換機iOS
- nagios監控drbd同步狀態iOS
- Nagios for Aix監控客戶端iOSAI客戶端
- nagios監控例項 -- 伺服器基本狀況監控iOS伺服器
- nagios監控linux主機監控記憶體指令碼iOSLinux記憶體指令碼
- Nagios監控lvs服務iOS
- nagios監控 ogg同步狀態iOS
- nginx下搭建nagios監控環境NginxiOS
- nagios-新增記憶體監控iOS記憶體
- nagios監控頻寬外掛薦iOS
- nagios check_mysql錯誤,找不到libmysqlclient.so.18的解決辦法iOSMySqlIBMclient
- zabbix使用perconaplugin監控mysqlPluginMySql
- 推薦使用innotop監控mysqlMySql
- Cacti+Nagios監控平臺完美整合iOS
- nagios監控linux磁碟io的bugiOSLinux
- nagios監控流量大小的外掛iOS
- nagios-新增oracle資料庫監控iOSOracle資料庫
- linux效能監控工具——NAGIOS和OVOLinuxiOS
- 使用Zabbix + Python對Mysql監控PythonMySql
- Nagios+Centreon監控系統簡介iOS
- centos7 nagios 配置被動模式監控CentOSiOS模式
- Nagios+Cacti監控平臺完美整合部署iOS
- nagios監控windows 報NSClient - ERROR: Invalid passwordiOSWindowsclientError
- nagios-監控端的localhost.cfg配置iOSlocalhost
- nagios-建立記憶體監控指令碼iOS記憶體指令碼
- Nagios 監控系統架設全攻略iOS