在linux主机测试插件check_nt是否能查询windows信息
-H 要查询的主机ip地址 -p指定端口 -v要查询的信息
配置检测一台windows主机的思路首先是安装nsclient++,这个前面已经安装好了,重点要说的是在linux上配置启动监控windows主机;中心点是要监控的主机一切围绕被监控的主机展开
修改文件前请全部备份
1.[root@localhostobjects]# vim windows.cfg
[root@localhostetc]# pwd
/usr/local/nagios/etc
[root@localhostetc]# vim nagios.cfg
重新启动服务,这样一台主机就添加玩了,
是不是觉得很简单,嗯,是的我想告诉你,你想多了,功能这么强大的nagios会这么简单?开玩笑,,咳咳,回归正题,其实添加一台主机也没那么难下面来添加第二台windows主机,
----------------------
先把检测的命令写好
[root@localhost objects]# vim commands.cfg
里面的这些命令我们都可以引用
[root@localhostobjects]# vim windows1.cfg 定义监控的主机
如果要监控多个服务,可以多谢几个define service
[root@localhost etc]# pwd
/usr/local/nagios/etc
[root@localhost etc]# vim nagios.cfg 添加windows1.cfg
check_nrpe插件,运行在监控主机上。
NRPE daemon,运行在远程的linux主机上(通常就是被监控机)
整个的监控过程:(如下图)
当Nagios需要监控某个远程linux主机的服务或者资源情况时:
1).nagios运行check_nrpe插件,我们要在nagios配置文件中告诉它要检查什么.
2).check_nrpe插件会通过SSL连接到远程的NRPEdaemon.
3).NRPE daemon会运行相应的nagios插件来执行检查本地资源或服务.
4).NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.
注意:NRPE daemon需要nagios插件安装在远程被监控linux主机上,否则,daemon不能做任何的监控. 别外因为它们间的通信是加密的SSL,所以在编译安装时都要加上选项, ./configure--enable-ssl --with-ssl-lib=/lib/,否则也会出错.
需要提前安装openssl
在监控主机上安装nrpe插件
[root@localhost /]# tar -zxvf nrpe-2.12.tar.gz -C /usr/src/
[root@localhost nrpe-2.12]# ./configure --enable-ssl --with-ssl-lib=/usr/lib/
[root@localhost nrpe-2.12]# make all
[root@localhost nrpe-2.12]# make install-plugin
配置被监控端
[root@localhost /]# useradd nagios
安装nagios-plugin
[root@localhost /]# tar -zxvf nagios-plugins-1.4.14.tar.gz -C/usr/src/
[root@localhost /]# cd /usr/src/nagios-plugins-1.4.14/
[root@localhost nagios-plugins-1.4.14]# ./configure--with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround(非必加,如果出现
checking for redhat spopen problem…时可以加上这个选项,关于他是干什么的,目前还不知道)
[root@localhost nagios-plugins-1.4.14]# make
[root@localhost nagios-plugins-1.4.14]# make install
[root@localhost nagios-plugins-1.4.14]# chown -R nagios:nagios/usr/local/nagios/
在被监控主机上安装nrpe插件
创建运行nrpe的用户
[root@localhost /]# useradd nagios
[root@localhost /]# tar -zxvf nrpe-2.12.tar.gz -C /usr/src/
[root@localhost /]# cd /usr/src/nrpe-2.12/
[root@localhost nrpe-2.12]# ./configure --enable-ssl--with-ssl-lib=/usr/lib/
[root@localhost nrpe-2.12]# make all
[root@localhost nrpe-2.12]# make install-plugin
[root@localhost nrpe-2.12]# make install-daemon
[root@localhost nrpe-2.12]# make install-daemon-config
配置nrpe
[root@localhost etc]# pwd
/usr/local/nagios/etc
[root@localhost etc]# vim nrpe.cfg
79 allowed_hosts=100.1.1.100 允许来检测的IP地址,多台主机用“,”隔开
[root@localhostetc]# /usr/local/nagios/bin/nrpe -c nrpe.cfg -d 启动nrpe
检查是否启动
[root@localhostnagios]# netstat -anpt|grep nrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 6939/nrpe
在监控端执行
[root@localhostlibexec]# ./check_nrpe -H 100.1.1.103
NRPE v2.12 查看被监控端nrpe的版本
在被监控端如果出现:
[root@localhostlibexec]# ./check_nrpe -H 127.0.0.1
CHECK_NRPE:Error - Could not complete SSL handshake.
请修改/usr/local/nagios/etc/nrpe.cfg
[root@localhostetc]# vim nrpe.cfg
重新启动nrpe进程
[root@localhostlibexec]# ./check_nrpe -H 127.0.0.1
NRPE v2.12
添加一台监控主机(在监控主机上)
[root@localhostobjects]# vim commands.cfg
[root@localhostobjects]# cp localhost.cfg linux103.cfg
[root@localhostobjects]# vim linux103.cfg
[root@localhostetc]# vim nagios.cfg 添加