| 
 来自:网络  
 
 
Centos6.3的安装就不再讲了,我用的是vbox虚拟机来安装的。                      nagios培训 配置好163的源 
我的A机为192.168.1.107当成监控机。也就是安装nagios服务器的机器。 
我的B机为192.168.1.108当成被监控机。也就是安装nagios-plug和nrpe的机器。 
我们先安装监控机,也就是服务器。  
先安装yum install gcc mysql httpd php gd openssl openssl-devel mysql-server vim wget 
Wget [  /sourceforge/nagios/nagios-4.0.7.tar.gz]sourceforge/nagios/nagios-4.0.7.tar.gz[/url] 
Wget [  /download/nagios-plugins-2.0.3.tar.gz]download/nagios-plugins-2.0.3.tar.gz[/url] 
Wget [  /project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz]project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz[/url]            nagios实施 
 
Ls 可以看到nagios-4.0.7.tar.gz nagios-plugins-2.0.3.tar.gz nrpe-2.14.tar.gz  
yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp 
useradd nagios 
passwd nagios 
groupadd nagcmd 
usermod –a –G nagcmd nagios  
tar –xvzf nagios-4.0.7.tar.gz 
cd nagios-4.0.7 
./configure –with-command-group=nagcmd  
可以先./configure –help先看看帮助,应为默认为主是用nagios用户,不需要指定—with-nagios-user或其它什么的。  
 
Make all 
Make install 
Make install-init 
Make install-commandmode 
Make install-config 
Make install-webconf  
 
Cp –R contrib/eventhandlers/ /usr/local/nagios/libexec/ 
Chown –R nagios:nagios /usr/local/nagios/libexec/eventhandlers                 监控软件 /usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.conf  
/etc/init.d/nagios start 或者service nagios start 
Chkconfig –add nagios 
Chkconfig nagios on 
Chkconfig httpd on 
Service httpd start  
 
Htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin 
输入密码nagios  
 
安装nagios-plugins 
Tar –xvzf nagios-plugins-2.0.3.tar.gz 
Cd nagios-plugins-2.0.3  
./configure –with-nagios-user=nagios –with-nagios-group=nagios 
Make  
Make install 
前面这步做了可以略过,反正要做一次。 
Chkconfig nagios on 或者chkconfig –level 35 nagios on 
Chkconfig httpd on 或者 chkconfig –level 35 httpd on  
 
Iptables –L –n  
Vim /etc/sysconfig/selinux 把selinux改成disabled这个需重启生效。  
 
nagios/ 这个是nagios地址,要输入用户名和密码的nagiosadmin nagios                        nagios配置  
安装NRPE插件。  
Tar –xvzf nrpe-2.14.tar.gz 
Cd nrpe-2.14 
./configure  
Make & make all 
Make install-plugin  
把check_nrpe放到/usr/local/nagios/libex下。才能使用check_nrpe。  
 
 
 
在被监控机器上安装。  
Nagios-plugins安装.  
Useradd nagios 
Passwd nagios 
Tar –xvzf nagios-plugins-2.0.3.tar.gz 
Cd nagios-plugins 
./configure  
Make  
Make install 
Chown –R nagios:nagios /usr/local/nagios  
 
安装nrpe-2.14 
Tar –xvzf nrpe-2.14.tar.gz 
Cd nrpe-2.14 
./configure 
make all 
make install-plugin 
make install-daemon 
make install-daemon-config  
 
yum install xinetd 
chkconfig –add xinetd 
chkconfig xinetd on  
make install-xinetd  
 
vim /etc/xinetd.d/nrpe  
在该文件的only_from  = 127.0.0.1 192.168.1.107  //在后面增加监控主机的地址,以空格间隔                      开源监控软件 vim /usr/local/nagios/etc/nrpe.cfg 这里也是充许访问里添加 192.168.107  
vim /etc/services  
根据其文件格式,添加nrpe      5666/tcp 这行。  
Service xinetd restart  
Netstat –at |grep nrpe 
Netstat –an | grep 5666  
 
Vim /etc/sysconfig/iptables  
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT (该语句有待,不过我另一台也是这样配的) 
好像不添加上面这个不得行,会报check_nrpe:Error - Could not complete SSL handshake  
 
运行ipables –F 清空一下规则,然后保存。 
然后iptables –L –n 查看确认后。  
Service iptables save 
Service iptables restart  
 
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1     //测试NRPE是否正常工作                   nagios安装 
NRPE v2.8.1           //正常的结果会显示当前NRPE的版本号  
 
 
其实在[  /nagios/下会报一个http测试403错误.这是因为192.168.0.107上的httpd没有安装web]nagios/下会报一个http测试403错误.这是因为192.168.0.107上的httpd没有安装web[/url]。我在/var/www/html下创建一个echo “<?php phpinfo(); ?>” >test.php ;&cp test.php index.php测试正常。  
[  /uploads/space/2014/0724/115412_okek_854444.png] [/url] 这个是从控监机查看的被监控机的硬盘使用率的图   
[  /uploads/space/2014/0724/115445_SVnI_854444.png] [/url]  
这个是nagios自带的几种服务的检测,新安装的如果没有在服务器上安装web的话会报个web测试错误,我有个test.php这个了,检测全部正常。  
[  /uploads/space/2014/0724/115514_m0VJ_854444.png] [/url]  
这个是nagios的home图。  
 
 
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流  QQ群号 :476809427  
 
 |