服务端安装:http://note.t4x.org/code/infrastructure-monitoring-nagios-server-config/
配置过程:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/usr/sbin/useradd nagios -M -s /sbin/nologin mkdir /byrd/tools/nagios -p cd /byrd/tools/nagios/ wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz tar zxf nagios-plugins-2.0.3.tar.gz cd nagios-plugins-2.0.3 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker make make install cd .. wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz tar zxf nrpe-2.15.tar.gz cd nrpe-2.15 yum install openssl-devel -y ./configure make all make install-plugin make install-daemon make install-daemon-config cd /usr/local/nagios/etc/ ################增加allowhost主机################ allowed_hosts=127.0.0.1,1.1.1.26 ################增加allowhost主机################ /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d /etc/init.d/iptables stop |
脚本:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
#!/bin/bash # Author:Byrd # Version:1.0 # Site:note.t4x.org # Contact:root#t4x.org #This script for Nagios-CLIENT PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG="en_US.UTF-8" # Check if user is root if [ $UID != "0" ]; then echo "Error: You must be root to run this script, please use root to install Nagios3.5.1" exit 1 fi clear echo "=========================================================================" echo "INSTALL NAGIOS-CLIENT" echo "=========================================================================" NagiosPls=http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz NagiosNrpe=http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz NagiosNrpV=nrpe-2.15 NagiosPve=nagios-plugins-2.0.3 NagiosDir=/byrd/tools/nagios /usr/sbin/useradd nagios -M -s /sbin/nologin if [ ! -f $NagiosDir/$NagiosPve.tar.gz ];then cd $NagiosDir yum install perl-devel -y wget $NagiosPls tar zxf $NagiosPve.tar.gz cd $NagiosPve ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules make && make install RETVALPls=$? else cd $NagiosDir yum install perl-devel -y tar zxf $NagiosPve.tar.gz cd $NagiosPve make clean ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules make && make install RETVALPls=$? fi if [ $RETVALPls -eq 0 ];then echo "$NagiosPve INSTALL SUCCESSFUL" else echo "$NagiosPve INSTALL FAILED" exit $RETVALPls fi if [ ! -f $NagiosDir/$NagiosNrpV.tar.gz ];then cd $NagiosDir wget $NagiosNrpe tar zxf $NagiosNrpV.tar.gz cd $NagiosNrpV ./configure make all make install-plugin make install-daemon make install-daemon-config else cd $NagiosDir tar zxf $NagiosNrpV.tar.gz cd $NagiosNrpV make clean ./configure make all make install-plugin make install-daemon make install-daemon-config fi if [ -f /usr/local/nagios/libexec/check_nrpe ];then echo "$NagiosNrpV INSTALL SUCCESSFUL" sed -i 's#allowed_hosts=127.0.0.1#allowed_hosts=127.0.0.1,1.1.1.26#g' /usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d else echo "$NagiosNrpV INSTALL FAILED" echo 1 fi |
备注:启动客户端
0 |
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d |
错误整理:
Q:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
Using Makefile.PL Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /byrd/tools/nagios/nagios-plugins-2.0.3/perlmods/Test-Simple-0.98/blib/lib /byrd/tools/nagios/nagios-plugins-2.0.3/perlmods/Test-Simple-0.98/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 6. BEGIN failed--compilation aborted at Makefile.PL line 6. make[3]: Entering directory `/byrd/tools/nagios/nagios-plugins-2.0.3/perlmods/Test-Simple-0.98' make[3]: *** No targets specified and no makefile found. Stop. make[3]: Leaving directory `/byrd/tools/nagios/nagios-plugins-2.0.3/perlmods/Test-Simple-0.98' Can't run make. Please rm -rf /byrd/tools/nagios/nagios-plugins-2.0.3/perlmods/Test-Simple-0.98 to remake from this point) at ../tools/build_perl_modules line 235. make[2]: *** [all-local] Error 2 make[2]: Leaving directory `/byrd/tools/nagios/nagios-plugins-2.0.3/perlmods' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/byrd/tools/nagios/nagios-plugins-2.0.3' make: *** [all] Error 2 |
A:
0 |
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!