d
root 30442 3292 0 23:48 pts/0 00:00:00 grep nrpe
[root@localhost bin]#
[root@localhost bin]# netstat -tnlp |grepnrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 30440/nrpe
tcp 0 0 :::5666 :::* LISTEN 30440/nrpe
[root@localhost bin]#
?
?
6,监控端安装nrpe
tar xf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
make all
make install-plugin
?
#安装完成后,会在Nagios安装目录的libexec下生成check_nrpe的插件,如下所示:
[root@test_db2 nagios]# ll /usr/local/nagios/libexec/check_nrpe
-rwxrwxr-x 1 nagios nagios 76777 Jun 2523:53 /usr/local/nagios/libexec/check_nrpe
[root@test_db2 nagios]#
?
检测报错:
[root@test_db2 libexec]# ./check_nrpe -H192.168.121.210
CHECK_NRPE: Error - Could not complete SSLhandshake.
[root@test_db2 libexec]#
?
去客户端在allowed_hosts中添加监控端IP地址
[root@localhost ~]# vim/usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.121.211
?
?
在mysql服务器上,报错:
[root@localhost ~]#/usr/local/nagios/libexec/check_mysql -unagios -P3306 -S -s/usr/local/mysql/mysql.sock -Hlocalhost --password='nagiosq@0512' -d test -w 60-c 100
/usr/local/nagios/libexec/check_mysql:error while loading shared libraries: libmysqlclient.so.18: cannot open sharedobject file: No such file or directory
[root@localhost ~]#
?
[root@localhost ~]# find / -namelibmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18
/root/mysql/mysql-5.6.12/libmysql/libmysqlclient.so.18
/root/mysql-5.6.12/libmysql/libmysqlclient.so.18
[root@localhost ~]# ln -s/usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
[root@localhost ~]#
?
添加mysql账号:
mysql> GRANT PROCESS, SUPER, REPLICATIONCLIENT ON *.* TO 'nagios'@'localhost' IDENTIFIED BY 'nagiosq@0625';
Query OK, 0 rows affected (0.05 sec)
?
mysql>
?
客户端自己检测:
[root@localhost ~]#/usr/local/nagios/libexec/check_mysql -unagios -P3306 -s /usr/local/mysql/mysql.sock -Hlocalhost--password='nagiosq@0625' -d test -w 60 -c 100
Uptime: 1823238 Threads: 6 Questions: 684495 Slow queries:0 Opens: 124 Flush tables: 1 Open tables: 116 Queries per second avg:0.375|Connections=3116c;;; Open_files=19;;; Open_tables=116;;; Qcache_free_memory=61538880;;;Qcache_hits=176271c;;; Qcache_inserts=41370c;;; Qcache_lowmem_prunes=0c;;;Qcache_not_cached=331835c;;; Qcache_queries_in_cache=3373;;; Queries=684496c;;;Questions=681384c;;; Table_locks_waited=0c;;; Threads_connected=5;;;Threads_running=2;;; Uptime=1823238c;;;
[root@localhost ~]#
?
7,完善配置文件
7.1在command.cfg里面添加监控command命令
将servers.cfg添加进nagios.cfg里面,将command.cfg里面的check_host_alive以及check_mysql_status补充好,然后重启nagios
# add by timman on 20150512
define command{
command_name check_mysql_status
command_line $USER1$/check_mysql_status-w $ARG1$ -c $ARG2$
}
?
# 'check_nrpe' command definition,add bytimman on 20140508
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe-H $HOSTADDRESS$ -c $ARG1$
}
?
define command{
command_name check_host_alive
command_line $USER1$/check_ping-H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
?
7.2在servers.cfg里面添加check_mysql_status、 check_host_alive等服务监控项。
[root@test_db2 etc]# more servers.cfg
# servicedefinition
?
define service{
host_name cactitest